Skip to content

Instantly share code, notes, and snippets.

@anonymelon
anonymelon / better-nodejs-require-paths.md
Created January 5, 2018 06:47 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

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:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@anonymelon
anonymelon / README.md
Last active February 28, 2017 08:51 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@anonymelon
anonymelon / tcp.js
Last active August 29, 2015 14:06 — forked from billywhizz/tcp.js
var TCP = process.binding("tcp_wrap").TCP;
try {
var crypto = process.binding("crypto");
var SecureContext = crypto.SecureContext;
} catch (e) {
throw new Error("node.js not compiled with openssl crypto support.");
}
function noop() {};
function createCredentials(key, cert, ciphers) {