Skip to content

Instantly share code, notes, and snippets.

View zeusdeux's full-sized avatar
👾
i wear my sunglasses at night so i can — so i can justify the money spent on 'em

Mudit zeusdeux

👾
i wear my sunglasses at night so i can — so i can justify the money spent on 'em
View GitHub Profile
@zeusdeux
zeusdeux / keybase.md
Created April 8, 2015 16:30
keybase.md

Keybase proof

I hereby claim:

  • I am zeusdeux on github.
  • I am zeusdeux (https://keybase.io/zeusdeux) on keybase.
  • I have a public key whose fingerprint is 1A74 2ABF 90F4 3181 D979 10E0 17E2 4044 6F8F 5CF5

To claim this, I am signing this object:

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@zeusdeux
zeusdeux / findTopN
Last active August 29, 2015 14:25
Get top N numbers from an arbitrarily large file with one number on each line
#! /usr/bin/env node --harmony_arrow_functions
// chmod a+x this file
// run this as: ./findTopN <path to input file> <value for n>
'use strict';
const path = require('path');
const findTopN = require('./topN');
const args = process.argv.slice(2);
@zeusdeux
zeusdeux / prettyTraces.js
Created July 24, 2015 16:48
Pretty indented stack traces
/*
#
# Example final output:
#
# 1000 main
# 1000 workLoop
# 900 read
# 900 __sys_read
# 100 parse
# 100 strcmp
@zeusdeux
zeusdeux / lookupInsertionIndex.js
Last active August 29, 2015 14:26
Use binary search to find the index where the given element needs to be inserted into the given sorted array
// use binary search to return index where given element needs to be inserted in the input array (must be sorted)
function binarySearchForInsertionIndex(arr, el, index = 0) {
const mid = ~~(arr.length / 2)
if (!arr.length || arr[mid] === el) return index
if (el < arr[mid]) return binarySearchForInsertionIndex(arr.slice(0, mid), el, mid + index - 1)
if (el > arr[mid]) return binarySearchForInsertionIndex(arr.slice(mid + 1), el, mid + index + 1)
}
@zeusdeux
zeusdeux / flexbox-grid.scss
Created October 3, 2015 17:22
flexbox based simple grid system
/* Simple flexbox based grid system */
$columns: 12;
@mixin layout-cols($device) {
@for $i from 1 through 12 {
.l-#{$device}-col-#{$i} {
flex: 0 0 $i / $columns * 100%;
}
}
@zeusdeux
zeusdeux / googleHurdleHack.js
Created October 6, 2012 23:04
A google hurdle hack that lets you get a time of 0.1s
/**************************************************************
Author: Mudit Ameta
Date : 9Aug12
Link : http://experiments.muditameta.com/googleHurdleHack/
***************************************************************/
(function () {
var game = document.getElementById('hplogo');
var leftDown = document.createEvent("Event");
leftDown.initEvent("keydown", true, true);
leftDown.keyCode = 37;
@zeusdeux
zeusdeux / tdz-1.js
Created October 13, 2015 18:42 — forked from rwaldron/tdz-1.js
Temporal Dead Zone
{
// The block has begun, we're in a new block scope. The TDZ for the "a" binding has begun
var f = function() {
// 2. Because f() is evaluated before `a` is actually declared,
// an exception will be thrown indicating to the author that
// `a` is not yet defined.
console.log(a);
};
@zeusdeux
zeusdeux / slim-redux.js
Created October 20, 2015 06:52 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {