Archive for January, 2013

Nice Javascript function to format numbers to currency

January 29th, 2013

Here is a code snippet I use to take any number in Javascript and format it nicely to a currency, if you just want it to be a regular number, simply leave off the ‘$’ in the return line, voila!! It may look pretty garbled below, if you click on the ‘<>‘ View Source it will show you what its supposed to look like.

Number.prototype.formatMoney = function (c, d, t) {
                var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
                return s + '$' + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");

BTW, you can use this in any standard JavaScript call, even in Underscore templates like this:

<label><%= YourNumber.formatMoney(2, '.', ',') %></label>

Cool OSX tip of the day.

January 25th, 2013

I do a lot of video editing with my mac and whenever I create a video for upload on the web I always need a still image for the preview image in the jwPlayer I use on the web. I used to have to have some kind of program to grab the still and export it for me, not anymore. This functionality is built right into OSX, all you simply have to do is do a SHIFT-COMMAND-4 and it will bring up a crosshairs and allow you to select the item you would like to capture and immediately turn that into a png file and place it on your desktop, how cool is that?

My first little Node.js App

January 24th, 2013

If you are a developer and you haven’t heard about node.js, what rock have you been living under??  Anyways, if you have been hearing about it and would like to learn more, head over to their site HERE and download it and start playing with it.  Its super easy to get going with node, once you install it, all you have to do is open a terminal window and type node “name_of_file.js”, with the correct javascript in it, of course.

I just wrote up this quick little example to see if I could get node to act like a webserver, so here is the js code for it below:

var http = require('http');
var fs = require('fs');
http.createServer(function (req, response) {
    fs.readFile('index.html', function (error, content) {
        if (error) {
        else {
            response.writeHead(200, { 'Content-Type': 'text/html' });
            response.end(content, 'utf-8');

}).listen(1337, '');
console.log('Server running at');

Just create a directory anywhere on your system and create a file with index.html (That’s my example, it can be anything) and then simply issue this command in the terminal window.

node “name_of_file.js”

My example is this: node server.js.

You will get a ‘Server running at’ message after that and that will let you know that node is running correctly, all you have to do after that is open a web browser and go to the address of and you should have the webpage you built, you may want to just slap some text in there so you see something.

I hope this helps someone, I plan on delving into the node realm a lot more in the coming weeks, so look for other posts down the road.

Help!! I have reset my Ubuntu 12.10 password and now the keyring prompt keeps coming up!

January 18th, 2013

I had recently forgotten my Ubuntu login and figured out how to reset the password by basically following these directions found HERE. Then when my system comes back up, I am getting a screen like this:  
The method I used to fix this on my system was simple, just open your directory and hit CTRL+H and that will show the hidden files and folders and then just simply navigate to your /.local/share/keyrings folder and delete anything you have in there.  This prompt won’t bother you again.  I hope this helps someone!!

Installing Chrubuntu on SD Card (to avoid messing with your Chomebook factory settings.)

January 17th, 2013

In a previous post, I posted about putting Ubuntu on your ARM based Chromebook, well if that seems too risky for you, Jay Lee, the guy at this blog post, has created a script to put the OS on a SD card and allow you to dual boot it or ChromeOS, which is exactly what I have been looking for. My chromebook just keeps getting more functional!! If you would like a more visual approach, here is a nice blog post with some nice pictures he’s provided to kinda let you see what you are doing, enjoy.

Create a dynamic and searchable optgroup with select2

January 16th, 2013

If you are writing a web app, you may or may not know about the Select2 control found HERE. I posted about it a few months ago here: and I was going to give you an update with an example of how to use it with an underscore template to create a searchable select with grouping. This will be useful in a project I am working on and I thought I would share. I have attached my jsFiddle below, the creator has an example of templating you can find there but I couldn’t really find an example of how to load the data in dynamically and you CANNOT use the ajax function in it with a select, so basically I create the entire select up front then style it.

How to place latitude and longitude points on a OpenLayers Map.

January 14th, 2013

I have posted a jsFiddle for anyone interested in displaying latitude and longitude points on an OpenLayers Map, I just found some random points from the area around where I live and stubbed them in there, enjoy.

Visual Studio 2012 Tip of the day

January 12th, 2013

I have multiple screens when I am at work so when I take my laptop home I like to work on that and as a result I have issues with windows not showing up on the screen. If you are like most Visual Studio users you make heavy use of the ‘Find in Files’ tool (CTRL+SHIFT+F), its a very handy tool. Well, if you run multiple monitors and you try to find it, it will more than likely be somewhere else and you won’t be able to find it. If you would like this window to show up, it’s gonna cost you some personalization to your studio environment, but it was worth it to me, so I went ahead and did this to get my find tool back:

Just simply Navigate to Window > Reset Window Layout, and agree to the Are you sure you want to…? prompt, that will reset your docked windows but will bring back these floating ones, but these little floating windows are pretty valuable IMO, I hope this helps.

My new MacBook Pro!!

January 10th, 2013

I just received my newest toy at work, a brand new 15″ MacBook pro!! I used to be a pretty tough critic of MacBooks back when my wife was using them at her job doing graphic design work, and now I admit I was that was because I truly didn’t understand the quality of these machines. Granted, Macs have came a long way from their past, but this machine is a beast, its just an amazing piece of hardware, here are specs:

15-inch MacBook Pro with Retina display

• 2.6GHz Quad-core Intel Core i7, Turbo Boost up to 3.6GHz
• 16GB 1600MHz DDR3L SDRAM
• 512GB Flash Storage
• Backlit Keyboard (English) & User’s Guide (English)
• Apple Thunderbolt to Gigabit Ethernet Adapter
• Mini DisplayPort to VGA Adapter

I set it up to dual boot Windows 8 as well and that has pretty much gone without a hitch using Bootcamp that comes with the Mac. I think installed refit to allow me to choose the OS I want, otherwise the mac always just boots into windows 8 which I probably don’t want to do everytime the machine boots up. Refit was the only hiccup that I have experienced so far, it took around 6 restarts to finally get the refit screen to come up and I have noticed others experiencing that online as well, but its running like a champ now.

I have already went thru a tutorial and wrote a simple iPhone app, :), I have been wanting to do that for a while and its not that bad once you get the hang of it. Expect some blog posts about that down the road as well, :).

So far the default installed software on the mac is able to replace pretty much everything I did on windows except visual studio. The only reason I have visual studio and windows on this machine is for the windows azure emulator, which I plan on figuring out a way around it down the road.

MacBook Pro

Getting 500 errors with Windows Azure and IIS

January 8th, 2013

I have yet another fix for anyone that is having problems running windows azure and getting the 500 errors, details follow.


Basically all I had to do was check the boxes you see here in “Windows Features” and all was well, I have no idea why this fixes this problem.  My guess is that somewhere along the line, Microsoft forgot to include this stuff in the Azure Tools SDK.  I hope this helps someone, thanks.