Skip to content

Instantly share code, notes, and snippets.

View fousa's full-sized avatar

Jelle Vandebeeck fousa

View GitHub Profile
@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
@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;
}
@fousa
fousa / content.m
Created July 12, 2012 10:08
GCD Date Formatter
static NSDateFormatter *dateFormatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
});
return [dateFormatter dateFromString:self];
@fousa
fousa / content.m
Created July 12, 2012 10:06
Static Date Formatter
static NSDateFormatter *railsFormatter = nil;
if (railsFormatter == nil) {
railsFormatter = [[NSDateFormatter alloc] init];
[railsFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
}
return [railsFormatter stringFromDate:self];
@fousa
fousa / gist:3093256
Created July 11, 2012 20:43
Lion Library
chflags nohidden ~/Library/