Thursday, February 21, 2013

Picking up Node.js

Over the last 6 to 9 months I've started playing around with Node.js. Node.js has often been described as "server-side" but really it's about using a javascript engine in all the places you might want to use Javascript, but don't want the browser.

Node is CommonJS implementation. You can run code server-side, you can make command-line tools, I'm sure there is other stuff you can do with it too.

A good place to start learning Node is The Node Beginner Book at least for me it was a great starting point.

Wednesday, February 13, 2013

Stop the Android "bounce" on Cordova (PhoneGap) based projects

Jeremy asked how to stop the bounce on android projects that use the WebView.

What you need to do is add a little bit of code to your Java class that extends DroidGap.

First, add an import for adroid.view.View:
import android.view.View;


Then, you need to make a call to 'setOverScrollMode' - however this call is only available on android 2.3 (gingerbread) and later.
Note, you'll want to add this to the end of the onCreate method, after the call to super.onCreate
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
  this.appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
And that should stop "OverScroll" or bounce & the associated highlighting you see.

Sunday, February 10, 2013

Simple command line tool via Node.js

Here is the gist of a little script I wrote recently:

concat.js

It runs on Node, so you'll need that, and npm of course (which installs with Node), you'll also note that you'll need commander, you can ge that by running:
npm instal commander
Once you've got that installed you can use the following to get the usage information:
node concat.js
Which will return
 Usage: concat.js [options]

  Options:

    -h, --help                output usage information
    -V, --version             output the version number
    -f, --filelist [txtfile]  use an input file with a comma separated list of files to concat
    -s, --files [files]       specify the files to concat in the option
    -d, --dest [dest]         the destination file
So, it's a little script that will take a list of javascript files & concatenate them together. You can provide the list either in a text file or on the command line, and in either case it's a comma separated list of filenames.

References:
Inspiration: blog.millermedeiros.com
Node.js: Node.js
Commander.js: on github