August 7, 2010

Force all Sinatra traffic to https

I wanted to have all traffic on a site go through https. Since the site was on heroku. @env['rack.url_scheme'])=='https' wasn't a sufficient way of detecting if on https. You need to also check (@env['HTTP_X_FORWARDED_PROTO']. Below I wrote a simple before filter which you could place in the production configuration. After talking with the author of rack-ssl-enforcer I got that patched to work on heroku as well. So that is an even simpler option.

Anyways, I spent far to long googling sinatra https, sinatra ssl, sinatra over https, sinatra secure, and heroku https, and couldn't find good pages on this for awhile. So here is the info for anyone else wanted to host secure Sinatra pages on heroku.

July 10, 2010

Adding Custom JavaScript Handlers for PhoneGap Android

One of the advantages I mentioned about PhoneGap, was being able to write custom native code, and interface with it via JavaScript. Their Aren't great example of how to do this out there, so I figured a quick blog post was in order.

I search around for how to do this when getting started with PhoneGap, and the best example I could find was, Native messages for Android PhoneGap. Following this example, I was able to get my own Javascript interface working.

Basically you create a class (using java for android example):


I
create this private class in the main Java class which extends DroidGap (the class that boots up PhoneGap and creates the webview UI).

Then in your html you can call in javascript bridged Java functions like var myData = CUSTOM.getData(); which will return the java data (in this case a string) to the javascript. I have used the JS bride to begin new Android Activities, Close the WebView and move entirely to Native code. Background the WebUI to do something native for awhile, then return the WebView back to the front, Etc.

This can be done similarly for the iPhone and Objective-C to Javascript with PhoneGap. This lets you leverage extra native flexibility while still building the majority of your app as JS, CSS, and HTML.

July 6, 2010

Mobile Development and My Recommendation for PhoneGap

In the last month or so I have been exploring mobile development. I wrote basic native Android and iPhone apps. I also build cross platform apps using Rhodes, Titanium, and PhoneGap. I thought it would be good to share my thoughts and experiences on the mobile dev space.

If you want full control and are doing a lot of local heavy processing (CPU bound) native is the way to go. I program to the web data without access I don't do much interesting. When the whole app basically relies on live data I feel javascript, HTML, and CSS is the way to go. Not only am I already familiar with it, but basically the app can share code with the mobile site. Also, using JS, HTML, and CSS gives the most flexibility in terms of supporting multiple devices. Since I wasn't using anything specific to a single mobile device or really pushing the hardware, I quickly moved away from fully native apps. It wasn't worth the time and extra effort to write nearly the same app in Java, Objective C, and whatever else. Game developers, and those doing a bunch with video, photos, etc are probably most interested in native apps and probably won't be as interested in other options.

This lead me to explore Rhodes, Titanium, and PhoneGap as alternatives to purely native apps. All of which let you leverage HTML and CSS for building a UI.

Rhodes lets you write code in Ruby using a MVC framework. You leverage html (erb/haml) views using a Ruby back end to make remote requests, interact with a DB, and interact with native phone components. It is a cool framework, and obviously since it is Ruby, I enjoyed writing the code. However, it obscured the actual process of making an app for a device a bit much for my comfort. If something went wrong anywhere in the stack or if you wanted to break out of the Rhodes way to do something native on a platform it was difficult to do. It tries to manage the entire app development end to end hiding any per device customizations away from you. Since I wanted to be able to use some existing libraries for Android and iPhones, this limitation was a dealbreaker.

Titanium and PhoneGap use the same basic approach as each other providing a javascript library, which interfaces with native code for each device. You write an app in JS/HTML/CSS and make calls to the JS library to interact with native elements like the accelerometer, GPS, buttons, etc. I think it's a big win to be able to write most of the app in familiar web languages basically utilizing Ajax and local storage to give a nice mobile experience. Getting up and running on either Titanium or PhoneGap was painless. Again, in the end I wanted more control over some native components which caused me to choose PhoneGap over Titanium. While the concept is the same for both of these products, their approach is very different.

Titanium is a bit more all or nothing of an approach, you develop in Titanium's little world and it is best to not go out of
it. PhoneGap takes a extremely lightweight and minimalist approach to getting your project running on each device. It gives you basically the bare necessities and gets out of your way. PhoneGap doesn't try to configure the build environment and it doesn't manage simulators. To create a app with PhoneGap for any mobile platform you point to the same web directory (HTML, CSS, JS, and images), then generate a native app for the device. At that point you have the same native app project you would have if you were to start from scratch but you have a few nice libraries and code started for you. If you don't like the way PhoneGap does something, that is fine delete it, override it, extend it. You need to do something native PhoneGap doesn't support add your own JS handlers and interact with new or existing native code. I needed to allow for FaceBook connect login on Android, which PhoneGap doesn't support no problem. FaceBook maintains a Android SDK, which I imported into my PhoneGap project and added JS handlers which call to the FaceBook Android native code. There is a bug in Androids SSL cert verification for WebKit that was causing errors for HTTPS access, drop into java override the SSL Cert verification and fixed that. This would be difficult to do with Rhodes or Titanium because they don't allow you easily write and interact with your own native code. The project has to work only through the API provided to you to stay cross compatible. Which is great in some ways, but very limiting if you want to break out and just tweak a few little things.

I have been extremely happy working with PhoneGap, it rocks. It lets you build a native mobile app as a locally cached and privileged mobile website. You can leverage existing mobile site code for the native app. It will still be better than a pure website experience. It lets you piggyback on skill web developers already have. It is a great way to make use of HTML5 local DBs, local data, and HTML templates. It encourages you follow best practices for building a mobile site that works offline and requests only minimal JSON so it can fast over slow internet.

Before building an app with PhoneGap I recommend building a mobile site. Learn about best practices for the mobile web. If you are new to developing sites for mobile, I highly recommend following the recommendations from Yehuda Katz on building great mobile sites. He discusses some things specific to Rails 3, but mostly just good JS practices.

In many ways when building a PhoneGap app you are just building a mobile website. You have access to utilizing some native things that you can't with pure HTML/CSS. Local storage is a good example, it is supported by HTML5, but the earlier Android webkit didn't support it. Using PhoneGap you have local storage on old devices and it can use standard HTML5 local storage on newer devices.

Last but not least, PhoneGap has a great active community. Drop into #phonegap on freenode and people are always around to help out. The mailing list has a constant flow of questions and answers. While PhoneGap docs are a little out of date, there are people actively working on improving them. There are many example applications and open code on github to check out how to use PhoneGap. Also, the code is small and simple enough it is a great project to get involved in and give back. After working with it awhile, you will start to understand the internals and could help contribute patches, features, and plugins to the community.

July 3, 2010

The Ruby-fitbit API has been updated

More about it can be found on here, Ruby-fitbit api on github. Also, the original announcement can be found on my blog.

Basically there is now detailed access to any of the data types for any given day. This can be used to backup your fitbit or gather the data for your own charting purposes. Which I will likely start taking advantage of soon for my fitbit blog widget.

Example:

~/projects/ruby-fitbit(master) > ruby bin/ruby-fitbit MYEMAIL MYPASS steps 06/22/2010
Calories Burned 1012
Steps Taken 0
Milkes Walked .00
Activity Levels Durations:
Sedentary 16hrs 7min
Lightly 0min
Fairly # => {fitbit.fairly_active}
Very 0min
steps data for data Tue Jun 22 00:00:00 -0400 2010
+--------------------------------+-------+
| 0 | 1 |
+--------------------------------+-------+
| Tue Jun 22 21:50:00 -0400 2010 | 91.0 |
| Tue Jun 22 05:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:55:00 -0400 2010 | 69.0 |
| Tue Jun 22 14:20:00 -0400 2010 | 15.0 |
| Tue Jun 22 08:45:00 -0400 2010 | 1.0 |
| Tue Jun 22 03:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:40:00 -0400 2010 | 11.0 |
| Tue Jun 22 10:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:45:00 -0400 2010 | 543.0 |
| Tue Jun 22 14:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:35:00 -0400 2010 | 347.0 |
| Tue Jun 22 03:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:30:00 -0400 2010 | 25.0 |
| Tue Jun 22 10:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:35:00 -0400 2010 | 19.0 |
| Tue Jun 22 14:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:20:00 -0400 2010 | 23.0 |
| Tue Jun 22 15:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:25:00 -0400 2010 | 535.0 |
| Tue Jun 22 02:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:15:00 -0400 2010 | 595.0 |
| Tue Jun 22 08:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:05:00 -0400 2010 | 425.0 |
| Tue Jun 22 13:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:10:00 -0400 2010 | 22.0 |
| Tue Jun 22 11:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:55:00 -0400 2010 | 62.0 |
| Tue Jun 22 13:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:00:00 -0400 2010 | 35.0 |
| Tue Jun 22 11:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:00:00 -0400 2010 | 91.0 |
| Tue Jun 22 22:15:00 -0400 2010 | 445.0 |
| Tue Jun 22 16:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:35:00 -0400 2010 | 0.0 |
| Wed Jun 23 00:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:05:00 -0400 2010 | 80.0 |
| Tue Jun 22 16:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:00:00 -0400 2010 | 370.0 |
| Tue Jun 22 23:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:55:00 -0400 2010 | 69.0 |
| Tue Jun 22 16:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:50:00 -0400 2010 | 13.0 |
| Tue Jun 22 03:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:45:00 -0400 2010 | 17.0 |
| Tue Jun 22 05:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:50:00 -0400 2010 | 155.0 |
| Tue Jun 22 14:15:00 -0400 2010 | 40.0 |
| Tue Jun 22 08:40:00 -0400 2010 | 203.0 |
| Tue Jun 22 03:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:35:00 -0400 2010 | 53.0 |
| Tue Jun 22 10:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:40:00 -0400 2010 | 438.0 |
| Tue Jun 22 14:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:30:00 -0400 2010 | 12.0 |
| Tue Jun 22 02:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:25:00 -0400 2010 | 32.0 |
| Tue Jun 22 15:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:30:00 -0400 2010 | 499.0 |
| Tue Jun 22 02:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:15:00 -0400 2010 | 67.0 |
| Tue Jun 22 15:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:20:00 -0400 2010 | 604.0 |
| Tue Jun 22 08:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 23:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:50:00 -0400 2010 | 10.0 |
| Tue Jun 22 06:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 21:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:10:00 -0400 2010 | 291.0 |
| Tue Jun 22 13:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 06:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 19:00:00 -0400 2010 | 161.0 |
| Tue Jun 22 13:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 17:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 04:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 15:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 02:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:55:00 -0400 2010 | 37.0 |
| Tue Jun 22 11:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:35:00 -0400 2010 | 26.0 |
| Tue Jun 22 15:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 13:05:00 -0400 2010 | 75.0 |
| Tue Jun 22 07:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:20:00 -0400 2010 | 22.0 |
| Tue Jun 22 11:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 00:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:10:00 -0400 2010 | 268.0 |
| Tue Jun 22 16:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 11:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:30:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:40:00 -0400 2010 | 0.0 |
| Tue Jun 22 09:05:00 -0400 2010 | 74.0 |
| Tue Jun 22 23:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 22:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 16:25:00 -0400 2010 | 0.0 |
| Tue Jun 22 10:50:00 -0400 2010 | 0.0 |
| Tue Jun 22 05:15:00 -0400 2010 | 0.0 |
| Tue Jun 22 20:05:00 -0400 2010 | 0.0 |
| Tue Jun 22 08:55:00 -0400 2010 | 0.0 |
| Tue Jun 22 03:20:00 -0400 2010 | 0.0 |
| Tue Jun 22 14:30:00 -0400 2010 | 16.0 |
| Tue Jun 22 23:45:00 -0400 2010 | 0.0 |
| Tue Jun 22 18:10:00 -0400 2010 | 0.0 |
| Tue Jun 22 12:35:00 -0400 2010 | 0.0 |
| Tue Jun 22 07:00:00 -0400 2010 | 0.0 |
| Tue Jun 22 01:25:00 -0400 2010 | 0.0 |
+--------------------------------+-------+
289 rows in set
done

June 26, 2010

Javascript document.addEventListener PhoneGap deviceready issues

I had some issues with the deviceready callback. I had seen some similar posts, and figured I could save someone some time. Basically when using document.addEventListener order matters a lot. It all comes down to exactly when this line is loaded and what is already defined.

document.addEventListener("deviceready", deviceSetup, true);

We have custom JS, and originally it was loaded second, so the
deviceready event was fired before, the listener was set.

        <script type="text/javascript" charset="utf-8" src="lscustom.js"></script> 
        <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 

After that I was still having an issue and it turns out the method you
define register as the callback needs to be defined before you add the
listener.
So having this in our lscustom.js works.

var deviceSetup = function(){ 
  console.log("Device Setup"); 
}; 

document.addEventListener("deviceready", deviceSetup, true);
While, the below fails.
document.addEventListener("deviceready", deviceSetup, true);
var deviceSetup = function(){
console.log("Device Setup");
};

Anyways since I ended up wasting a bit of time searching and debugging this issue, I figured I would share my debugging session.

June 21, 2010

Code Highlighting on MovableType

def code_highlighting
  puts "this is a highlight"
end

I found a syntaxhighlighter plugin, which makes it simple to use SyntaxHighlighter on Movable Type. After downloading and unzipping the plugin in your MT directory. Just add the

<$MTSyntaxHighlighterInclude$>
tag to your templates and then choose the SyntaxHighlighter format when making a post.

Web 2.0 craziness

View Dan Mayer's profile on LinkedIn


I Power Seekler
I Power Seekler

www.flickr.com
This is a Flickr badge showing public photos and videos from mayer_dan. Make your own badge here.

Creative Commons License
This weblog is licensed under a Creative Commons License.