Skip to content

Instantly share code, notes, and snippets.

View rjregenold's full-sized avatar

RJ Regenold rjregenold

  • Provider Science
  • Texas
View GitHub Profile
@rjregenold
rjregenold / 0_reuse_code.js
Created August 21, 2017 18:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
module Bus where
import Data.List (find, intercalate)
data BuildStatus = AllGreen
| Borken
deriving (Eq, Show)
data Brogrammer = Johnny
| Arthur
<?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 March 26, 2013 04:33
Map ActiveRecord timezone names to NSTimeZone names.
<?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>
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 September 22, 2011 02:26
Simple Coffeescript templating
# 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
@rjregenold
rjregenold / zipkit-example.m
Created January 9, 2011 14:27
A ZipKit example.
- (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 December 17, 2010 03:49
Django Edit Profile Form
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')