Skip to content

Instantly share code, notes, and snippets.

View fousa's full-sized avatar

Jelle Vandebeeck fousa

View GitHub Profile
@fousa
fousa / content.m
Created July 18, 2012 19:01
AFNetworking Reachability
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://www.apple.com"]];
[client setReachabilityStatusChangeBlock:^(BOOL isNetworkReachable) {
NSLog(@"Reachable %i", isNetworkReachable);
}];
@fousa
fousa / content.rb
Created July 18, 2012 09:22
Nested Resource Routes
resources :zones do
resources :users, :module => "zones"
end
@fousa
fousa / content.rb
Created July 18, 2012 09:22
Dynamic Role Methods
self.roles.each do |r|
define_method "#{r}?" do
role == r
end
end
@fousa
fousa / content.rb
Created July 17, 2012 06:38
Generate Hash Ruby
SecureRandom.base64(5).tr('+/=lIO0', 'pqrsxyz')
@fousa
fousa / AppDelegate.m
Created July 16, 2012 19:19
NSService
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[NSApp setServicesProvider:[MyService new]];
...
@fousa
fousa / content
Created July 16, 2012 16:27
Dump PSQL
pg_dump databas > dump.sql
UserInterfaceState.xcuserstate
car-sharing-ios.xcodeproj/project.xcworkspace/xcuserdata/fousa.xcuserdatad/UserInterfaceState.xcuserstate
@fousa
fousa / content.rb
Created July 12, 2012 15:09
Devise Generate Token
Devise.friendly_token
@fousa
fousa / content.css
Created July 12, 2012 14:22
CSS3 Pulsating Ring
.ring {
border: 3px solid #999;
-webkit-border-radius: 30px;
height: 40px;
width: 40px;
position: fixed;
top: 45%;
left: 45%;
@fousa
fousa / content.m
Created July 12, 2012 10:09
GCD Singleton
+ (MyClass *)sharedInstance {
static dispatch_once_t _predicate;
static MyClass *_sharedInstance = nil;
dispatch_once(&_predicate, ^{
_sharedInstance = [self new];
});
return _sharedInstance;
}