The Mona Lisa in PHP

Recently on Hacker News it has become common place to bash PHP. There was an article posted to the site with a title of “At 14, is PHP Finally Growing Up?” which started a slew of flame bait. I took it upon myself to post this morsel of a comment:

I would like to argue the C language argument here. If I want to shoot myself in the foot, the language should let me. If I want to paint the Mona Lisa, the language should let me. PHP does that.

That prompted a few snarky remarks about which resolutions and to what extent PHP could paint the Mona Lisa.

So I did it.

Full size: http://williamriggins.com/mona.php?x=400&y=571

Favicon Size: http://williamriggins.com/mona.php?x=10&y=10

Code (minus base64′d image constant): http://pastie.org/506643

Rails, OAuth and GameTweet

Yesterday I launched a little tool for twitter using Ruby on Rails, Capistrano (with Deprec), and OAuth called GameTweet. This is the first Rails application I’ve deployed since I started playing with the stack a few weeks ago. The idea for GameTweet came one night when I was thinking about the old TD clan website before the site went down. There used to be a feature for anyone who wanted to be text messaged when a game was about to start where a user could put in their phone number and carrier and any member of the site could send out a mass text to those on the list notifying them when they were going to play. Fast forward a few years into the future and we have Twitter, which works with most phones and can notify users when a message is posted.

The idea was simple: Use Twitter to notify my friends when and where I was playing a game, specifically a PC game.

I remembered that Twitter was implementing a new authentication method which might just work for something like this, as basic authentication always seemed dirty to me. Why would anyone in their right mind hand out their username and password? A quick Google for “Twitter OAuth in Ruby on Rails” and I hit the Twitter OAuth examples. It didn’t take much to fashion the quick and dirty example into a working system. Actually, I’d estimate I was in the single digit hour range as for work involved. It was simple, which seriously scared me. Capistrano and Deprec really made the process extremely painless. More on that later.

OAuth came easy. All I had to do was follow along in the step by step example from Twitter’s wiki and then register my application with Twitter’s OAuth Client page. Perhaps the hardest part was debugging and testing, as the current Twitter system doesn’t appear to have a test sandbox.

So GameTweet was born. Just login to Twitter via OAuth and then type the IP:Port combination of the server you’re playing on, then the name of the game, and hit “Tweet!”. GameTweet then uses OAuth to update your status with all that information as well as a tinyurl to the GameTracker server status page using the tinify_urls plugin.

Capistrano, the Ruby based task automator, is perhaps the single most amazing piece of scripting I’ve seen in awhile. Coupled with the deployment recipes from Deprec, I was able to manage everything from code checkout, releases, deployment and even the Apache configuration all from one “cap deploy”. I managed to get an installation of SMF2 (a php based forum) deploying with Capistrano as well. Really, it is a joy to work with. After making a quick change to GameTweet I just had to run an “svn commit” and “cap deploy” and everything is up on the server with the latest code, database schema, and Passenger restarted the application.

That said, GameTweet has absolutely no test harness. I’m still learning the ropes with Ruby and Rails, but I do plan on eventually implementing a full test bed. OAuth is perhaps not the best thing to start with, but GameTweet was a tool I wanted to use for myself so I built it. Fast.

If you have an idea for GameTweet, want to talk shop, criticize my horrible Ruby on Rails code, or just talk pop me an email using the contact form or send me a tweet.

New Headset, Space Cadets and More

Well, last night I did something rather crazy which involved jumping up from a game of Counter-Strike and running to the living room. Unfortunately, I took the headset cord with me. I literally ripped the cord in half at the Y connector. I attempted a really horrible splicing job, but couldn’t get it to work. So, off I went to purchase a new headset. There were 3 models on the Best Buy website that seemed like they’d work: GameCom 377, GameCom 777 and the Logitech ClearChat Pro USB. Needless to say, I cheaped out and got the 377.

GameCom 377 Headset

GameCom 377 Headset

Initial impressions were definitely mixed. The sound was good, the cord was reinforced, and the controls were huge. Of course, everything about this thing was huge. For $40, you really got your money’s worth in plastic. The mic tucks away very nicely, but in comparison to the ear cans you’d probably miss it entirely. I honestly looked like a space cadet with those things on. They were pretty heavy, and they made a clear statement: “I have no idea why I’m wearing these, but aren’t they wicked cool? No? Aww, seriously?”

So, my wife came home and I displayed my inner uber nerd and then realized just how crazy these things were. So, a quick check on the return policy, and back to the big blue and yellow box they went. Shay, a good friend of mine and one heck of a shot in Counter-Strike, recommended the ClearChat Pro USB from the start. I gawked at using USB for audio, but this time around I decided I better heed someone’s advice since I apparently have horrible judgment.

Logitech ClearChat Pro USB

Logitech ClearChat Pro USB

Snapped up a pair for $10 more than the 377s and headed home. Opened the horribly designed blister pack and threw them on my head. These things are light. To be honest, it hardly feels like you’re wearing anything at all. The cable is just long enough to comfortably reach my tower, and the thing was plug and play. Vista 64bit just installed them and set my defaults for me. One game of Command & Conquer 3 later and I’m happy with them. Logged into Ventrilo and someone even commented that I sounded much better, easier to hear. Weird. It’s just a headset, right? The build quality is just okay, but if you’re relatively careful (unlike me) they should last awhile. The on ear controls aren’t as strange as they sound. You get used to it.

Anyways, I hope that helps a few people make some decisions on headsets. Just remember that return policy.

i7 Build is Done

I finally got around to building a new desktop PC. I’ve been working from my MacBook Pro for the last year or two, and its perfect for getting things done and its very speedy. Unfortunately, it simply cannot handle any of my hard-core games. So, in a fit of insanity, I built a new rig.

Components I had to buy to bring the old box up to speed:

  • i7 920 2.66ghz Quad Core
  • GTX 260 896mb Video Card
  • 6gb DDR3 1600
  • X58 Motherboard
  • 550w PSU
  • Vista x64 Home Premium

So far, everything is working without a hitch. I am noticing some interesting things though. For one, I now understand the frustration that everyone has with Windows Vista. UAC is beyond annoying, and sometimes things are a pain to find due to the new start menu. However, the machine is incredibly snappy. Everything runs incredibly fast, and crash recovery is much better. I can alt+tab from a game to desktop and back without a complete reboot, and games run like melted butter. That said, getting my older games to run under 64bit Vista was… fun. Battlefield 2142 apparently requires the patches to be installed in a certain order, and Punkbuster (the anti-cheat scanner) has to be manually updated. All of my Steam games run perfectly though, and the recommended settings are right on par with what I expected. Overall, I was really impressed with how they handled that. The game knew I had a decent machine, and automatically ramped up the settings. I love it.

I’m still running on some old 17″ LCDs, but a friend of mine has volunteered to swap me his dual 19″ for them. I’ll definitely owe him, but it’ll be nice to have matching monitors again. I should be all set, except for my chair, which is the next upgrade on my plate.

Now, the i7 definitely gets my seal of approval for hardware as does the GTX 260, but if you are trying to build a machine on the cheap go for the raw clock speed. The i7 does a lot of things (at the same time) well, but Battlefield is still not as buttery as it should be. I got the EVGA brand motherboard and graphics, which at the time was due to reviews and cost but in the aftermath I think it was a great choice. Why? Because it came with free stuff. Not only did I get the Newegg bonus Call of Duty: World at War, but I also got 3d Mark Advantage, the ELEET overclocking tool and a bunch of discounts. EVGA also offered to let me return my new graphics card and upgrade it to a higher end model within 90 days. That is just amazing, to me. Also, the extra year warranty I get from registering my motherboard is a wonderful bonus.

One day I’ll get around to installing Visual Studio, for now, Counter-Strike and BF2142 will do nicely for burn-in testing.

ASP.NET Pandora, iTunes Mashup

What is it?

Last week I had some down time and manage to crank out a relatively basic mashup of the iTunes Libary XML file and Pandora’s favourites feed. Essentially my code reads in the iTunes XML file and converts it into a readable form using XSLT then grabs the Pandora feed and compares the two using XPath.

The application is written in VB.NET on the ASP.NET platform. Yes, I know, VB is the poor ugly stepchild language but we use it at work and it was far easier to pick up and go. C# is on the docket for the next project, I promise. That said, I’m hoping to get some Ruby and Python up here too. I just need to get a ticket in with my Linux hosting provider.

Why did you write it?

I wanted to write this application for awhile but I never had the time or the motivation. Thankfully boredom breeds innovation for me. I had started the code months ago and abandoned it after getting stuck on the WebRequest to Pandora. I managed to dig up the code last week and had a few eureka moments which lead to release worthy code.

The reason behind the construction of this application is that I use Pandora every single day. I practically need their radio service to work. One thing that I do when I’m listening is bookmark the songs I like, and mod them up with the thumbs up button. It’s intuitive and quick to do which is great. However, when you’re ready to plop down a bunch of money on new music how do you know which songs to buy? I always forget to update my favourites list to remove the songs I’ve bought, and I’m too lazy to search my iTunes every time I want to buy a song. Sure, iTunes sometimes prevents you from buying the same song twice, but having been bitten by that bug before I’d rather have a third part verify that for me.

Improvements, Ideas, Concerns

The application is very rudimentary and will be sitting on a very restricted shared hosting environment. The code is definitely not rocket science, but it works for the most basic use case. That said, it doesn’t handle advanced searches or merge results for remixes and the like. It isn’t using a special algorithm for matching. It just does a direct XPath contains on the artist and song title. If it doesn’t match, the application will falsely mark it as if it doesn’t exist in your library. Likewise, single quotes are currently not handled correctly because I was lazy and XPath parameterization looked like a pain. This is just a proof of concept.

iTunes XML files can get pretty big. I think my library file was almost 6mb, which is rather large for a web upload. I might look into letting users upload a zip file and decompress it on the fly. Not sure how you’d go about that though. My guess is this application will thrash the server with IO under load.

One of my coworkers/friends suggested implementing affiliate IDs for the various music stores and injecting those into the application in order to generate revenue. If I ever wanted to turn this into a real product that might be a way to monetize, but rest assured that isn’t implemented at the moment. If anyone wants to see this as an actual product, feel free to drop me a line.

Where is it?

It will be hosted on my new domain at once the kinks are worked out. GoDaddy’s Windows hosting is far from perfect, but it gets the job done. Unfortunately, it appears they are trying to proxy my WebRequest and XSLT discovery outgoing sockets which is throwing an error. I have a ticket in to find out what I can do to fix that.

If you are interested in seeing the code I’ll gladly post it. Right now it isn’t up to much and still needs some cleaning up so I’ll leave it off for now.

Where have I been?

An excellent question. Where have I been?

In the past 12 months I have gotten married, switched jobs, adopted a kitten and moved back to the big city. You could say I’ve been in quite a few places doing any number of things. To explain though, I left WeatherFlow to return to Orlando to be closer to friends and family. Working there was perhaps the best decision I had made as I was able to learn quite a few technologies in a short amount of time, meet some very bright and driven people, as well as work on some amazing projects. If it wasn’t for WeatherFlow I wouldn’t be where I am today.

Where is that, you ask?

Well, I’m currently working for one of the largest defense contractors in the world. I work for the division which creates internal HR Applications for the company. Definitely a change from my usual 6-12 developers in a room and rapid application development. I picked up some legacy ColdFusion code and helped the team hit a couple releases before I was reassigned. From there I joined a small VB.NET/ASP.NET development team working on some internal applications which were eventually shelved, or made it into Phase II.

During the colder months I took on a stretch assignment to help another team which had been working with a 3rd party software vendor. Essentially, I have been testing and deploying the application for our internal team and managing the correspondence with the vendor. I’ve been learning our software engineering process, IIS configuration, account provisioning, writing SOI’s, hosting meetings and trying my hand at application deployment and environment configuration. Really, it has been a great learning experience thus far and I am looking forward to this new fiscal year.

Where do I go from here?

I am hoping to post more code on this blog, as well as start a few new projects on the side. I have a small Pandora/iTunes mashup written in VB.NET/ASP.NET 3.5 which needs a home. Hopefully I can find some hosting shortly and get that one up and running.

This year my goals are lofty:

  • Learn ASP.NET MVC with C# & jQuery
  • Learn Python & Django
  • Learn Ruby on Rails
  • Get Certified, whether its an MCPD or MCTS just do it.
  • Write something useful.
  • Become a better technologist and developer.

As always, I want to keep current and stay on top of the industry changes, and filter out the hype from the reality. Agile this, rails that are great things to investigate but what is the business case? What is the need? Hopefully this year I can find the time to publish some articles recounting those very things from my own point of view.

I hope that brings everyone up to date. I am still here, and hopefully I’ll be posting more in the weeks to come.

Mike Potter, Adobe - Thanks Guys!

So, I was checking my mail today and a mysterious package arrived from Amazon. Now, it could have been anything but to my complete shock and awe, it was from Mike Potter at Adobe. Here are some blurry photos from my phone:

WrappedCardBook

I had added the cookbook to my Amazon wish list shortly after Flex 3 was released, as I wanted to dive in and learn everything I could about the newest version of Flex. I really appreciate the gift, and to all of the Adobe team, thank you. You guys have delivered a great product, and you really know how to reach out and touch the community.

BrightKite

If anyone wants a brightkite invite, just let me know. I have 3 left, so the first 3 to comment will get the invites.

Flex Web Cam Effects Demo

Just updated the blog to WordPress 2.3.3 and figured it was time for another post. Today on InsideRIA.com they posted a rather interesting post about Flex graphical filters. Now, I’ve wanted to do this sort of thing for a very long time, but only today had the down time to give it a try. Basically, the application I’ve attached shows your regular web cam feed on the left, as well as a filtered feed on the right. I’ve only scratched the surface with what you can do with filters, combining filters, and the like but the demo serves a very useful purpose.

When my boss saw my little demo running his first comment was, “Wow, that’s fast.” and he was right. Flash was rendering the filtered stream in real-time; side-by-side with the regular output. Granted, blurring and practically inverting the colors isn’t rocket science, but the applications are limitless. Personally, I’d love to see a background subtraction library for Flex with other real-time video processing effects. My guess is that someone over at Adobe already has something to this end for working with YouTube Remixer and similarly powered applications.

Code and source after the break…

Continue reading ‘Flex Web Cam Effects Demo’

Updated: MyBlogLog Plugin v0.5.1

The MyBlogLog WordPress plugin is receiving a very belated face lift and a few bug fixes (thanks to those who reported them). Now, as a disclaimer, this code is relatively untested and was dug out of a very old archive from my days at cloudspace (the company who initially partnered to create MyBlogLog), so use it at your own risk. If you find any bugs, just drop me an email using the contact form and I will try to help in any way I can. This release has been activated on at least 2 WordPress 2.3.3 installs, so yes, it works with 2.3.3!

Check the project page to download the latest plugin file.

Oh, and still no readme.txt. ;)