Monday, October 27, 2014

How To Create a CLI Program Using Coffee-Script

I'll show you how to create a command line program with coffee-script.

First of all, you'll need node.js - if you don't have it installed, then head over to and install it. You will also need coffee-script:
$ sudo npm install coffee-script -g

We will call our application arg,  so let's create the project directory:

$ mkdir arg
$ cd arg
$ mkdir bin
$ npm init

The npm init command will ask you for your project info - for this demo, you can just hit enter for each prompt. This creates the file package.json, which we will edit, adding:

  "bin": {
    "arg": "./bin/arg"

Next create create the file ./bin/arg (no extension) with the following lines

#!/usr/bin/env coffee
http = require('http')
url = ""

http.get url+escape(process.argv.slice(2).join(' ')), (res) ->
  res.on 'data', (chunk) ->
    console.log String(chunk)
  .on 'error', (err) ->
    console.log err
Finally, mark it as executable and install:

$ chmod a+x ./bin/arg
$ sudo npm install . -g

Now enter

$ arg I like coffee-script
I like spiced rum-script

Spiced Rum-Script? Hmmm...

Arg follow 'tis link to github to download th' gist

Friday, October 17, 2014

The Graying of Software

Aging is one thing that affects everyone, regardless of socio-economic status or any other measure of the human condition. So seeing something like Telikin makes me feel good.

Don't mistake this for an endorsement of their product - I've never used it. I'm not recommending that you buy it. But I know that my parents would have loved something like this. They had WebTV, and as awful as that was, they enjoyed using it.

Is there other 'software for seniors'? I don't see much out there. I think there should be more thought, discussion, and action about this. Everyone of us has at least two seniors that have affected our lives. We need to give back. What applications would we write? Reminders? Memory Games? Remotes? Calculators? Almost anything can be re-tooled for senior needs. What software will you want to use when you get old and gray? Will you still be able to use it?

It's a potentially huge market, but it has a very limited budget. Our local retailers offer senior discounts. What about Google - should they give a discount to seniors? How do we verify age to make that possible?

All I have are questions. I think these are questions we should all be asking.

Monday, October 6, 2014

Selling Your Old Android Phone?

Whether you donate or sell your old Android phone, you should make sure that there is no personal information left on it. C/Net has a great how to:

But as I got to step three: Load dummy data, I thought 'How much dummy data can my phone hold?' About 12 gb, it seems. That sounds tediuos - what are the chances that I'll actually finish copying 12 gb of dummy photos to my phone? Where am I going to get that many dummy photo's? And aren't photo's going to automatically post to Google+? Agh.

Of course, there is the advice 'take a hammer to your phone' ... So I wrote an app to do it for me

Data Hammer

And it's free on Google Play:

Get it on Google Play

Data Hammer fills up your phone's hard drive with random bytes. I've tested it on our phones -

  • Nexus 4 running 4.4, both Dalvik and ART
  • Samsung S4 running 4.3

And it is tested in the emulator to be compatible back to version 2.2 Froyo.

Please report any issues on github

Friday, August 29, 2014

Run Local Flash Games in Linux

I recently upgraded to Linux Mint 17.  So far, the only issue I've run into is that my Flash (*.swf) files no longer run when I try to open them in a browser. Instead of playing my game, it tries to download the file from my local drive to my local drive.

I've checked all the forums. It look other distro's have the same issue. And the support bozo's all say you can't do that. This tells me that they are just reading from a script, because it has always worked before.

So what's the answer? Simple - the mime type association has been changed, probably at, which is upstream from the distros. Here is how you can change it back:

$ gksudo gedit /usr/share/mime/packages/

Replace "" with "x-shockwave-flash" and save.
Now update your mime types:

$ sudo update-mime-database /usr/share/mime

Now navigate to your *.swf file. You should see the old flash icon back. You can now right click on the file and open it directly in your browser.

Happy Gaming!

Friday, August 1, 2014

Releasing a Signed Cordova Apk from NetBeans 8

I'll show how to build a cordova android app in NetBeans 8, and release a signed apk file.

The first part is relatively easy. Start up NetBeans 8, and from the main menu select File -> New Project. This brings up the New Project dialog.

In the dialog 'Categories' open the Samples folder and select the HTML5 subfolder. In the dialog 'Projects', select the Cordova Maps Sample, and click Next, name the project and click Finish:

This generates the application. Open index.html in your root, connect your android phone to the usb and hit F6 to run the project.

You should see something like this on your phone:

That was the easy part. Net beans doesn't have any menu selections to build a signed apk that you can distribute. However, Cordova uses an ant build process, and NetBeans is ant friendly.

So, the first thing you need to do is create your key:

$ keytool -genkey -v -keystore myapp.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

The keystore utility will walk you through some questions. You'll need to enter your app name and password, app alias, alias password and developer name. The remaining can be defaulted.

Now, in NetBeans project explorer, select the files tab, and create a file named ./platforms/android/ entering the following contents:

Now you can right-click on ./platforms/android/build.xml and select Run Target -> release:

It will take a minute or two, and the ant build process will generate  ./platforms/android/bin/MyApp-release.apk, a signed distribution file.

Maybe I was wrong - with a little tlc, NetBeans does have a menu selection to build your apk!

Monday, May 26, 2014

Porting an MVC4 App from VisualStudio to MonoDevelop

I recently created a demo shopping cart application using VisualStudio Express 2013 and MVC4. This meant spending some time in Windows.  But, I was quite impressed with MVC4. This is a vast improvement over the old viewstate based web apps. Plus, there is asset bundling support. This was worth the time spent using Windows.

When I was done, I wanted to log back into my Linux machine and port my project to Mono. The first thing I did was upgrade to Mono 3 and MonoDevelop 5. And then I set about porting my demo. MonoDevelop only has MVC3 templates, so first, I had to find an MVC4 template, Now I was ready to get started.

With most IDE's, you can just drop files into a folder and forge ahead. But MonoDevelop uses the VisualStudio project structure that mirrors the file system. So I  fired up MD, loaded my template, renamed it, and deleted all of the boilerplate. Then I visited each project folder, right clicked, selected Add Files from Folder, and dragged in all of the source from my original project.  This worked for everything except the Model.

Since Linux doesn't support MSSQL, I decided to use MySQL, with NHibernate for my ORM. I prefer a database first design process, so the first thing I did was update the sql script that creates my database and stored procs. Then I copied in the domain objects created by EntityFramework, changing the properties to virtual. The real work was creating the xml bindings -  but I actually prefer doing it manually, it is much easier to update than the tedious VisualStudio process of deleting and rerunning the wizard. Plus, you have much more control over the final product.

Thas is it. You can see the result at And compare the projects on github. The original VS project is at, and the MonoDevelop project is at

Thursday, May 22, 2014

Deploy Mono MVC4 to AppHarbor

After upgrading to MonoDevelop 5,  (see my previous blog: Upgrading to MonoDevelop 5.1 in Linux Mint 16) you'll want to create an mvc4 app. But MD5 only comes with mvc3 templates. No problem. Chris F Carroll has published just the template you'll need. Clone this github project: Asp.Net MVC4 C# Razor Template for Mono on Mac and Linux

This template worked for me right out of the box. But when I deployed it to AppHarbor, it failed. The log shows this error:

error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I actually got the same error using the mvc3 templates that ship with MonoDevelop. This is due to some missing tags in the Web.config file. Find this section:

   <compilation debug="false" targetFramework="4.0">

You'll need to add these tags:

        <add assembly="System.Web.Helpers, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Now re-deploy your site. You'll find that these tags will disappear any time you modify your project references. I keep a copy inside a comment tag inside the web.config file, so I don't have to go looking for them every time I update my project.

Wednesday, May 21, 2014

Upgrading to MonoDevelop 5.1 in Linux Mint 16

Linux Mint, being based on Ubuntu, is stuck with an old version of Mono, and an equally old version of MonoDevelop. So, using this posting on stackoverflow, I've upgraded to the latest versions of Mono runtime and MonoDevelop.

First, the runtime:

sudo add-apt-repository ppa:directhex/monoxide

In Software Manager, edit Software source PPA's for monoxide, changing saucy to raring to select the 13.10 Ubuntu branch. Now upgrade:

sudo apt-get update && sudo apt-get dist-upgrade

At this point, I am running MonoDevelop 5.1, and I can compile and run desktop apps.
Next,  to use ASP.NET, we meed to get the web server running:

sudo apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libpng12-dev libfontconfig1-dev
cd Git
git clone git://
cd xsp
./ --prefix=/usr
sudo make install
sudo mkdir /etc/mono/registry
sudo chmod -R 0777 /etc/mono/registry

I can now create and run ASP.NET apps.  Check out my demo shopping cart app - Monomart.

Monday, May 19, 2014

Why Use Stored Procedures?

It's an old debate. Google 'why use stored procedures' and you'll get a million hits and a million opinions.  Many of the answers are technical in nature, relating to performance issues. The rest are pro/con discussions about where and how you want to code and debug your business logic, or how ugly stored procedures are compared to an elegant ORM. Along those lines, here is my favorite rant Who Needs Stored Procedures, Anyways?

But most of those reasons don't really matter. because the most compelling reasons to use sprocs are not technical at all, they are administrative.

Reason 1:
Data integrity. Say for example, your app has 1,000 tables. Don't laugh - SAP has way more tables than that. Your shop has a dev pool of 6 positions with an average job turnaround of 6 months. If those developers are maintaining embedding SQL into the application code, inconsistencies will crop up. If you are using sprocs, then you can have some assurance that the DAL isn't impacted.

Reason 2:
The business. Remember them? They are why you have a database. Suppose you have a business role that audits business line items, but isn't allowed to view the cost field in the line item table. Table level security won't help. Even if your app doesn't expose the cost, a clever power user will figure out how to download the table in MS Access, and then they can view the cost. You need sprocs or views to control that.

In light of business reasons like these, does it matter that stored procedures can't pass objects? Only to coders.

Wednesday, April 30, 2014

The Wonderful Thing About Windows Is...

That Windows Just Loves to Reboot. (Apologies to A. A. Milne)

I've finally got my mouse wheel back in Windows 7.  I've tried again and again, in Control Panel > Mouse resetting the parameters on the wheel. It never seems to work. And it's been rebooted countless times in the interim.

Today, I was making sure that my Node.js tool chain worked in windows, so I could hand it off to a windows developer. The lack of scroll wheel was driving me insane - I finally had enough and said to myself "I'm fixing this before I do anything else". So, armed with the old adage that 'the wonderful thing about windows is that windows just loves to reboot'  I tackled the issue. Here is what finally worked.

  1. Reboot.
  2. Enable touchpad (I hate touchpads, they trigger too often when my hands get tired). Reboot.
  3. Using the tray touchpad utility from Dell, I reset the pointer devices to default. Reboot.
  4. Went into Control Panel > Mouse, and changed my Mouse wheel params. Reset them Back. Reboot.
  5. At this point, the mouse wheel finally started working. I went back to the touchpad utility, and disabled it. Reboot.
  6. Now I have a working mouse wheel, and a disabled touch pad. 
Hooray for Windows!

Wednesday, April 23, 2014

Parsing a PDF file in Excel

Every Linux distro comes with a handy utility called pdftotext. But you can use it on a windows machine, as well.  Using the browser of your choice, visit, and download the precompiled for x86 Windows.

Different windows versions and installs give you different default directories, so I'll tell you what I did.

1. The file you downloaded is a zip, so first unzip it.Then look in the subfolders - on my pc:


     if you are running on a 32 bit OS, there is also a


2. Go to Start>Run and enter cmd. That puts me in C:\Users\Bruce. Then enter cd Documents. My dos prompt now says


    That maps to the Documents folder on the start menu. In an explorer window, copy the pdtotext.exe file from the folder in step 1 to your Documents folder.

3. Put your PDF doc in the Documents folder. Now, from the dos prompt, enter:

      pdftotext <filename>.pdf -layout

In the explorer window, you should now see a file named <filename>.txt

If that gives you the results you are looking for, then this excel macro will probably make things easier - just change the line:

        exe = "C:\Users\Bruce\Documents\pdftotext.exe"

to reflect where your exe ended up:

Tuesday, April 1, 2014

How To Uninstall Firefox in Linux Mint

One of the best features of Linux is the package manger. The package manager gives you the freedom to install your choice of many great software applications. And, if you so choose, you can also remove those same applications. After all - it's a free distro. Free as in beer, and free as in choice.

It is pretty easy to remove Firefox - just open a terminal window and enter:

$ sudo apt-get remove firefox

Firefox came pre-installed in the latest version of Linux Mint, which I recently installed. So is it safe to remove? Why not - after all, it's not Internet Exploder! And, if you read my post Enabling the Java Plugin for Chrome in Mint, which piggybacks on Firefox, don't worry - the Java plugin still works in Chrome.

Now, if it turns out you do need Firefox after all - perhaps there is a web app that you use that only runs in Firefox, just re-install it:

$ sudo apt-get install firefox

I did and voila - all of my preferences and settings were still there, along with all of the plugins I had previously installed. 

Sunday, March 30, 2014

CoffeeScript vs TypeScript

Why do I prefer CoffeeScript over TypeScript?

There are some obvious syntax differences -

  • CS uses white space to define bocks,  TS uses curly braces 
  • CS uses the -> operator to define functions
  • CS uses @ to represent the current context, TS uses the 'this.' keyword

In addition, there are some higher level differences -

  • TS has a concept of modules, CS is not opinionated on this.
  • TS allows you to define a type when you declare vars.
  • TS resolves the super class at compile type, CS accepts a run-time reference.

The syntax differences are more a matter of preference. To me, CoffeeScript is cleaner looking, and requires less keyboard action to write. It also makes async and callbacks easier to follow, especially with the alternate bound function definition operator => for events.

Higher level differences make more of a difference when deigning your app. TypeScript restricts you to their own concept of modules. CoffeeScript is flexible on this matter, and I can use several different module libraries, from native node require on the server to RequireJS or Browserify on the client. 

All in all, I find CoffeeScript easier to code, and less restrictive, where TypeScript fights the dynamic nature of javascript, 

Sunday, March 23, 2014

Enabling the Java Plugin for Chrome in Mint

So, you've gone to the Oracle web site and installed Java. But when you visit a website that requires Java, you still get a message that directs you back to the Oracle web site to install Java. The problem is that your browser doesn't know that you've installed Java, so you need to tell it where to look.

Both Ubuntu and Mint use Firefox as a default browser.  If we tell Firefox where to look, Chrome will also know. So we actually get a 2 for 1 deal.

You'll need to know where Firefox is installed, as well as Java. On my machine, these are:
  • Firefox - /usr/lib/mozilla
  • Java - /usr/local/jdk1.7.0_45/jre
If you've only installed the java runtime, it's probably in /usr/local/jre1.7.0_45. Your folder structure may be for a different version. If you're not sure where Java is, you can open a terminal window and enter:

$ sudo find / -name

Armed with this information, open a terminal window, and go to the Firefox folder:

$ cd "/usr/lib/mozilla/plugins"

Now,  create a symbolic link in that folder that points back to the plugin:

$ sudo ln -s "/usr/local/jdk1.7.0_45/jre/lib/amd64/"

Now, you can restart your browser, and enable the plugin:

  • Firefox - Select Tools > Add-ons (Ctrl+Shift+A) from the Menu Bar.  Then select the Plugins panel, and enable Java(TM) Plug-in
  • Chrome - type chrome://plugins in the Navigation Bar to enable the plugin.

Now goto to verify the plugin is working.

I've recently upgraded from Xubuntu to Linux Mint. What is nice is that since Mint is based on Ubuntu, many of the tricks and tips that I've learned for Ubuntu also work on Mint. This tip that worked on Xubuntu 11.10 with Java 1.6, still works on Mint 16 Cinnamon with Java 1.7.

Saturday, March 22, 2014

Top 6 Web Conferencing Solutions for Linux

I'm looking for good online meeting software so I can collaborate with other developers, and hopefully some customers as well.

My criteria as simple - it has to run on linux, and it has to be free. I don't mind if there is a pro version that I can upgrade to if I find it to be that useful. But no 14 day free demos.

My laptop runs on Linux Mint 16 Cinnamon 64-bit. After reviewing many packages, here are the ones I found several that will run on my machine:

A nice modern look with Google calendar integration. The ui is easy to use, and the workflow is well thought out - after the meeting, I was emailed with a reminder to follow up on my action items. also gives you a public Meet Me page where anyone can schedule a meeting with me. There is an Android app, but it's still beta.

Meeting Burner 

A full featured application, the ui reminds me of LiveMeeting. MeetingBurner uses Flash player for the presentation window. There is also a mobile app for android which requires Adobe AIR.


Yeah, I know. If you google 'veeting' you'll find something completely different :)  Veeting claims to be very confidential due to Swiss hosting. You can schedule short one-off meeting with one other person without joining.


Vyew has a lot of features, but has a steep learning curve.

Web Huddle

WebHuddle is beta, and feels like it. I'll have to check back later when it more finished.


On linux, Cisco WebEx only works in Firefox with Java enabled. The features are comparable to MeetingBurner. There is also a android app.

I really like It's pure HTML, has a modern look, and I love the Meet Me page and Google integration. I also like MeetingBurner, it's packed with functionality and easy to use. There is an Android app, and it works great on my Nexus phone. In some respects, they can complement each other, and I will be using both of them.

Veeting is not bad either, but seems more like a Skype alternative. The remaining are in my opinion not very easy to use. I think a meeting app should be more intuitive, otherwise it get's in the way of the meeting. WebEx is fast and the android app updates almost instantly, but the ui reminds me of the admin page on my router - also a Cisco product... If they fix their UX, I'd probably use it.

Wednesday, March 5, 2014

Put Some Promise in your Cakefile

Cakefiles seem like such a simple solution, until you need asynchronous code. Even in coffeescript, the "pyramid of doom" becomes hard to handle. For example, take a look at the cakefile I use to build the huginn-liquid distribution:

util = require 'util'
{exec} = require "child_process"

task 'build:src', 'Build the Liquid source', ->

  # Build the intermediate js
  exec 'coffee -o lib -c src', ($err, $stdout, $stderr) ->

    util.log $err if $err if $err?
    util.log $stderr if $stderr if $stderr?
    util.log $stdout if $stdout if $stdout?
    util.log 'ok' unless $stdout?

    exec 'browserify  lib/liquid.js --debug --standalone Liquid > dist/liquid.dbg.js', ($err, $stdout, $stderr) ->

      util.log $err if $err if $err?
      util.log $stderr if $stderr if $stderr?
      util.log $stdout if $stdout if $stdout?
      util.log 'ok' unless $stdout?

      exec 'browserify lib/liquid.js --standalone Liquid | uglifyjs > dist/liquid.min.js', ($err, $stdout, $stderr) ->

        util.log $err if $err if $err?
        util.log $stderr if $stderr if $stderr?
        util.log $stdout if $stdout if $stdout?
        util.log 'ok' unless $stdout?

        exec 'browserify  lib/liquid.js --standalone Liquid > dist/liquid.js', ($err, $stdout, $stderr) ->

          util.log $err if $err if $err?
          util.log $stderr if $stderr if $stderr?
          util.log $stdout if $stdout if $stdout?
          util.log 'ok' unless $stdout?

As you can see, even with CoffeeScripts async friendly syntax, the code still starts to creep off that right edge. And adding more build steps will only get worse. But with Promises, we can fix that. First, install Q:

$ sudo npm install -g q

Now we can make some changes to Cakefile that will make it easier to read. We'll use Q's nfcall method.

util = require 'util'
{exec} = require "child_process"
{nfcall} = require 'q'

task 'build:src', 'Build the Liquid source', ->

  # Build the intermediate js

  start = new Date().getTime()

  nfcall exec, 'coffee -o lib -c src'

  .then ->
      nfcall exec, 'browserify  lib/liquid.js --debug --standalone Liquid > dist/liquid.dbg.js'

  .then ->
      nfcall exec, 'browserify lib/liquid.js --standalone Liquid | uglifyjs > dist/liquid.min.js'

  .then ->
      nfcall exec, 'browserify  lib/liquid.js --standalone Liquid > dist/liquid.js'

  .fail ($err) ->
      util.error $err

  .done ($args) ->
      util.log $text for $text in $args when not /\s*/.test $text
      util.log "Compiled in #{new Date().getTime() - start} ms"

Wow - that IS cleaner! And as I add more steps it will stay just as easy to read.

Friday, January 3, 2014

Coding Requires Abandonment

Sure, I've stayed up all night coding, just 'cause I couldn't stop. But that's not what I'm talking about.

I'm referring to the notion that a node module requires a return value. Abandon that thought - I did recently while breaking my code into framework modules.  Lets look at what I did.

First, the framework needs a  namespace, or root object.

module.exports =

  VERSION:  require('../package.json').version

require './liquid/drop'
require './liquid/interrupt'
require './liquid/strainer'
require './liquid/context'
figure1: ./src/

Then, we link up the framework classes:

Liquid = require('../liquid')

class Liquid.Interrupt

  message: ''

  constructor: (@message = 'interrupt') ->

class Liquid.BreakInterrupt extends Liquid.Interrupt

class Liquid.ContinueInterrupt extends Liquid.Interrupt

figure2: ./liquid/

Note the lack of a module.exports in the child class. Instead, I've required the namespace root, and defined the classes as properties of that.
We can repeat this pattern to fill out the entire framework - you can view the full example on github.