Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
@tlkahn
tlkahn / gists_to_dash_db.rb
Last active December 18, 2015 05:50 — forked from voising/gists_to_dash_db.rb
Connect Gists with Dash (Code Snippet Manager)
#!/usr/bin/env ruby
if ARGV[0].nil? || ARGV[0].match(/-h/)
puts "Usage : #{$0} github_username dash_sqlite_db char_appended_to_keyword [no_comments]"
exit
end
require 'net/http'
require 'open-uri'
#require 'awesome_print'
@tlkahn
tlkahn / gist:dba464882e26baf97242
Created December 18, 2015 05:26
uitableview data source
#pragma mark UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.statuses count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"STTwitterTVCellIdentifier"];
if(cell == nil) {
@tlkahn
tlkahn / 0_reuse_code.js
Created December 16, 2015 06:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tlkahn
tlkahn / option.js
Created December 12, 2015 21:06 — forked from igstan/option.js
// `unit` is `return` from Haskell
// `bind` is `>>=` from Haskell, or `flatMap` from Scala
var None = {
bind: function (fn) { return this; },
unit: function (v) { return Option(v); },
getOrElse: function (elseValue) { return elseValue; }
};
var Some = function (value) {
@tlkahn
tlkahn / maybe.traceur
Created December 12, 2015 21:01 — forked from torgeir/maybe.traceur
An es6 js maybe monad, using generators
log = console.log.bind(console);
maybe = v => {
function * f () {
if (v) yield v;
}
f.bind = f =>
v ? f(v) : maybe();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tlkahn
tlkahn / gist:0783251cf145620cd30a
Created December 11, 2015 19:27
javascript assert function
function assert(condition, message) {
if (!condition) {
message = message || "Assertion failed";
if (typeof Error !== "undefined") {
throw new Error(message);
}
throw message; // Fallback
}
}
@tlkahn
tlkahn / gist:26d114e7f1b0b4f62087
Created December 9, 2015 07:40
latex typeface font set
\usepackage[xetex]{graphicx}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont[Scale=.95]{Times}
\setmonofont{Lucida Sans Typewriter}
@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)
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)