Maintenance
Greetings to those who actually read my blog. My site and all associated sites (chat.blangdon.com and mirror.blangdon.com) will down starting Wednesday 5/9/2012 at noon Eastern time and will return some time Friday 5/11/2012 after noon Eastern Time.
Continuous NodeJS Module
Greetings everyone. I wanted to take a moment to mention the new NodeJS module that I just published called Continuous.
Continuous is a fairly simply plugin that is aimed to aid in running blocks of code consistently; it is an event based interface for setTimeout and setInterval. With Continuous you can choose to run code at a set or random interval and can also hook into events.
Installation:
npm install continuous
Continuous Usage:
This code will run the provided callback every 1 to 3 seconds up to 5 times. It will also force stop the execution of the callback after 5 seconds.
var continuous = require('continuous');
var run = new continuous({
minTime: 1000,
maxTime: 3000,
random: true,
callback: function(){
return Math.round( new Date().getTime()/1000.0 );
},
limit: 5
});
run.on('complete', function(count, result){
console.log('I have run ' + count + ' times');
console.log('Results:');
console.dir(result);
});
run.on('started', function(){
console.log('I Started');
});
run.on('stopped', function(){
console.log('I am Done');
});
run.start();
setTimeout( function(){
run.stop();
}, 5000 );
For more information check out Continuous on Bitbucket
OS X Battery Percentage Command Line
Recently I learned how to enable full screen console mode for OS X but the first issue I ran into was trying to determine how far gone the battery in my laptop was. Yes of course I could use the fancy little button on the side that lights up and shows me but that would be way too easy for a programmer, so of course instead I wrote this scripts. The script will gather the battery current and max capacity and simply divide them to give you a percentage of battery life left.
Just create this script, I named mine "battery", make sure to enable execution "chmod +x battery" and I moved mine into "/usr/sbin/". Then to use simply run the command "battery" and you'll get an output similar to "3.900%" (yes as of the writing of this my battery needs a charging).
#!/bin/bash
current=`ioreg -l | grep CurrentCapacity | awk '{print %5}'`
max=`ioreg -l | grep MaxCapacity| awk '{print %5}'`
echo `echo "scale=3;$current/$max*100"|bc -l`'%'
Enjoy!
What I’m Working on Now
There has been a lot of lapse between posts lately but rest assure, I've been fairly busy learning new and exciting things. Lately I have been playing around with NodeJS quite a bit with Jade/Stylus/Coffee, Socket.IO and SocketStream. I am working on a project with Node to create a traffic/scoring/monitoring engine for my University to use when practicing for NECCDC and as of today I am planning a rebuild of my blog using NodeJS.






