Skip to content

Instantly share code, notes, and snippets.

@thecneu
thecneu / combinations
Created April 26, 2014 00:09
Find combinations of a list of arrays [ ['a], ['b'] ] = 'a' 'b' 'ab'
function getCombinations( list ) {
var set = [],
listSize = list.length,
combinationsCount = (1 << listSize),
combination;
for ( var i = 1; i < combinationsCount; i++ ) {
var combination = [];
for ( var j=0; j<listSize; j++ ) {
if ( (i & (1 << j)) ) {
@thecneu
thecneu / contains
Created April 26, 2014 00:10
Intersection and contains - stripped from underscore
function contains(a, obj) {
var i = a.length;
while (i--) {
if (a[i] === obj) {
return true;
}
}
return false;
}
sudo mkdir -p /data/db
sudo chown -R `id -u` /data/db
D=$'\e[37;40m'
PINK=$'\e[35;40m'
GREEN=$'\e[32;40m'
ORANGE=$'\e[33;40m'
hg_ps1() {
hg prompt "{${D} on ${PINK}{branch}}{${D} at ${ORANGE}{bookmark}}{${GREEN}{status}}" 2> /dev/null
}
export CLICOLOR=1
@thecneu
thecneu / hotreload.js
Last active March 2, 2017 22:14
hot reload
ReactDOM.render(
<App />,
rootEl
)
if (module.hot) {
module.hot.accept('./App', () => {
const NextApp = require('./App').default
ReactDOM.render(
<NextApp />,