Skip to content

Instantly share code, notes, and snippets.

@paramburu
paramburu / listenOnPortOrSocketFile.js
Last active September 10, 2015 22:13 — forked from visnup/listenOnPortOrSocketFile.js
Listen on a TCP port or a UNIX socket file in node.js. Handle EADDRINUSE for the socket file by deleting it and re-listening.
var fs = require('fs')
, net = require('net')
, http = require('http')
, port = process.env.PORT;
var app = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
@paramburu
paramburu / headings.scss
Created March 18, 2014 03:57
Sass recursive headings function (h1, h2, h3...)
@function headings($from:1, $to:6) {
@if $from == $to {
@return 'h#{$from}';
} @else {
@return 'h#{$from},' + headings($from+1, $to);
}
}