Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Wheeler benjiwheeler

View GitHub Profile
@benjiwheeler
benjiwheeler / memes_index.js.coffee
Last active Aug 29, 2015
Backbone rails correction
View memes_index.js.coffee
class Punchline.Views.MemesIndex extends Backbone.View
renderA: ->
$(@el).html("rendered A")
$(@el).html()
renderB: ->
$(@el).html("rendered B")
@el
View gitignore_global
# copied from https://help.github.com/articles/ignoring-files
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
View AppDelegate.h
#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 / MyParseUser
Last active Aug 29, 2015
Parse User Subclass for use with FB
View MyParseUser
#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 Aug 29, 2015
AppDelegate boilerplate for Parse and FB with push
View AppDelegate.m
#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];
@benjiwheeler
benjiwheeler / zip3_to_timezone.csv
Created Jul 10, 2014
Zip3 to timezone csv; accurate for most zip codes; includes daylight savings info
View zip3_to_timezone.csv
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
View 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 Jul 12, 2014
Parse cloud code example
View parsecloudcode.js
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 / quality.rb
Created Dec 9, 2014
recursive quality scoring class that allows for arbitrary scoring methods and cycles of dependency
View quality.rb
class Quality < ActiveRecord::Base
belongs_to :measureable, :polymorphic => true, :inverse_of => :qualities
# translates a raw value to a log scale, using expected mean and halflife.
# eg, suppose we're scoring the relative reliability of something based on its age.
# if 10 days is halflife, and expected mean is 2 days, the raw values and log values will be:
# raw value | log value
# --------------------------
# 0 days | -.17
# 1 day | -.09
@benjiwheeler
benjiwheeler / circle.yml
Created Jan 4, 2015
Canonical circle.yml
View circle.yml
general:
build_dir: .
machine:
environment:
RAILS_ENV: "test"
RACK_ENV: "test"
# note: DON'T need to have heroku: section anywhere because we use --app heroku commands.