This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bus where | |
import Data.List (find, intercalate) | |
data BuildStatus = AllGreen | |
| Borken | |
deriving (Eq, Show) | |
data Brogrammer = Johnny | |
| Arthur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |