Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
@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: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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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();
@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 / 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 / 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 / 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:e301c33686f995940d32
Created December 18, 2015 06:39
ios tableview basic boilerplate
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSMutableArray *data;
@end
@tlkahn
tlkahn / gist:59150cb4e062a8e5c29d
Created December 20, 2015 00:43
space lorem ipsum
/* Lorem Ipsum Generator
* (CC-BY) Fredrik Bridell <[email protected]> 2009
* Version 0.21 - multilingual
* Released under a Creative Commons Attribution License
*
* You are welcome to use, share, modify, print, frame, or do whatever you like with this
* software, including commercial use. My only request is that you tell the world where you found it.
*
* One way is to include the phrase:
* "Using the The Lorem Ipsum Generator by Fredrik Bridell (http://bridell.com/loremipsum/)"