Skip to content

Instantly share code, notes, and snippets.

@ih2502mk
ih2502mk / gist:16d3a3ac506e413c2a0c
Created September 22, 2014 15:53
Oneliner for getting parameters out of location.search
location.search
.slice(1)
.split('&')
.map(function(part) {return part.split('=')})
.reduce(function(acc, pair) {acc[pair[0]] = pair[1]; return acc}, {});
@ih2502mk
ih2502mk / tabular-JSON.md
Last active August 29, 2015 14:05
An idea for sending tabular data with less overhead both on amount of stuff to send and on amount of stuff to convert.

Tabular JSON

A transfer format that is a valid json but looks a lot like CSV and does not have overhead of sending repetitive parameter names.

{
  header: ["id", "username", "first_name", "last_name" ],
  data: [
    [1, "jsmith", "John", "Smith"],
@ih2502mk
ih2502mk / index.js
Last active August 29, 2015 14:05
requirebin sketch
var mercury = require("mercury")
var h = mercury.h
var nextTick = require('next-tick')
var cuid = require('cuid')
var events = {
addItem: mercury.input()
};
var state = mercury.struct({
@ih2502mk
ih2502mk / keybase.md
Created July 31, 2014 21:42
keybase.md

Keybase proof

I hereby claim:

  • I am ih2502mk on github.
  • I am ih2502mk (https://keybase.io/ih2502mk) on keybase.
  • I have a public key whose fingerprint is 56BB 0B57 B531 F848 990D 52C2 C672 856D E2B7 AFF7

To claim this, I am signing this object:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@ih2502mk
ih2502mk / gist:9233574
Created February 26, 2014 16:56
Curl command to get Github Auth token
curl -u <username> \
-d '{"scopes":["public_repo"],"note":"CI: demosite"}' \
https://api.github.com/authorizations
# See https://developer.github.com/v3/oauth/ for help on post data json
@ih2502mk
ih2502mk / gist:8284176
Created January 6, 2014 15:12
Javascript prototypal inheritance.
var __extends = function (child, parent) {
for (var p in parent) {
if (Object.prototype.hasOwnProperty.call(parent, p)) {
child[p] = parent[p];
}
}
function __() {
this.constructor = child;
}
@ih2502mk
ih2502mk / url_key_value
Created November 20, 2012 15:35
adding key_value params to url
var key_value = [
"paam_1=value_1",
"paam_2=value_2",
"paam_3=value_3",
"paam_4=value_4",
]
url.indexOf("?") == -1 ? "?" : "&") + key_value.join("&");
@ih2502mk
ih2502mk / .bashrc
Created November 5, 2012 16:08
current git br in command line
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
BLUE="\[\033[0;36m\]"
DARK_BLUE="\[\033[1;34m\]"
RED="\[\033[0;31m\]"
DARK_RED="\[\033[1;31m\]"
YELLOW="\[\033[0;33m\]"