Skip to main content

Posts

Showing posts from 2013

A Very Simple Network Connection with Node

Let’s say we want a very simple NodeJS server that listens on a specified port and writes the data it receives from TCP connections to a file. How easy can we code this up? Turns out this is fairly simple with NodeJS.
Require the necessary modules and instantiate a server. varserver=require('net').createServer();varfs=require('fs');server.listen(14300,serverReady);Start listening on a port, call function ‘serverReady’ when the server’s bound and ready to start receiving incoming connections. functionserverReady(){server.on('connection',handleConnection);}Assign an event handler on the server to call ‘handleConnection’ whenever a client connects to the bound server. The handler will receive the socket object for an argument. functionhandleConnection(socket){socket.setEncoding('utf8');socket.on('data',writeData);}When we get a connection, set the socket to utf8 encoding so that we simply receive strings for data rather than Buffer objects. When dat…

Fancy FTP Deployment with Grunt

I recently dove into Grunt.js at work for automating our build process and I haven’t looked back. It’s an awesome tool with a plug-in for just about anything. I expected the usual would be there like JavaScript minification and concatenation, but I was surprised at a few others that I found, one being for FTP file deployment. Just shows how popular and community supported Grunt is.

There are a few FTP plug-ins available for Grunt. I didn’t do an analysis of all of them but ran across grunt-ftp-push which seemed to do what I needed so I decided to try it out. A simple ftp-push setup to upload an entire project via FTP could look like this:

grunt.initConfig({ftp_push:{all:{options:{host:'example.com',port:21,dest:'/project/path/',username:'user',password:'pass'},expand:true,cwd:'dist',src:['**/*','!**/*.zip']}}});
Some details here: I opted to put the username and password in the main config rather than using an .ftpauth file. The …

More Commute Options

I’ve had about a 25 minute drive each way commuting to work for close to the past three years. While I’ve listened to the occasional podcast to try to make something out of this 4 hours a week that I must expend for my job, I often would resort back to music. Nothing wrong with that. Sometimes it helps me wind down from the day. In the past couple weeks though, this picture has been making it’s way around the web:

I was rather inspired by this. Here I have access to a wealth of knowledge through my phone, but rarely use it as such. There’s plenty of things I’ve wanted to learn about but usually ended with thinking “I don’t have time” when I got home. So, recently I’ve been exploiting my phone for learning opportunities. Not home and have to wait on something? Just bust out one of those cheap e-books Amazon was giving away in the past.  I’ve also come across a few more ways to utilize audio in my car beyond the simple podcast or audiobook. Wikipedia Spoken Articles
I’ve recently became…