Programming
I’m a programmer by day, and a lot of what I have to say will have something to do with that
Spoofing your browser’s user agent
2If you are a web developer (or anyone doing any programming which involves web browsers, which is just about everyone nowadays) you really are doing yourself a disservice if you don’t include Firefox in your toolbox for diagnosing issues and testing sites. The community provided Addons for Firefox are just invaluable in day to day tasks. A great example is the ability to spoof your browser’s user agent, pretending to be any browser you want, all from one browser.
My quest to do this started as a curiosity when I found a blog post titled “Search Engine Marketeers are the new script kiddies” discussing a WordPress blog which was hacked in such a way that it invisibly provided more traffic to the hacker’s site whenever a search engine bot crawled the site. The hack was pretty impressive, actually but more impressive was the ability for the blogger to diagnose what had happened and track down the culprit.
Having a few WordPress blogs of my own, I decided to look into checking mine for the same issues. It took me an hour or so of toying and poking around to get everything I needed, so I figured I would take a shot at documenting the steps that went into my adventure in the hopes that someone else would be able to get this done more quickly if they ever needed it. Plus… it will provide a reference for me when I inevitably do this on more computers in the future.
First, you’re going to need to get the User Agent Switcher Addon for Firefox (written by Chris Pederick). Installation should be fairly straight forward, so just click the button while in Firefox and let it do its thing.
Now for the part which took some searching…
The default installation of the Addon doesn’t provide a lot in the way of user agents to switch to. A couple of examples are all that are there, so in order to be really useful you’ll need to add agents of your own or find them somewhere. I found a very complete set of agents conveniently compiled into an XML file which can be imported into the Addon (Options > Options > User Agents > Import) over on Tech Patterns.
Once you have installed the Addon and loaded a complete set of user agents, you can test them out with the QuirksMode Browser Detect page.
There are a lot of uses for this ability, from security to verifying code which reacts to a specific browser. Whatever you use it for, hopefully this short guide made it easier to get your results.
Ajax Rain: A collection of JS / DHTML / AJAX code
1I remember a time… waaaaaay back in, oh… say… 1997 when the internet was really just starting to get “cool.” We would drink the latest caffeine laden beverage, take the latest “keep you wide-eyed” herbal supplement and write code until we were all convinced our hair was moving all over our skulls of its own volition. Back then, we would eagerly watch for the latest release notes for Netscape Navigator and relish any additions they made to JavaScript (bonus points for anyone who can remind me what the name of the scripting language was originally). As soon as a new change was in place we would attack it and put it somewhere… anywhere… on our sites. The code was raw, usually poorly formatted and documented and almost always protected by the author like it was going to be the next billion dollar idea.
That was then. In the ten years since that time we, as web developers, have evolved. Not quite far enough to exist only on a temporal plane but far enough to consider when writing code that other people may find it useful. No longer is the “cool” stuff of a proprietary variety. Now, developers more commonly take a little extra time to make their code understandable and customizable… then they do what was unthinkable ten years ago and (gasp) distribute it for free!
In steps Ajax Rain. A new resource style site that provides the coolest in JavaScript, DHTML and AJAX code for discerning veteran and budding rookie web developers alike. All of these snippets are downloadable for free and anyone can add their latest creation to the database.
So saddle up and ride some else’s code horse for a change. Quit reinventing the wheel (never mind that Good Year and Michelin continue to make millions doing exactly that) and get with the times. Go download and implement someone else’s code and take full credit for it yourself when praise is dished out at your next company picnic! After all… all the kids are doing it and they’re making you look lame in the process.
SQL Management Studio… How NOT to save in Unicode format
16A project I work on requires that we developers edit stored procedures and store the resulting script in a text file that we put in our source control tool. In our case, we use Microsoft SQL Server Management Studio to do the aforementioned editing and we use CA’s Harvest Change Manager as the corporate mandated code repository and source control tool.
Now if you were using another tool, Notepad or Query Analalyzer, for instance, you probably wouldn’t have the problem I’m going to outline. As a matter of fact, the problem I’m going to outline is probably pretty rare. But it exists and I found a solution, so I’m going to write about it.
As it turns out, whenever you “Save As” in Microsoft SQL Server Management Studio the default encoding for the file is Unicode – Codepage 1200. Yes, this is a new approach to saving your beloved stored procedures and no, it wasn’t done that way in the past. Further, I can’t find any notification that the “standard default” was going to be changing.
Anyway, Harvest doesn’t like Unicode files. So when you go to add the file to your Harvest project it won’t let you. Oh, the humanity! ANSI for everyone!
Now I may be in the minority here, but I originally failed to notice that on the “Save File As” dialog there is a small arrow on the right side of the [Save] button. Once I noticed it, I clicked it… Then I clicked “Save with encoding…” Now I’m happy again! Kind of…
The good thing is that this will let you save your file in whatever encoding you want. The caveat is that it will let you save your file in whatever encoding you want.
So how is the default set? I’ll leave that for another article… Mostly because I don’t know yet.
Update (04.11.2008): Thanks to Chris May for the following step by step instructions on how to overcome this issue (edited for formatting, the original version is comment #8):
I have found some information about this.
Though it is possible at the time a script is saved to change the encoding to ascii it is tedious. Here is the process.
- Choose File\Save
- Choose the name and folder to save the file then look really closely at the right edge of the “Save” button for a tiny arrow
- Click that tiny Arrow and choose “Save with Encoding”
- From the Drop list select the encoding you want (the default encoding is “Unicode – Codepage 1200″, which means “UTF-16″). I have been using “US-ASCII – Codepage 20127″
- Hit OK and Save. Your files should now work just fine with Perforce, CVS, etc.
Additionally, Chris has voiced his feedback to the SQL team, I encourage everyone to go have a look and hopefully we can get a solution sooner rather than later… although the outlook is bleak.