Friday, May 23, 2008

Learning JavaScript (finally)

I'll be honest. Until recently, I haven't really used much JavaScript in the Web Applications that I've built. I've usually preferred to take the post back hit and perform the necessary functions server-side, instead of trying to craft the right JavaScript routines that work across all browsers. In my new job however, we use a fairly large amount of JavaScript to deliver rich functionality directly on the page client-side. Time to get me some learn'n on JavaScript.

Because I had stayed away from JavaScript for so long, I never really got a good feel for it. I could read an existing script and determine what it was doing with little effort, but I would be hard pressed to write my own script that did anything beyond the basics. One of the reasons for this was that any resource I found on JavaScript never spelled out how the language is composited within a Web Browser.

Since JavaScript is a dynamic language, it can be implemented wherever you like; not just within a Web Browser. However, when JavaScript is implemented in a Web Browser, additional methods and properties are merged in from 2 other sources: The Document Object Model (DOM) and HTML.

The DOM is a hierarchical structure of all of the elements making up a document. Every element has parent (except root), 0 or more children, and 0 or more siblings (elements at the same level). Any JavaScript variable that references an element within the web page inherits the methods and properties supplied by the DOM based on the type of element it is, in addition to the standard methods and properties defined for JavaScript objects.

You will also inherit properties based on the HTML type the element represents. For instance, if the JavaScript variable is currently pointing to an element, then the variable will have properties that match what is available for an image, such as Alt, Src, Height, Width, etc.

Thus, any given variable in JavaScript can have methods and properties composed from 3 possible sources: core JavaScript, the DOM, and HTML. This may seem trivial to most people who have been writing JavaScript for several years, but to someone who has avoided the language for a while, this can be a source of confusion. Especially since most books seem to gloss over this composition behavior. Once you are aware of this, writing JavaScript becomes a lot easier.

In order to grasp the full capability of JavaScript within the context of a Web Browser, I would suggest buying at least 2 books: One on JavaScript (the language), and another on the Document Object Model (DOM). If you are lucky, you can find a book that does a good job incorporating all of these aspects in one place.

Thursday, April 03, 2008

SQL Server Management Studio Tip

Recently, Sara Ford outlined a tip on her blog about a registry hack that enables vertical column guides within the Visual Studio Editors. This is one feature that my favorite text editor (Notepad++) has had for a long time and something that I have missed when working within Visual Studio.

After using this for a few hours in both Visual Studio 2005 and 2008 and then using SQL Server Management Studio (SSMS), I wondered if it would be possible to enable this option for SSMS's editor(s)?

After digging through the registry, I found a registry path the looked an awful lot like the Visual Studio path. I closed down SSMS, added the proper registry key, and then opened SSMS, and...

Presto! I now have the vertical column guides! Here are the instructions...

WARNING: This tip modifies your registry. Please ensure that you have a backup before proceeding in the event that Murphy's law kicks in!
  1. Open the Registry Editor
  2. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\90\Tools\Shell\TextEditor
  3. Add a new String value named "Guides"
  4. Set the value to "RGB(r,g,b),c1,...,c13" using the format described in Sara's blog.
Enjoy!

Tuesday, October 23, 2007

Cropper

I've recently had to write some documentation for my new job. As with any documentation, screenshots are essential. In the past I have taken the whole Print Screen, Paste into an image program (like GIMP or Paint), and save to disk approach.

A while back I had stumbled upon a program named Cropper, but hadn't taken the time to give it a test run. Since I didn't already have any screen capturing software on my new system, I figured now would be a good time!

After installing and starting cropper, all you are presented with is a small icon in your system tray. At this point, you could simply follow your normal Print Screen (or Alt-Print Screen) routine and Cropper will automatically start saving BMP files into it's default Save folder. You could also double-click the system tray icon (or press F8) and be presented with a transparent window that can be moved and resized to selectively capture certain portions of the screen.

You can also have Cropper automatically create Thumbnails of each screenshot you take, if so desired. In addition to outputting BMP files, you can also output to PNG or variable-quality JPG files as well as send directly to the Clipboard or the default printer.

With it's small install size, easy to use and unobtrusiveness features, and cost (free!) , I would highly recommend Cropper to anyone who needs to take screenshots.

Thursday, October 18, 2007

Microsoft Comfort Curve Keyboard 2000

I recently switched jobs and have come to realize how much I liked having the low-profile style keys that laptop keyboards. Most developers I know also share a similar view when they have to use a desktop computer for long periods of time.

For my new job I have a desktop, which is great since it's an Intel Core2 Duo with 3GB of RAM and 250GB HD of hard drive space along with a rather large LCD monitor (Dell 2007FP). The only draw back was the use of a regular (and somewhat cheap feeling) keyboard that came with it. If you've purchased a Dell system recently, you probably know the keyboard I'm talking about... the one that barely has any extra space between the keys and the edge of the keyboard itself.

After having used a laptop 90% of the time (my desktop at home uses a Sun Type-6 USB keyboard due to it's low profile keys) for the past 7 years, I quickly began to dislike it. So I went to a local office supply store looking for an inexpensive keyboard that had a wired connection with low-profile keys. Call me old-school, but I prefer wired keyboards since there is less of a chance that something will go wrong with them (driver issues, dead batteries, etc.)

There were several nice keyboards from Logitech and and others that had the low-profile keys, but most of them cost between $50 and $300 and were wireless. Then I found the Microsoft Comfort Curve 2000.

It's a low-profile, low-cost (~$20) keyboard that has minimal 'extra' buttons, requires no drivers in order to use all of the buttons, and was wired. I had used this keyboard in the past briefly when setting up a server when our KVM died and liked it a lot. The 'curve' in the title refers to the fact that the keyboard curves about 6-degrees from the center of the keyboard, resulting in a more natural (ergonomic) design for your wrists. I have tried the broken keyboard designs in the past, but I found them really frustrating to use since I am not a touch-typer (but getting there).

After having used this keyboard extensively for the past week, I would highly recommend it to anyone, especially since it is so inexpensive.

Tuesday, October 16, 2007

Amazon's MP3 service

I recently made my first jump into digital media purchases. Up until this point I refused to purchase music from any of the online services that use Digital Rights Management technologies.

The iTunes store has a clean interface and an impressive catalog, but the DRM-laden AAC files do not play on my current digital music player of choice, a 2nd generation Dell DJ 20. All of the services that were compatible with my device used DRM-laden Windows Media Audio (WMA) files. I've heard countless stories from people who have purchased music only to have a computer/software glitch that renders their purchased music unplayable, so I never wanted to take the risk.

A few weeks ago, I heard that Amazon had recently opened up their MP3 store as a public beta, offering DRM-free 256Kbps MP3 files that are compatible with pretty much any digital music player available (past or present). After looking through the initial catalog offerings, I decided to take the plunge and make my first digital music purchase.

After installing the Amazon MP3 Downloader application (only required for albums, but useful for purchasing many singles at once), I decided to download Pablo Honey by Radiohead. I have owned this album since it was first released in 1993, but sadly only in Cassette format (without a cassette player for the past 5 years). After following the quick checkout procedure, the Amazon MP3 Downloader opened and my music files began downloading. After each file finished downloading, the application would add it to my Windows Media Player (or iTunes) library automatically.

When everything was all said and done, I opened up WMP and found (surprisingly) that everything had worked and transferred the files onto my DJ without hassle. I even made a physical copy of the CD to put into my home stereo just as easily (and using whatever application I wanted to do it with!).

I applaud Amazon for offering DRM-free MP3 tracks and the seamless downloading experience has left me a happy consumer, willing to purchase digital versions of albums that I only own in cassette format as well as new albums. I only wish that they would also provide cover & disc art to go along with album purchases so you could make your own physical CD's look nicer.

Thursday, September 20, 2007

'Jena Six'

I'll touch on hot-button issue that is currently ragging in the media, the 'Jena six'.

From what I have heard so far, a group of white students placed nooses on/around a tree. A few days later a group of 6 black students beat one of the white students pretty good. The white students were suspended from school for 3 days while the black students were expelled, arrested, and charged with a variety of crimes. There is currently a huge demonstration happening in Jena with people calling the punishments racist and discriminatory.

Let me break this down as someone who respects the law and believes all people are equal, no matter their education, culture, religion, etc. The terms "white students" and "black students" are used solely to identify the groups. If you wish, you could replace these terms with "Group A' and "Group B' if you like, the logic is still the same.

What the white students did was obviously incredibly wrong. I have no respect for a person who thinks that the answer to any problem involves the killing of another without justified reasons (such as kill or be killed, as is the case in a 'justified' war like WWII), which is clearly what the noose was meant to represent. I think that the punishment handed out by the school was a good starting point, but I don't think they took it far enough. An instance such as this should have involved a much longer suspension (like the remainder of the school year) instead of just 3 days.

However, the act of placing the nooses on/around the tree can be considered a First Amendment right, since it did not (to my knowledge) explicitly identify any individuals in the statement and was just a public display of an opinion, such as the "Support our troops. Impeach George Bush" bumper stickers you see on cars. As long as there isn't a Local/State/Federal law prohibiting the displaying or hanging of nooses in a public setting, then there is little the white students can be charged with, except maybe disturbing the peace or such. There is a little gray area here, since it could be argued that the statement represented a risk to the safety of a portion of the public (much like yelling "Fire!" in a crowded movie theater), but that is an exercise for those with law degrees.

On the other side, the group of black students physically beat one of the white students. This act cannot be covered by the First Amendment since it involved the physical harm of another individual and is not longer a statement or opinion. There are very specific laws regarding this and they are being charged in accordance with those laws. The specific charges are decided based on motive and intent. If the black students initiated the beating with the intent of killing the white student, then they can be charged with attempted murder. Otherwise they could be looking at charges like Assualt & Battery, or other similar charges. Again, since I am not a lawyer, I'll leave the specific law questions up to them.

Bottom line...

Were the actions of the white students unquestionably immoral and wrong? Absolutely.
Should they have been punished by the school more? Definitely.
Did they commit an actual crime? Maybe. It depends on specific Local/State/Federal laws.

Were the actions of the blacks students wrong? Absolutely.
Should they have been punished less by the school? Depends on school policy.
Did they commit an actual crime warranting arrest. Yes.

You can't go around beating people up for expressing an opinion, no matter how strongly you feel against it. It is an opinion and not a direct physical threat.

Yelling "All Muslims must die!" is a matter of opinion, but yelling "All Muslims must die!" while firing a fully automatic machine gun into a crowd of Muslims is not. There is a distinct difference between the two. If you don't see that difference, then we have bigger problems as a species.

Wednesday, September 05, 2007

Green cars you can't buy

First - It's been over 2 months since my last post. I know I said that I try to post more often, but life has a way of altering your plans whenever it wants. My son was born at the beginning of July and things are just now starting to settle down, if only slightly. Hopefully I'll have some more time to update this blog in the future.

And now, the latest from my synapses...

According to this article on MSN autos by a new columnist, it is against the law to sell you an extremely low-emissions vehicle in the 42 states that don't follow California's lead on clean air and curbing auto emissions (luckily, New York has). Ironically, the law that makes this illegal is contained in the Clean Air Act! Only in American politics could something like this happen and is further proof that most of our legislators are a bunch of corporate, pan-handling pansies.

In the past few years, the has been a huge up-swing of people acting more responsible in regards to the environment, a surge in websites promoting green technologies (such as EcoGeek.org), and even some corporations are taking environmental concerns very seriously. It's time that the politicians recognized this trend and got on board, not just with words, but with solid actions as well.