Archive for March, 2013

Even better way to clear your Web SQL or local dbs in Google Chrome

March 25th, 2013

Thanks to one of my visitors to my site, I have been directed to a much easier and cleaner way to delete your local databases in Google Chrome, simple put this into your address bar in Chrome: chrome://settings/cookies and it will pull up a screen similar to this:

I just simply did a search for “localhost” and it pulled up my site which looked like this:


From there you can delete whatever you want, individual dbs or cookies, any of it.  A much better solution that going out to the file system and blowing away folders and files that are usually in use by chrome which requires a shutdown of all the chrome processes.  I hope this helps others, enjoy!!

Add some sweet logging to your Javascript/Node.js apps with Winston

March 19th, 2013

If you are looking for a logging solution to your javascript or node.js apps, look no further, enter Winston.  This little tool can write logs from your apps to a file, to the console, or to a database and you can even query the logs with its own built in syntax, how sweet is that?  Anyways, I have included below the code snippets that is needed to get it going, check it out:

//by default, Winston is set to log to console 
var winston = require('winston');

 winston.log('info', 'Hello distributed log files!');'Hello again distributed logs');

//you can change that behavior by doing something like this:
winston.add(winston.transports.File, { filename: 'somefile.log' });

Here is the github repo for further reading if you are considering this tool

Pretty simple, just three lines of code and you are logging, just slap a anywhere you want to see some info and you are good to go, enjoy!!

Netflix Comes to the Samsung Arm based Chromebook!!

March 12th, 2013

I love my chromebook, on my blog here you can find other posts where I am dual booting it with Ubuntu off of an SD card.  I have since added a 32GB slim jump drive for extra space, its more than I would ever need, but I thought it would be cool to have that kind of storage to move movies around or music or whatever and it was only $20 from amazon.

Anyways, back to my post subject, when I bought the chromebook I knew full well that netflix did not work with it, but at the end of last year you would get a screen like this one below:


Well, I knew from that error that it would come down the road, so I thought it would just be an extra benefit, albeit one that is a very nice feature of the device, especially on trips and such, since the device is so light and for only $249, you can’t beat it.  That day is finally here!!  You may have to grab the latest update for your device by going to settings and then help, just stay on that page, your device will update if it needs it, but if you are like most, you will have all the latest updates and you will be ready to go, enjoy!!

Using Socket.IO with Backbone.js

March 6th, 2013

I work on a lot of different projects, some for work and some for fun and some on the side.  I have been working on a social application here lately that will have lots of topics and within those topics they will have comments.  I felt like the ‘Room’ concept of would be a good fit for this idea so I began implementing it for this project.  When I first set up socket I was having a problem because stupid me had some javascript that was formatted incorrectly and the engine was not throwing an error with it because it translated to good javascript.  In the meantime while I was doing all of that I had stuck the socket connection in a global variable so it was only making one connection, that does seem to be how you would want your application to be setup anyways.

I have included the final code below of the solution that is working for me with my backbone views, it turns out I had to create a new connection each time a topic was clicked on by the user, due to the fact that I am ‘joining’ them to that room, identified by the TopicID.  When I had the socket defined globally, I was getting duplicate messages back to my clients and my only reasoning was that I had the single connection so my clients were getting those dupes back at them.

If you have anything you could throw in for me with input, I would really appreciate it as I think this setup is not a very scalable one, thanks.

var io = require('').listen(server);
io.sockets.on('connection', function(socket) {
  console.log('Socket Connection Made - Server Side');
  socket.on("leaveRoom", function(data){
      console.log('Leaving room ' +;
  socket.on("setRoom", function(data){
      console.log('Joining room ' +;

  socket.on('comment', function(data) {
    console.log('Emitting comment');'comment', data.comment);

//in backbone view initialize()
var url = "http://localhost:3000";
this.socket = io.connect(url);
this.socket.on('connect', function () {
    that.socket.emit("setRoom", {room: that.model.get("TopicId")});
this.socket.on('comment', function (data) {

//here is the code to tell server a new comment has been published
that.socket.emit('comment',{ comment: msg, room: that.model.get("TopicId")} );

Calculate Percentages from Two HTML inputs with javascript

March 1st, 2013

I recently had a need for a generic way to calculate 100% across two input boxes, for instance if you entered 50% in one box it would go over and put 50% in the other, and vice-versa.  Well, I have accomplished this with a little help from jQuery and for formatting I use the excellent javascript library called autoNumeric found HERE.  Make sure you use the one I have referenced here in the fiddle as others would not let the autoNumericGet work, it must have been older versions. I have linked my jsFiddle below, check it out, run the sample and see how it works, hope this helps someone.

If you can’t see, the fiddle, here is a link to it: