Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
{
"color_scheme": "Packages/User/SublimeLinter/Oceanic - Eighties (SL).tmTheme",
"fade_fold_buttons": false,
"font_size": 10,
"highlight_line": true,
"ignored_packages":
[
],
"jshint_options":
{
(function(global) {
global.Functor = function(conf) {
Functor.types[conf.key] = {
obj: conf.obj,
fmap: conf.fmap
};
};
Functor.types = {};
@tlkahn
tlkahn / Functor.js
Created November 3, 2015 20:37 — forked from CrossEye/Functor.js
First Functor Fantasy
(function(global) {
var types = function(obj) {
throw new TypeError("fmap called on unregistered type: " + obj);
};
// inefficient as hell, but as long as there aren't too many types....
global.Functor = function(type, defs) {
var oldTypes = types;
types = function(obj) {
if (type.prototype.isPrototypeOf(obj)) {
@tlkahn
tlkahn / test.py
Created November 30, 2015 08:17
python descriptor example
class Desc(object):
def __get__(self, obj, klass):
return lambda x: x+1
class Desc2(object):
def __get__(self, obj, klass):
print "getting from Desc2"
return lambda: obj.name + " guo"
class A(object):
@tlkahn
tlkahn / gist:12013f7c3f01fa0ee63a
Created December 4, 2015 01:34
latex and mathjax sum with limits
%%latex
$\lim\limits_{x \to 1} \frac{x^2-1}{x-1}$
$\frac{\sum\limits_{s \in S}^{n} s^2}{\sum\limits_{p \in P} p^2}$
@tlkahn
tlkahn / test.py
Created December 4, 2015 02:03
python attribute descriptor example
class Desc(object):
def __get__(self, obj, klass):
return lambda x: x+1
class Desc2(object):
def __get__(self, obj, klass):
print "getting from Desc2"
return lambda: obj.name + " guo"
class A(object):
@tlkahn
tlkahn / WBSReaderSharedStyleSheet.css
Created December 6, 2015 01:24
safari read mode css
h1 {
font-size: 1.25em;
}
h2 {
font-size: 1.125em;
}
h3 {
font-size: 1.05em;
@tlkahn
tlkahn / 0.js
Created December 6, 2015 18:14 — forked from mxriverlynn/0.js
recursing a tree structure with ES6 generators
function *doStuff(){
yield 1;
yield 2;
yield *doStuff();
}
var it = doStuff();
var res;
res = it.next();
var graph = 'graph.json'
var w = 960,
h = 700,
r = 10;
var vis = d3.select(".graph")
.append("svg:svg")
.attr("width", w)
.attr("height", h)
@tlkahn
tlkahn / gist:5d86ff64d5df8510d3bf
Created December 9, 2015 00:44
python histogram frequency
r = np.random.randn(1000)
x = range(1000)
tab = pd.DataFrame({"x":x, "r": r})
count, division = np.histogram(tab['r'], bins=100)
tab['r'].hist(bins=100)