March 2013
1 post
MongoDB: Shorten The ObjectId →
Mar 29th
February 2013
2 posts
Using MongoDB MapReduce to join 2 collections →
Feb 13th
Eclipse NullPointerException Breakpoints →
Feb 11th
July 2012
1 post
Android Phonegap call to OpenGL ES API with no...
When using Phonegap on Android I was getting this OpenGL error somewhat randomly. It seemed to be related to CSS animation. Turns out the problem was that hardware acceleration is turned off by default. Error I was getting call to OpenGL ES API with no current context (logged once per thread) Add this to your AndroidManifest.xml android:hardwareAccelerated="true"
Jul 13th
2 notes
February 2012
2 posts
Using authbind with forever
A few weeks ago I posted how to use authbind to runing node on port 80. This works great for simple node apps but if you need to spawn child processes that can listen on port 80 it wont work out of the box. To do this you need to use authbind --deep. Since forever doesn’t actually listen on port 80 but instead spawn a new process that listens on port 80 you need the --deep option. So to...
Feb 24th
3 notes
2 tags
AngularJS ng:repeate with jQueryUI Sortable
On a project I am working on I needed allow the user to reorder items in an ng:repeat. The obvious way to do this is with jQueryUI Sortable. It provides simple drag and drop sorting. The problem is getting it to play nicely with AngularJS. A quick google search came up with a stackover flow answer, but it doesn’t work with Angular v0.10.x. Here is what I ended up with or the...
Feb 17th
1 note
January 2012
2 posts
2 tags
Using authbind to run node.js on port 80 with...
Like everything else this requires a Dreamhost VPS. If you don’t have node.js installed yet checkout my slightly outdated guide on installing node.js on Dreamhost. It should still work just swap out the version of node.js that you need. You will also need to turn off or change the port of the web server of the VPS. It’s a general rule that you shouldn’t run node as root, but...
Jan 25th
11 notes
3 tags
CSS Styling
Styling the <input type="file" /> tag is nearly impossible, but there is a simple solution. Don’t style it just hide it and style the <label>. Note: You can’t display: none the <input type="file" /> because this will prevent the <label> from working. HTML <label id="fileLabel" for="file"> <input type="file" id="file" /> </label> ...
Jan 21st
16 notes
November 2011
2 posts
2 tags
Using mongoose and connect-mongodb with Node.js
When using mongoose with connect-mongodb you need to not initialize the session store before mongoose connects. Otherwise you will get the nasty connection already open error. Always put it inside of the mongoose.connect callback. mongoose.connect(config.db, {auto_reconnect: true, native_parser: true}, function(err) { var MongoStore = require("connect-mongodb"); app.use(express.session({ ...
Nov 17th
4 notes
1 tag
I finally made the move from TextMate to vim
and I wish I had done it a long time ago. I will link to the resources I used when I get around to it, but until then I started with vimtutor and googled my way from there. MacVim is a great tool but it pays to start with plain old command line vim. You will want to use iTerm instead of Apples Terminal. I put my .vim files on github if your interested.
Nov 8th
7 notes
August 2011
1 post
3 tags
Installing Cloud9 IDE on Dreamhost
Cloud9 is a new IDE written in Javascript for Javascript server and client development. It has a great visual debugger built right in and is really the best IDE for node.js development. The downside of cloud9 is that its not simple to get installed. I have had no luck getting it to run on OS X 10.7, but others have. I have however got it running on a Dreamhost VPS. Here is how… First you...
Aug 28th
14 notes
July 2011
1 post
2 tags
Debugging Node.js with Node Inspector
Debugging node.js is very different then debugging say PHP. When node.js crashes so does the server and it may not give you much if any information when it does. This is where Node Inspector can really help. Node Inspector is basically the javascript debugger from webkit (Chrome and Safari). It doesn’t come as part of node.js though. To install it run npm install -g node-inspector and you’re set....
Jul 31st
June 2011
3 posts
1 tag
Xcode 4 and .xcconfig files
Xcconfig files are text files that control your build settings. This allows you to greatly simplify more complicated builds. The framework I am working on now has 3 modes that change the way the framework presents itself to the user. With each of those mode I have 3 targets (dev, beta, release). This very quickly became a mess. With no simple way to switch between modes for testing. Xcconfig files...
Jun 11th
1 tag
UIBarButtonItem Default Font
I found myself with a need to match a UILabel’s font with the font of a UIBarButtonItem’s font. Unfortunately there is no font property for a UIBarButtonItem. Googling it I found this blog post with the default font for a UIBarButtonItem with the UIBarButtonItemStyleBordered style. I needed the font for UIBarButtonItemStylePlain though. I was able to guess and check my way to an answer. Both use...
Jun 2nd
1 tag
UIWebView Viewport Not Resizing With...
When a UIWebView is loaded the viewport for the content is set. When the UIWebView is resized something interesting happens. If the first resize makes it wider then the viewport is resized with the UIWebView. However, if the first resize makes it narrower then viewport is not resized and the content will extend past the edge of the UIWebView. The fix is as simple as adding a meta tag to the...
Jun 1st
May 2011
2 posts
1 tag
UIToolbar and UINavigationBar system default...
Although it now seems quite obvious, if you want to set the tintColor of a UIToolbar or UINavigationBar back to the default for that device set the tintColor to nil. toolbar.tintColor = nil; or self.navigationController.navigationBar.tintColor = nil;
May 28th
1 tag
UIWebView in a UIScrollView doesn’t work
It turns out that a UIWebView wont paint if the view is not visible or if it is inside of a UIScrollView that is currently scrolling. This means there is no way to preload the content off-screen so that it is visible while scrolling. The only work around that I have found is to actually preload the UIWebView on the screen with a very low alpha and then move it to the UIScrollView. Update ...
May 18th
March 2011
1 post
1 tag
Enabling background tasks on iOS 4.0+
Enabling background tasks is really just two UIApplication methods ( beginBackgroundTaskWithExpirationHandler: and endBackgroundTask:). Calling beginBackgroundTaskWithExpirationHandler: tells iOS that you are running a task that should continue to run when the app is transitioned to the background. Once the task is finished you call endBackgroundTask: so the iOS knows that the task is finished. ...
Mar 18th
February 2011
1 post
3 tags
Node.js on Dreamhost
**** Updated: 1/26/2012 There are a few guides to installing node.js on Dreamhost, but none that take you from start to finish deploying a node.js server. This guide will attempt to do just that. Everything should work on with a shared server, but I would highly recommend a VPS. In this guide we will: Install Node.js Install npm Install forever Start a node app as a daemon Add a cron job...
Feb 28th
5 notes