I am Hack Sparrow
Captain of the Internets.

Archive for March, 2012

The Vim Survival Kit

Has Vim's vast options intimidated you to the point of not even daring to learn the basics? Fear not, for the Captain is here with you. In this post I will show you the most basic and useful commands that every Vim user should know. First off, there is a difference between Vi and Vim. Vim is like the improved version of the Vi editor (Vim == proved). If you are on Ubuntu, you need to install Vim first. The default Vi edi ...

Linux – Find out which OS distro

So how do you get the distro name of the Linux you are using? The uname command doesn't really help a lot of time. [code] $ uname -a Linux hackbox 2.6.32-131.17.1.el6.x86_64 #1 SMP Thu Oct 6 19:24:09 BST 2011 x86_64 x86_64 x86_64 GNU/Linux [/code] Try looking for the details in /proc/version. [code] $ cat /proc/version Linux version 2.6.32-5-xen-amd64 (Debian 2.6.32-31) (captain@hacksparrow.com) (gcc versi ...

JavaScript – Use Variables with Regular Expressions

So you know the basics of Regular Expressions in JavaScript and often use it for replacing text etc. Example: [code] var sentence = 'Regular Expression'; sentence.replace(/ssion/, 'shun'); // "Regular Expreshun" [/code] Now what if the string you need to replace needs to be flexible? Well you could use a variable! [code] var replacee = 'sion'; var replacer = 'hun'; sentence.replace(/+ replacee +/, replacer); // SyntaxError ...

Express.js Tutorial

Looking for a good tutorial on Express.js to help you get quickly productive in it? You have come to the right place. [notice] This tutorial is for Express 3, the current version is Express 4. Unless you want to use Express 3, consider the tutorial outdated. [/notice] In this tutorial I will run you through the process setting up an Express.js app and making it do what a basic website might do. You will learn the basics of routes, views, Jade templates, Stylus CSS engine, handling POST a ...

Express.js HTTPS

Setting up a HTTPS Express.js server is pretty easy and straightforward. First you need to make sure you have a signed SSL certificate for your server. In case you don't have one, you can create one for yourself this way: [code] $ openssl genrsa -out hacksparrow-key.pem 1024 $ openssl req -new -key hacksparrow-key.pem -out certrequest.csr $ openssl x509 -req -in certrequest.csr -signkey hacksparrow-key.pem -out hacksparrow-cert.pem [/co ...