Skip to content

Instantly share code, notes, and snippets.

@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");
@Couto
Couto / raspberrypi_archlinux.md
Last active August 27, 2017 17:06
Raspberry Pi with ArchLinux
@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: '"'
};
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
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.
@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
}
@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;
@johnpolacek
johnpolacek / .gitconfig
Last active May 8, 2024 04:05
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
@masahirompp
masahirompp / User.ts
Last active May 5, 2021 20:04
mongoose + typescript
/// <reference path="../tsd/tsd.d.ts" />
import mongoose = require('mongoose');
import passport = require('passport');
interface IUser extends mongoose.Document {
provider: string;
id: string;
authorId: string;
displayName: string;
@emyarod
emyarod / color-map.scss
Created April 8, 2016 09:35
Google Material Design colors in a Sass map
// $primary: get-color('cyan', '500');
@function get-color($color-hue, $color-shade: '500') {
$color: map-get(map-get($colors, $color-hue), $color-shade);
@if $color {
@return $color;
} @else { @error '=> ERROR'; }
}
$colors: (
/**
* Called if a parameter is missing and
* the default value is evaluated.
*/
function mandatory() {
throw new Error('Missing parameter');
}
function foo(mustBeProvided = mandatory()) {
return mustBeProvided;
}