Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@sma
sma / basic.py
Created December 27, 2009 16:50
A simple BASIC interpreter that can run the old HAMURABI game
from __future__ import division
from math import trunc
from random import random
import re
TOKENS = re.compile(r'(?<=REM).*|\.?\d+|\w+\$?|[():;=+\-*/]|<[=>]?|>=?|"[^"]*"')
class Basic(object):
def __init__(self, filename):
self.tokens = []
@chrisyour
chrisyour / Folder Preferences
Created December 4, 2010 20:05
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@asmallteapot
asmallteapot / README.mdown
Created April 19, 2011 16:38
Naïve fuzzy–matching of NSStrings.

Simple fuzzy–matching of NSStrings, ignoring case, diacritics, and position in the string being searched. Based on a blog post by @rwenderlich, Apple’s documentation, and banging my keyboard until it works.

@mikelikespie
mikelikespie / CCBlockTableViewDataSource.h
Created May 4, 2011 18:55 — forked from omnivector/CCBlockTableViewDataSource.h
Block based data source / delegate
//
// CCBlockTableViewDataSource.h
//
// Created by Tristan O'Tierney on 1/24/11.
//
#import <UIKit/UIKit.h>
@interface CCBlockTableViewDataSource : NSObject <UITableViewDataSource, UITableViewDelegate> {
anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@cdcarter
cdcarter / form_helper.rb
Created June 4, 2011 02:52
NS Form Helper Class
class FormHelper
attr_accessor :form
def initialize(nsform=nil)
@form = nsform
end
def length
form.numberOfRows
end
@sj26
sj26 / application.rb
Created June 7, 2011 01:14
Rails 3.1 compass initializer
config.generators.stylesheet_engine = :sass
@gstark
gstark / gist:1040098
Created June 22, 2011 13:35
Difference between scope of block yield variable between for-in and Enumerable#each
array = [1,2,3,4]
array.each do |array_iter|
# do something with array_iter
end
# Hmm, array_iter isn't defined
puts defined?(array_iter)
for for_iter in array do
@ldandersen
ldandersen / great-circle-cocoa.m
Created September 6, 2011 22:40
Great circle distance in Cocoa
static NSInteger STEarthRadiusKilometers = 6371;
- (NSNumber *)distanceFromLatitude:(NSDecimalNumber *)inLatitude longitude:(NSDecimalNumber *)inLongitude;
{
CLLocationDegrees inLatitudeDegrees = [inLatitude doubleValue];
CLLocationDegrees latitudeDegrees = [self.latitude doubleValue];
CLLocationDegrees inLongitudeDegrees = [inLongitude doubleValue];
CLLocationDegrees longitudeDegrees = [self.longitude doubleValue];
double distance = acos(sin(inLatitudeDegrees) * sin(latitudeDegrees) + cos(inLatitudeDegrees) * cos(latitudeDegrees) * cos(longitudeDegrees - inLongitudeDegrees)) * STEarthRadiusKilometers;