Skip to content

Instantly share code, notes, and snippets.

View hezi's full-sized avatar

Jorge (Hezi) Cohen hezi

View GitHub Profile
@yosefw
yosefw / static_footer
Last active August 29, 2015 14:09
Static footer that sticks to the bottom, regardless of content height. Based on http://mystrd.at/modern-clean-css-sticky-footer/
anonymous
anonymous / gist:2767637
Created May 22, 2012 08:39
Wiggling Animation
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[animation setToValue:[NSNumber numberWithFloat:-M_PI/128]];
[animation setFromValue:[NSNumber numberWithDouble:M_PI/128]];
[animation setDuration:0.09];
[animation setRepeatCount:NSUIntegerMax];
[animation setAutoreverses:YES];
@furf
furf / User.js
Created June 15, 2012 20:14
Use everyauth authentication via JSON REST API only
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
Promise = mongoose.Promise,
mongooseAuth = require('mongoose-auth'),
UserSchema = new Schema({}, { strict: true }),
User;
UserSchema.plugin(mongooseAuth, {
@lukeredpath
lukeredpath / Gemfile
Created July 11, 2012 11:53
A parser for Twitter's tweet archive dump format
gem "mongo"
gem "bson_ext"
gem "mongoid"
#import <Foundation/Foundation.h>
@interface TCMemoryDebugPrinter : NSObject
+ (Class)activateMemoryDebuggingFor:(Class)sourceClass;
@end
@lilyball
lilyball / gist:3391903
Created August 19, 2012 04:19
+[NSObject cast:]
@interface NSObject (Cast)
+ (instancetype)cast:(id)from;
@end
@implementation NSObject (Cast)
+ (instancetype)cast:(id)from {
if ([from isKindOfClass:self]) {
return from;
}
return nil;
@pajp
pajp / script.sh
Created August 26, 2012 13:18
print out oauth tokens from a process using dtrace
#!/bin/sh
/Applications/Twitter.app/Contents/MacOS/Twitter &
sudo dtrace -q -p $! -n 'pid$target::free:entry /arg0 != 0/ { printf("%s\n", copyinstr(arg0)) }' 2> /dev/null | grep oauth
@steipete
steipete / gist:4233987
Created December 7, 2012 15:32
Print a CGPath
extern void CGPathPrint(CGPathRef path, FILE* file);
CGPathPrint(path.CGPath, NULL);
Path 0xb44e380:
moveto (-12, 295)
lineto (115, 295)
lineto (108, -12)
lineto (235, -12)
@boredzo
boredzo / PRHOverlayLayer.m
Created May 9, 2013 01:31
Method that implements Python-style string formatting in NSString.
//Formats a string in which format specifiers look like %(key)@, similar to Python's %(key)s.
//Currently does not work with any other specifiers (i/d/u/x/f/g/e/s/c/C) or formatting guidance (space-padding, justification, etc.), and probably will never allow mixing positional and keyed format specifiers, just as Python doesn't.
- (NSString *) stringWithFormat:(NSString *)format values:(NSDictionary *)values {
NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"%\\(([a-z_][a-z0-9_]*)\\)@"
options:NSRegularExpressionCaseInsensitive
error:NULL];
NSMutableString *resultString = [NSMutableString stringWithCapacity:format.length
+ [[[values allValues] valueForKeyPath:@"@sum.length"] unsignedIntegerValue]];
__block NSRange rangeSinceLastMatch = { 0, 0 };
# download imagesnap [http://iharder.sourceforge.net/current/macosx/imagesnap/]
# identify your video recording device
./imagesnap -l
# repeatedly take a snapshot
while :; do ./imagesnap -d "HD Pro Webcam C920" ~/Pictures/snapshots/`date +%H-%M-%S`.jpeg; sleep 58; done
# optional: resize
# WARNING - will overrite your files