Skip to content

Instantly share code, notes, and snippets.

RJ Regenold rjregenold

Block or report user

Report or block rjregenold

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rjregenold
rjregenold / 0_reuse_code.js
Created Aug 21, 2017
Here are some things you can do with Gists in GistBox.
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>
@rjregenold
rjregenold / ActiveRecord2iOS_Timezones.plist
Created Mar 26, 2013
Map ActiveRecord timezone names to NSTimeZone names.
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
@rjregenold
rjregenold / template.coffee
Created Sep 22, 2011
Simple Coffeescript templating
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.
@rjregenold
rjregenold / forms.py
Created Dec 17, 2010
Django Edit Profile Form
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')
You can’t perform that action at this time.