Skip to content

Instantly share code, notes, and snippets.

View mhupman's full-sized avatar

Matthew Hupman mhupman

  • Yext
  • United States
View GitHub Profile
@mhupman
mhupman / gist:5187317
Last active December 15, 2015 02:29
NSObject+JRSwizzleBlock.[h,m]
/* NSObject+JRSwizzleBlock.h */
#import <Foundation/Foundation.h>
@interface NSObject(JRSwizzleBlock)
+ (void)swizzle:(SEL)origmethod toMethod:(SEL)newmethod forBlock:(void(^)(void))swizzledBlock;
@end
@mhupman
mhupman / gist:5187589
Last active December 15, 2015 02:29
Temporary, block-based method swizzling.
// privateBundleIdentifier is our custom implementation of bundleIdentifier in a NSBundle category
[NSBundle swizzle:@selector(bundleIdentifier) toMethod:@selector(privateBundleIdentifier) forBlock:^{
[Crashlytics startWithAPIKey:CRASHLYTICS_API_KEY];
}];
#!/bin/sh
PROJ=`find . -name '*.xib' -o -name '*.[mh]' -o -name '*.storyboard' -o -name '*.mm'`
for png in `find . -name '*.png'`
do
name=`basename -s .png $png`
name=`basename -s @2x $name`
if ! grep -q $name $PROJ; then
echo "$png"
fi
class User < ActiveRecord::Base
attr_accessible :username, :password
attr_accessor :password
def password=(password)
self.password_salt = "salty"
self.password_hash = "#{password}#{self.password_salt}"
end
end
User = describe 'User', ->
property 'username', String
property 'password_hash', String
property 'password_salt', String
set 'restPath', pathTo.users
# One-liner to check if repo directory exists. If so, attempt to enter and `git pull`. Otherwise, `git clone`
if [ -d citrrusbuilder ]; then cd citrrusbuilder && git pull && cd ..; else git clone git@bitbucket.org:citrrus/citrrusbuilder.git citrrusbuilder; fi
@mhupman
mhupman / gist:7896390
Created December 10, 2013 19:14
mybryan
RAC(self, isSomethingEnabled, @(YES)/*default value i'm refering to*/) = RACObserve(self, someOtherDangle);
@mhupman
mhupman / gist:8584839
Last active January 4, 2016 06:49
citrrus email signature
<div>
<div>
<br />
</div>
<!-- Leave this out for gmail -->
<!-- <p style="background-color: rgb(255, 255, 255); margin: 0px;"><font color="#999999" style="font-family: arial, sans-serif;">----------------------------------------------------------------------------------------------</font></p> -->
<div style="color: rgb(34, 34, 34); font-family: arial, sans-serif;">
<br />
@mhupman
mhupman / crash report
Created February 26, 2014 18:31
Socialcast iOS App Crash Report
Feb 26 13:26:35 Mhupmans-iPhone-5s Socialcast[2825] <Error>: -[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance 0x39976a60
Feb 26 13:26:35 Mhupmans-iPhone-5s Socialcast[2825] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance 0x39976a60'
*** First throw call stack:
(0x2ee6de83 0x391ce6c7 0x2ee717b7 0x2ee700af 0x2edbedc8 0x156f47 0x1569a7 0x155f6d 0x1579e7 0x1581b1 0xd9b41 0x15b2c7 0x2ee2fe71 0x2eda3ab1 0x2f7a200d 0x2f7a59c5 0x130a8b 0xd8dbd 0xc50d7 0x396b30c3 0x396b30af 0x396b59a9 0x2ee385b1 0x2ee36e7d 0x2eda1471 0x2eda1253 0x33ad52eb 0x31656845 0xba01f 0xa3da0)
Feb 26 13:26:35 Mhupmans-iPhone-5s ReportCrash[2826] <Notice>: ReportCrash acting against PID 2825
Feb 26 13:26:35 Mhupmans-iPhone-5s ReportCrash[2826] <Notice>: Formulating crash report for process Socialcast[2825]
Feb 26 13:26:35 Mhupmans-iPhone-5s com.apple.launchd[1] (UIKitApplication:com.socialcast.Social
# Let's face it. Ruby's Hash#to_s output isn't very useful.
# Here's a draft for a better version.
class Hash
def to_s
keys.inject([]) do |a, key|
a << "#{key}: #{fetch(key)}"
end.join(', ')
end
end