Skip to content

Instantly share code, notes, and snippets.

View jonsterling's full-sized avatar

Jon Sterling jonsterling

View GitHub Profile
@jonsterling
jonsterling / Coinduction.hs
Created October 13, 2012 22:46
Idea for codata syntax in Haskell
-- Inspired by http://www2.tcs.ifi.lmu.de/~abel/popl13.pdf
[codata|
codata Stream a where
head :: Stream a -> a
tail :: Stream a -> Stream a
|]
fib :: Stream Nat
[copattern|
@jonsterling
jonsterling / gist:3851205
Created October 8, 2012 07:33
Attic Greek Exercise 12.B.3

ἔγωγε δὲ φοβοῦμαι, ὦ ἄνδρες, μὴ ἂν εἴη καὶ Δημοσθένης τις ἀδύνατος εἰπεῖν τὴν τῶν ἀδικημάτων δεινότην τῶν τρίακοντα· οὐ γὰρ μόνον ἀπέκτειναν τοὺς ἀναιτίους ὧντινων αἱρήσονται τὰ χρήματα, ἀλλὰ καὶ εἰς τοσοῦτον ἧκον αἰτίας ὥστε προὔδωκαν τοὺς τε φίλους καὶ τοὺς προσήκοντας θᾶττον ἢ τοὺς ἔχθρους. τοσαύτη γὰρ οὖν ἡ μοχθηρία τούτων ὥστε διήρπασάν ποτε οἱ τριάκοντα καὶ τοὺς σφετέρους.

I am afraid that even a Demosthenes would be unable to express the heinousness of the crimes of the Thirty. Not only did they kill the innocent in order to take their money, but they reached such a level of criminal behavior that they betrayed their own friends and relations even more quickly than their enemies. In fact, their corruption was so extensive that the Thirty began to prey upon their own members.

(To be clear, I composed the Greek from the English. Not the other way around.)

// Which of these do you find easier to scan?
// This is what I imagine you would prefer. No single-char variable
// names. The purpose of every variable is described to the best of my
// ability, though many parameters are just that: parameters.
implicit def KleisliCategory[MonadParam[_]: Monad]:
Category[({type TypeConstructor[FirstParam,
SecondParam] = Kleisli[MonadParam, FirstParam,
SecondParam])#TypeConstructor] = new Category[({type
@jonsterling
jonsterling / Tasky.py
Created August 19, 2012 01:23
A very simple curses-style TaskWarrior client
#!/usr/bin/python
# -*- coding: latin-1 -*-
import urwid
import json
import subprocess
class TaskWarrior(object):
def pending_tasks(self):
@jonsterling
jonsterling / Solarized.hs
Created July 29, 2012 20:00
A quick & dirty script to toggle Solarized theme variants
module Main where
import System.FilePath
import System.Process
import System.Exit
import System.Environment
import Control.Applicative
import Control.Monad.Identity
@jonsterling
jonsterling / IBAForms.podspec
Created June 16, 2012 03:24 — forked from jk/IBAForms.podspec
Podspec for IBAForms
Pod::Spec.new do |s|
s.summary = 'A simple iPhone forms library'
s.license = 'Apache License, Version 2.0'
s.source = { :git => 'https://github.com/yardsale/IBAForms.git', :tag => '1.1.0' }
s.source_files = 'library/**/*.{h,m}'
s.author = { 'Itty Bitty Apps' => '[email protected]' }
s.version = '1.0.0'
s.homepage = 'https://github.com/ittybittydude/IBAForms'
s.name = 'IBAForms'
s.platform = :ios
@jonsterling
jonsterling / Example.m
Created May 13, 2012 02:55
Safe keypaths without macros!
NSString *safe = self.keys.url.port.stringValue;
NSString *unsafe = @"url.port.stringValue";
assert([safe isEqualToString:unsafe]);
@jonsterling
jonsterling / Output.h
Created February 15, 2012 15:53
Algebraic Data Types in C: Example Output
// This is the output of my ADT preprocessor
struct Expr {
enum {Plus,Times,Inc,Dec} tag;
union {
struct {
int l;
int r;
} Plus;
struct {
@jonsterling
jonsterling / gist:1541947
Created December 30, 2011 23:09
Configuring UITableViews with C99 array initialization!
// Define your table view's sections
typedef enum {
kTitleSection = 0,
kGoalSection,
kNumberOfSections
} NESTemplateEditTableSections;
// Make configuration arrays indexed against table sections.
// It's safe to reorder the original enum!
static NSString * const kCellIdentifiers[kNumberOfSections] = {
@jonsterling
jonsterling / gist:1117345
Created July 31, 2011 23:30
Feeds I like