Skip to content

Instantly share code, notes, and snippets.

View hekike's full-sized avatar

Peter Marton hekike

View GitHub Profile
@hekike
hekike / Reduce
Created March 7, 2014 19:18
Reduce
/*
1.
a: NaN
b: 0123
c: 6
*/
var transactions = [{ id: 1, value: 1 }, { id: 2, value: 2 }, { id: 3, value: 3 }];
var total = transactions.reduce(function(prev, transaction) {
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@hekike
hekike / gist:7289302
Last active December 27, 2015 07:29
How to detect the filetype of the stream in NodeJS.
var
beginBuff,
beginBuffStr;
// type detection
if (chunkNum === 0) {
beginBuff = data.slice(0, 8);
beginBuffStr = beginBuff.toString('hex', 0, beginBuff.length);
// jpg