Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

No Multiline Comments With Ruby on Rails

Feb 28

I’ve searched all over for this one and if you have any insight I’d love to hear it. It turns out there’s no support for multiline comments with Ruby on Rails. I guess I should say that this isn’t even supported in plain Ruby.

A general method for debugging that I use is to comment out chunks of code. This allows me to focus on a piece of code that might be causing a problem. While the exclusion of multiline comments isn’t a major issue, I’ll definitely need to look into alternate debugging techniques. While I realize a single comment (#) can be placed on every line, in some cases this may not be practical. For more information on Ruby feel free to check out this great reference:


Programming Ruby: The Pragmatic Programmers’ Guide, Second Edition

Read More

Hot Pink Hummer H2

Feb 28

You see some crazy things in the city of Dallas. I’m sure we’ve all made a crack at the soccer mom driving the Hummer H2. Doing a quick Hummer search I stumbled across this funny site. Be sure to check out the poster. I’m constantly amazed at what lengths people will go to support their cause. The web is an amazing place that lets people easily express their opinion for the world to hear. Anyway, that’s a tangent and check out the hot pink Hummer H2 cruising in front of me on the way home from work. These photos were taken with my new 8125 and the quality isn’t the greatest. You should at least be able to tell it’s pink.

Read More

Freeing Program Memory in Windows Mobile

Feb 27

Today I was busy trying to multitask on my 8125. I kept receiving out of memory errors and was pretty frustrated thinking that I already pushed my device to the limits. Luckily I stumbled across the Running Programs list in the Memory screen. You can access this by going to Start > Settings > System > Memory > Running Programs.

After opening the list I realized there was no less than 10 programs running, which were ultimately causing my device to run slowly. The weird thing about Windows mobile is there’s generally no explicit way to close a program. Actually, I take that back. There used to be a way with Pocket PC to kill a program by pulling up the on-screen keyboard and selecting CTRL-Q. I’ll have to give it a try and see what happens…..just tried it and it does work!

Now if I can just find a way to do it from the hard keyboard. The 8125 has a cool concept of an OK button which I would assimilate to minimizing a desktop application. It sends the app to the background and displays whatever was underneath. At any rate, be sure to keep your memory clean and the device will perform much better.

Read More

Detecting Pocket IE Using JavaScript

Feb 26

I recently read that Pocket IE for Windows Mobile supports JavaScript 1.5. This came as a complete suprise. For some reason I thought it would be far behind its desktop counterpart. At some point I’m going to test the DOM support as well.

I decided to do a bit of testing to see what it would take to do some simple browser detection. I’m not talking about detecting different desktop browser versions, but detecting Pocket IE. The key is to tie into JavaScript’s navigator object to grab the necessary information. In this case it’s called userAgent. The user agent is sent by the browser with each request to a web page. You can see the actual user agent entry from my log file below:

68.88.69.133 – - [26/Feb/2006:19:18:38 -0600] “GET / HTTP/1.1″ 302 3 “-” “HTC-8100/1.2 Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; PPC; 240×320)”

This entry was created by my new Cingular 8125. So I wanted to take this a little further and see what JavaScript’s navigator object would return when accessing it from my 8125, which runs Pocket IE. I just wrote a simple function that enumerates the navigator object and prints it on a page. Well it wasn’t really a function since I couldn’t get Pocket IE to behave the way I wanted. I ended up writing the script directly in the page:

Feel free to access the page here:

http://www.db75.com/dev/mobile/user_agent.html

In Safari this yields the following output:

appCodeName: Mozilla
appName: Netscape
appVersion: 5.0 (Macintosh; en-US)
language: en-US
mimeTypes: [object MimeTypeArray]
platform: MacPPC
oscpu: PPC Mac OS X Mach-O
vendor: Firefox
vendorSub: 1.0.1
product: Gecko
productSub: 20050225
plugins: [object PluginArray]
securityPolicy:
userAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1
cookieEnabled: true
javaEnabled: function javaEnabled() { [native code] }
taintEnabled: function taintEnabled() { [native code] }
preference: function preference() { [native code] }

While in Pocket IE only a subset of this is listed:

appCodeName: HTC-8100
appName: Microsoft Pocket Internet Explorer
appVersion: 1.2 Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; PPC; 240×320)
userAgent: HTC-8100/1.2 Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; PPC; 240×320)
platform: WinCE

Notice the difference in the userAgent properties, which is what we normally use to do browser detection. This can be something as simple as navigator.userAgent.toLowerCase().indexOf(“windows ce”); to check for a Windows enabled mobile device. Obviously the detection can be made more robust, but the point is accessing the userAgent string and performing your logic on that.

The mobile browser has come a long way and it’s exciting to see such extensive support for JavaScript on these devices. It will enable developers to do exciting things and push the limits of mobile web applications. If you’re interested in one of the best references for JavaScript then I highly recommend the book below.


JavaScript: The Definitive Guide

Read More

CVS Checkout on OS X

Feb 25

I normally use Eclipse and its built-in CVS support to checkout different development projects. As with most tools you’re abstracted away from the underlying commands. I recently stumbled across a cool Ruby on Rails project called RealTime on Rails. I’ll post more on this project at a later date, but the general objective is to enable push capabilities to AJAX applications. This means the server can actually push data to different web clients instead of using a traditional polling method.

At any rate, the RTRails project can only be accessed through CVS. I wanted to check out the project on my Mac using the cvs command and found it very simple to work with. Of course, most things are simple once you learn how to do them. Here’s the command in action:

cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/rtrails checkout rtrails

The -d parameter specifies the root directory of the repository. While rtrails specifies which project we want to checkout. It’s amazing how simple things are if you just take the time to learn them.

Obviously the argument can be made that this is slower than using a GUI tool to manage CVS projects. A valid argument, but most of the time I’m much more efficient at the command line than with a tool. Plus it’s cool to know what’s going on under the hood.

Read More