Wednesday, July 7, 2010

WebMatrix PHP Editor

Yesterday Scott Guthrie announced WebMatrix, a new tool from Microsoft which lowers the barriers to entry for creating your own .NET based website. It features all the newest Microsft treats which Guthrie has introduced over the last week: IIS Express, Compact SQL Server, and Razor.

Tonight, rather than playing with all these new toys, I was able to setup WebMatrix as an IDE for an existing PHP website I manage. A screenshot (clicky, please):

It's pretty, by far the best looking PHP IDE I've tried. And easy to use; everything about it screams simplicity (which is good and bad: no intellisense, no right-click context menu). Still a huge improvement over my previous editor: Filezilla and TextPad :)

Two big complaints: the Publish functionality wasn't working well for me (I update to an ftp site, WebMatrix updates *all* files everytime) and my site doesn't render perfectly in the browser (css-related stuff, not sure if it's an IIS Express).

I did have to go through a bit of pain to get IIS Express to render php pages. Detailed issue below:
  • Trying to load a .php page, I recieved a HTTP 404.3 error: "The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map."
  • The handler is not present! I spent quite a bit of time trying to manually update the .config file (I think I was updating the wrong one - %WebMatrixInstall%/config/applicationHost.config?? Anybody know?) before finding this post which details how to add a php handler to IIS 7.0 and IIS 7.5 (and IIS Express, which is based on IIS 7.5) via appcmd.exe.

And how to fix it:

  • Open a command prompt at your WebMatrix install directory (mine is "C:\Program Files (x86)\Microsoft WebMatrix"
  • For the following command, replace the scriptProcessor parameter with your proper path to php-cgi.exe and run: " appcmd set config /section:handlers /+"[name='PHP_via_FastCGI',scriptProcessor='C:\Program Files (x86)\PHP\php-cgi.exe',path='*.php',verb='*',modules='FastCgiModule',resourceType='Either']" "
  • Do the same with this command: " appcmd set config -section:system.web
    Server/fastCgi /+"[fullpath='C:\Program Files (x86)\PHP\php-cgi.exe']" /commit:a
    pphost "
  • It works (for me)!

All in all, I was very impressed with WebMatrix and IIS Express. I'll be using WebMatrix to manage my PHP site in the future and I hope to play with Razor and SQL Express soon!

Tuesday, June 1, 2010

TextPad and XML Tidy

I've been using TextPad for general text editing lately. Works quite nicely, no huge complaints (syntax highlighting would be nice, perhaps there's an add-on out there???).

There is an Add-On for Text-Pad named XML Tidy that formats XML documents nicely, taking them from ugly one-line documents to properly tabbed hierarchies. Very cool, this feature is a must for Text-Pad users working with XML documents. I ran into some problems during install on Windows 7 and will note the solution here. First, an install guide:

1. Download XML Tidy from the Text-Pad Add-On page
2. Unzip and put the folder in a permanent location (I chose the existing TextPad install folder)
3. In TextPad, install the Add-On by going to Configure->Preferences and selecting Tools in the tree. Click Add-> Program and select the XML Tidy exe (where you put in in step 2).
4. You will now be able to configure XML Tidy in the same Preferences window. Expand Tools and select XML Tidy. You'll need to change Parameters field to "$Clip $DocWnd" (as per the XML Tidy Readme). Hit OK.
5. You can now run XML Tidy in TextPad by going to Tools->External Tools -> XML Tidy. Note the Ctrl + (number) shortcut, very handy!

At this point you should be excited, as you've installed and configured XML Tidy. Open up your favorite XML document, hit Ctrl + (number) aaaaaand.... Nothing happens. Here lies the issue.

XML Tidy is throwing an error (it's hidden when running in TextPad). Run XMLTide.exe by itself, you'll get the following error in a dialog box:

"The program can't start because MSVBVM50.DLL is missing from your computer. Try reinstalling the program to fix this problem."

XML Tidy requires Visual Basic 5 runtime files, which apparently includes certain DLLs no longer packaged with or are deprecated in Windows 7 (Windows Vista, too? I didn't research it thoroughly). Luckily you can still download the required DLL here. Download and unzip the CAB file (a DLL and an INF file are inside) to the same directory as XMLTidy.exe (the exe will be able to find the DLL if it's located in the same directory).

That should be it! Try running the exe again, you should get a different error that says you need to pass text to the program. Go back into TextPad and try running the Add-On again there. I hope it works for you!

Friday, May 7, 2010

Pepsi Promoting Entrepreneurship

It's great to see entrepreneurship promoted anywhere: schools, businesses, a beverage company's latest philanthropy...

Check out Pepsi's Refresh Project, a philanthropic project whose basic premise hinges on the American Entrepreneurial Spirit(tm). Here's the gist:
  • Every month, Pepsi gives away $1.3 million to 32 philanthropic ideas
  • Anyone can submit an idea
  • Pepsi chooses 1000 ideas each month to be voted on by YOU!
  • YOU can cast up to 10 votes per day in support of any of the 1000 ideas
  • The top ideas at the end of the month are verified as legit by Pepsi, Pepsi sends a check
Brilliant! Some ideas are rather boring "grant money please" applications. But others, others radiate with the entrepreneurial excitement that is so fun and energizing to behold. It's a joy to see that spirit promoted and rekindled in philanthropy and America at large.

Wednesday, April 21, 2010

Setting up SVN

I've used this guide from Coding Horror several times over the past year. It takes the reader through the install and configuration of a simple SVN server. The end solution is hosted as a Windows Service and provides simple user authentication.

Also, Programming Nightmare does not directly borrow its name from Coding Horror :-)

Friday, April 16, 2010

DBML (LINQ to SQL) Wonkiness

I like using DBML (LINQ to SQL) as an ORM system when I'm doing work in C#.NET. It's far from a perfect solution but it's easy to use and expandable (partial classes for the win).

Visual Studio 2008 has a graphical DBML file editor which allows you to drag tables from a SQL Server database onto its canvas. Probably the biggest pain working with this setup comes when making DB changes and you need to reflect those changes in this graphical editor. The best solution I've come up with in doing this is to basically delete all the tables you've updated, then drag them back onto the canvas. Unfortunately this requires deleting stored procedures that return an object of that table type.. So you have to re-add those as well, which makes this non-scalable solution. (If you have a better update solution, please post it!)

This is where the wonkiness comes in. I've had the following happen a few times: I have the DB Server connected inside Visual Studio and at the same time I'm making updates to it within SQL Server Management Studio. Changes are made to the database within Management Studio and I'll need to go through the above process in Visual Studio. Then something goofy happens. I'll be unable to add a stored procedure, receiving an error that indicates that the SP's return object does not match the Table shown in the graphical editor. Or Foreign Keys won't appear in the graphical editor or its produced code. The problem persists until Visual Studio is restarted. After a restart everything will work as expected.

This wonkiness has me caused some hair pulling over the last year. Hopefully this tip - restart Visual Studio if the graphical DMBL editor isn't behaving as expected - will save you some time.

Tuesday, April 6, 2010

Getting Back Into Gaming

I have fallen out of touch with the gaming universe.

It happened slowly... I quit checking for new articles every hour. Then I'd check it every day and just glance over the feeds for something interesting, not having time to keep up on all games on all consoles. I quit reading PvP. I didn't listen to the Gamers With Jobs podcast. I stopped watching Zero Punctuation. Before long I fell behind on Dubious Quality, xkcd and Penny Arcade..

As of today, it's been over 6 months since I've felt "in touch" with the gaming industry. It really came to light today when I stumbled across this article, from 2 weeks ago. (Nintendo has released some info on the Nintendo 3DS, a new handheld which will be unveiled at E3 this year). Back in my gaming days, this is the type of thing that I would have known about less than an hour after the news broke. And I would have been incredibly excited about it. Now it's something I'm interested in and somewhat disappointed that I didn't know about.

I don't need to get back to the point where I get know the hourly news on every game. However, gaming is something I'm interested in and passionate about, a hobby that I want to keep my nose in and an industry I enjoy keeping abreast of. I firmly believe that happiness is a product of doing the things you enjoy (advanced concept there). What does it say for my future if I'm unable to make time to do the things I enjoy today, when I have so little responsibility?

So I'm going to tiptoe back into gaming news. I plan on reading the sites I loved: Dubious Quality, xkcd, Penny Arcade, Rock-Paper-Shotgun, Gamers With Jobs.. These are all easy to digest in 15 minutes a day. Today I bought a little something-something to jumpstart these refound habits:

Sure I'll miss the breaking, sometimes obscure Kotaku and Joystiq news; I will get the highlights instead. I'll be doing something I enjoy, regardless.

Monday, April 5, 2010

Batch Photo Resizing

This is how I want picture resizing to work: Drag pictures or a folder onto an executable icon, that exe should then transcode those photos (recursively exploring sub-folders) to a Facebook / CD-RW friendly 1 megapixel image.

The Google brought me this app: Picture Resizer 4.0. PR4 works just like I've outlined above! Configuration is done by renaming the executable (appending options to the end of it). The site has a "Renaming Wizard" to help you out with this:

Shown are the options I used, which gave me images in the kB's rather than the MB's. Who needs all those pixels anyway?

Picture Resizer 4.0. Googling so you don't have to.