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 / objToArray.js
Last active August 29, 2015 14:08
Convert arbitrary js objects into an array of array of array and so on while keeping the keys close to their values
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
function objToArray(obj){
if (!isObject(obj) || Array.isArray(obj)) throw new SyntaxError('Give me an object to work with plz. kthxbai.');
return output = Object.keys(obj).map(function(key){
var temp = [];
temp.push(key);
if (isObject(obj[key]) && !Array.isArray(obj[key])) temp.push(objToArray(obj[key]));
else temp.push(obj[key]);
@zeusdeux
zeusdeux / thunkify.js
Created December 22, 2014 13:19
Didjoo even thunk that woulda happnd?
function thunkify(fn) {
return function() {
return fn.apply(this, arguments);
}
}
@zeusdeux
zeusdeux / Flamegraph_osx.md
Last active February 14, 2025 20:23
Node.js flamegraphs on osx using instruments.app, node and http://thlorenz.github.io/flamegraph/web/

Flamegraphs for your node processes on OS X

This document will help you generate flamegraphs for your node processes on OS X.

You can read about the various types of flamegraphs and how they are useful
in Brendan Gregg's wonderful write up here.

By the end of this document, you should have a flamegraph for you node app to play with.

@zeusdeux
zeusdeux / prelude-generators.js
Last active May 4, 2018 14:25
Iterable higher order functions so that they play well with comprehensions
Number.prototype[Symbol.iterator] = function* (startIdx = 0) {
const endIdx = this.valueOf()
let i = startIdx
while (i < endIdx) {
yield i++
}
}
//console.log([...8]); // [0,1,2,3,4,5,6,7]
@zeusdeux
zeusdeux / Boop.md
Last active August 29, 2015 14:17
Todo at hacker school

Stuff to work on at Hacker School

Broadly:

  • Interpreters
    • one for scheme as a gateway drug into the land of interpreters
    • one for my own interpreted language
  • Compilers
    • one for my own compiled language
  • Languages to move from play -> work
@zeusdeux
zeusdeux / Syntax
Last active August 29, 2015 14:18
RC LANG
// sugared fib is below
fib n
let one = 1
if n == 0
then
one
else
if n == 1
then
one
@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:

@zeusdeux
zeusdeux / socketio.md
Last active March 18, 2020 22:51
Vanilla websockets vs socket.io

Vanilla websockets vs socket.io

Note: The points below are a comparison of using vanilla websockets on client and server and using 'em via socket.io and not about why only use socket.io

  • Native websockets provide us with only a send method to send data to the server. Send accepts only string input (not too sure about this). Socket.io lets us emit arbitrary events with arbitrary data (even binary blobs) to the server.
  • To receive messages on a vanilla websocket you can only assign a handler for the message event. The data you receive is mostly likely to be text (again not too sure about this) and you will have to parse it manually before consuming it. Socket.io lets the server and client both emit arbitrary events and handles all the parsing and packing/unpacking.
  • Socket.io gives us both a server and a client. Implementing a vanilla websocket server isn't something that you would want to do per project since it's quite painful. You will have to implement [RFC6455](https://tools.ietf.org/h

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