Skip to content

Instantly share code, notes, and snippets.

@johnpolacek
johnpolacek / .gitconfig
Last active March 8, 2025 22:15
My current .gitconfig aliases
[alias]
recent = "!git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)' | head -n 10"
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
@colelawrence
colelawrence / passhash.coffee
Created June 4, 2014 19:33
Password hashing for nodejs
# check out https://github.com/visionmedia/node-pwd
# Module dependencies.
crypto = require('crypto');
# Bytesize.
len = 128;
@colelawrence
colelawrence / utils.js
Last active August 29, 2015 13:58
Incrementing object properties
// Ensure object obj[prop] = {}
function _obj(obj, prop) {
if (obj[prop] == null) obj[prop] = {}
return obj[prop]
}
// Ensure number obj[prop] (+= val or = val)
function _diff(obj, prop, val) {
if (obj[prop] == null) obj[prop] = val
else obj[prop] += val
}
@cerebrl
cerebrl / 1-securing-express.md
Last active February 23, 2025 17:02
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@Rich-Harris
Rich-Harris / CSV Parser
Created October 11, 2012 17:15
A bog standard JavaScript CSV parser. Putting it here so I don't need to keep rewriting it or remembering where I put the last one. Usage self-explanatory, will break if you throw weird shit at it (cells with newlines in them, that sort of thing)
CSVParser = function ( options ) {
var defaults, delimiter, rowDelimiter, qualifier, qualified, unqualified;
options = options || {};
defaults = {
delimiter: ',',
rowDelimiter: '\n',
qualifier: '"'
};
@Couto
Couto / raspberrypi_archlinux.md
Last active August 27, 2017 17:06
Raspberry Pi with ArchLinux
@kitek
kitek / gist:1579117
Created January 8, 2012 17:50
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");