Skip to content

Instantly share code, notes, and snippets.

View benjiwheeler's full-sized avatar

Benjamin Wheeler benjiwheeler

View GitHub Profile
@benjiwheeler
benjiwheeler / memes_index.js.coffee
Last active August 29, 2015 13:56
Backbone rails correction
class Punchline.Views.MemesIndex extends Backbone.View
renderA: ->
$(@el).html("rendered A")
$(@el).html()
renderB: ->
$(@el).html("rendered B")
@el
@benjiwheeler
benjiwheeler / gitignore_global
Created May 15, 2014 16:17
gitignore_global
# copied from https://help.github.com/articles/ignoring-files
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
@benjiwheeler
benjiwheeler / MyParseUser
Last active August 29, 2015 14:02
Parse User Subclass for use with FB
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>
@interface MyParseUser : PFUser <PFSubclassing>
+ (MyParseUser *)currentUser;
+ (void)doFbLoginWithCompletion:(void ( ^ )(BOOL success, id responseOrError))handler;
+ (BOOL)ensureLinkedToFB;
+ (BOOL)isLinkedToFB;
- (NSString*)fbValueForKey:(NSString*)key;
@benjiwheeler
benjiwheeler / AppDelegate.m
Last active August 29, 2015 14:02
AppDelegate boilerplate for Parse and FB with push
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import <FacebookSDK/FacebookSDK.h>
#import "MyParseUser.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, ViewControllerEnum) {
ViewControllerEnumUnknown = 0
, ViewControllerEnumCongratulationsViewController = 1 // for example
};
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@benjiwheeler
benjiwheeler / zip2tz.csv
Last active August 13, 2017 18:42
Zip to Time Zone csv
We can't make this file beautiful and searchable because it's too large.
'00501','Holtsville','NY','America/New_York'
'00544','Holtsville','NY','America/New_York'
'01001','Agawam','MA','America/New_York'
'01002','Amherst','MA','America/New_York'
'01003','Amherst','MA','America/New_York'
'01004','Amherst','MA','America/New_York'
'01005','Barre','MA','America/New_York'
'01007','Belchertown','MA','America/New_York'
'01008','Blandford','MA','America/New_York'
'01009','Bondsville','MA','America/New_York'
@benjiwheeler
benjiwheeler / zip3_to_timezone.csv
Created July 10, 2014 02:15
Zip3 to timezone csv; accurate for most zip codes; includes daylight savings info
005 EST -5 EDT -4 NY Holtsville
010 EST -5 EDT -4 MA Agawam
011 EST -5 EDT -4 MA Indian_Orchard
012 EST -5 EDT -4 MA Adams
013 EST -5 EDT -4 MA Ashfield
014 EST -5 EDT -4 MA Ashburnham
015 EST -5 EDT -4 MA Auburn
016 EST -5 EDT -4 MA Cherry_Valley
017 EST -5 EDT -4 MA Acton
018 EST -5 EDT -4 MA Andover
@benjiwheeler
benjiwheeler / zip3 to timezone json
Created July 10, 2014 04:05
zip3 to timezone json
{
"005": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "NY", "eg_city": "Holtsville"}
,"010": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Agawam"}
,"011": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Indian_Orchard"}
,"012": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Adams"}
,"013": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Ashfield"}
,"014": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Ashburnham"}
,"015": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Auburn"}
,"016": {"std_tz": "EST", "std_utc_diff": -5, "dst_tz": "EDT", "dst_utc_diff": -4, "state": "MA", "eg_city": "Cherry_Valley"}
,"017": {"std_tz": "EST", "std_utc_diff": -5, "
@benjiwheeler
benjiwheeler / parsecloudcode.js
Created July 12, 2014 19:51
Parse cloud code example
drizzle_parse_cloud / cloud / main.js
// ************************* libraries ***********************************
var _ = require('underscore');
var moment = require('moment');
//var moment = require('moment-timezone');
var MAX_ALERT_LENGTH = 110;
var TARGET_TIME_OF_DAY_SEC = 7 * 3600; // 7 am
var TIME_OF_DAY_ABS_DIFF_LIMIT = 40 * 60; // within 40 mins
@benjiwheeler
benjiwheeler / groups_controller_test.rb
Last active January 19, 2018 14:06
Example of Test::Unit code from Underground rails application, using FactoryGirl to generate test objects
require 'test_helper'
class GroupsControllerTest < ActionController::TestCase
test "ok to create duplicate group through api" do
user = create(:user)
@request.env["HTTP_AUTHORIZATION"] = user.basic_auth_header("abc1234")
post :apicreate, format: :json, nickname: "hannabarbera"
assert_response :created
assert_not_nil assigns(:group)