View 0_reuse_code.js
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
View Bus.hs
module Bus where | |
import Data.List (find, intercalate) | |
data BuildStatus = AllGreen | |
| Borken | |
deriving (Eq, Show) | |
data Brogrammer = Johnny | |
| Arthur |
View ActiveSupport2iOS_Timezones.plist
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Information</key> | |
<dict> | |
<key>Description</key> | |
<string>Map Rails ActiveSupport timezones to iOS readable timezone IDs.</string> | |
<key>Version</key> | |
<string>1.0</string> |
View ActiveRecord2iOS_Timezones.plist
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Information</key> | |
<dict> | |
<key>Description</key> | |
<string>Map Rails ActiveSupport timezones to iOS readable timezone IDs.</string> | |
<key>Version</key> | |
<string>1.0</string> |
View base_report_aggregator.rb
def recurse_grouping(grouping, by, f, grouped_values = {}) | |
key = by.shift | |
grouping.map do |name,group| | |
grouped_values[key] = name | |
if by.empty? | |
data = group.data.first.to_hash.merge(grouped_values) | |
f.call(group, data) | |
else | |
recurse_grouping(grouping / name, by.dup, f, grouped_values.dup) | |
end |
View template.coffee
# inspired by this post: | |
# http://mir.aculo.us/2011/03/09/little-helpers-a-tweet-sized-javascript-templating-engine/ | |
t = (s,d) -> | |
f = (p,c) -> p.replace new RegExp("{{#{c}}}", 'g'), d[c] | |
(Object.keys d).reduce f,s | |
# --- | |
# usage examples |
View zipkit-example.m
- (void)inflateArchive { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSString *archivePath = [self archivePath]; | |
ZKFileArchive *archive = [ZKFileArchive archiveWithArchivePath:archivePath]; | |
[archive setDelegate:self]; | |
[self setArchiveSize:[[[archive centralDirectory] valueForKeyPath:@"@sum.uncompressedSize"] unsignedLongValue]]; | |
[archive inflateToDiskUsingResourceFork:NO]; | |
// do something with inflated archive. |
View forms.py
class EditUserForm(forms.ModelForm): | |
class Meta: | |
model = User | |
fields = ('first_name', 'last_name', 'email',) | |
class EditProfileForm(forms.ModelForm): | |
def __init__(self, *args, **kwargs): | |
super(EditProfileForm, self).__init__(*args, **kwargs) | |
profile = kwargs.get('instance') |