Skip to content

Instantly share code, notes, and snippets.

Jay lakemove

Block or report user

Report or block lakemove

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@branneman
branneman / better-nodejs-require-paths.md
Last active Mar 27, 2020
Better local require() paths for Node.js
View better-nodejs-require-paths.md

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@juandopazo
juandopazo / client.js
Created Aug 19, 2012
localtunnel in Node
View client.js
var http = require('http');
module.exports = function (config) {
console.log("Starting client");
var client = http.request({
host: config.remoteHost,
port: config.remotePort,
method: 'CONNECT',
path: 'new'
@kiy0taka
kiy0taka / tree.md
Created Apr 24, 2012 — forked from timyates/tree.md
A one-line tree in Groovy
View tree.md

One line Tree in Groovy

The other day, I saw Harold Cooper's One-line tree in Python via autovivication, and wondered if the same thing was possible in Groovy.

The answer is yes! But you need to define the variable tree before you can assign it to the self-referential withDefault closure, hence with Groovy, it's a two-line solution ;-)

Anyway, given:

def tree = { [:].withDefault{ owner.call() } }
@zaius
zaius / background.sh
Created Jan 16, 2011
How to redirect a running process output to a file and log out
View background.sh
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@kennethkalmer
kennethkalmer / gist:278814
Created Jan 16, 2010
node.js SMTP Server
View gist:278814
/*
smtpd.js is SMTP server written for node.js
MIT License
*/
var tcp = require('tcp');
var sys = require('sys');
You can’t perform that action at this time.