Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
@asmallteapot
asmallteapot / album.json
Created May 28, 2010 00:10
MobileMe Gallery ‘API’
// http://gallery.me.com/flpatriot/100009?webdav-method=truthget&feedfmt=json
{
"records": [
{
"viewIdentifier" : 2,
"numMovies" : 0,
"allowsVideoContent" : true,
"showMobile" : false,
"download" : false,
"path" : "http://gallery.me.com/flpatriot/100009",
@asmallteapot
asmallteapot / .profile
Created November 5, 2010 17:47
Bash config with: Colours. Homebrew. RVM + Subversion status in prompt. user@host.tld:/dir title.
# system paths & enviroment variables
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
## subversion status
svn_status() {
local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
[ "$REV" ] || return
[ "$(svn st)" ] && DIRTY=' *'
echo "[r$REV$DIRTY]"
# open a hash of FasterCSV generators
data = { :table1 => nil, :table2 => nil, :table3 => nil, :table4 => nil }
data[:table1] = FasterCSV.generate do |data[:table1]|
data[:table2] = FasterCSV.generate do |data[:table2]|
data[:table3] = FasterCSV.generate do |data[:table3]|
data[:table4] = FasterCSV.generate do |data[:table4]|
# do stuff with it
# close them, rewriting the data to CSV inside the same hash
@asmallteapot
asmallteapot / clear.rb
Created November 22, 2010 20:36
clear the console from irb
def clear
puts `clear`
end
@asmallteapot
asmallteapot / brainerd.py
Created January 24, 2011 15:42
Simple Markdown server in Python. Assumes you have Markdown files in ~/Text. Access ~/Text/Hello.mdown at http://localhost:5000/w/Hello.
#!/usr/bin/env python
# -*- coding: utf8 -*-
from flask import Flask, redirect, url_for
from markdown import markdown
import os
import re
# create the app
# TODO: load config/template from files, with fallbacks
@asmallteapot
asmallteapot / gist:883458
Created March 23, 2011 16:53
Actual code I actually just wrote.
if(!DEVICE_IS_IPAD) {
// nobody loves you
return;
}
@asmallteapot
asmallteapot / evil.m
Created March 23, 2011 17:33
Somehow, this just doesn’t seem fun…
@implementation NSObject (Evil)
- (id)init {
return nil;
}
@end
@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.

@asmallteapot
asmallteapot / CSTextCell.m
Created April 28, 2011 17:27
Trying to figure out how I’m doing cell recycling wrong.
#import <UIKit/UIKit.h>
// Including the .h and .m file together for simplicity’s sake.
// yes, this is a horrific abuse of ObjC
@interface CSTextCell : UITableViewCell {
}
+ (id)generate:(UITableView *)tableView at:(NSIndexPath *)indexPath text:(NSString *)text;
+ (NSString *)cellID;