I hereby claim:
- I am stevegraham on github.
- I am sg (https://keybase.io/sg) on keybase.
- I have a public key whose fingerprint is DB6D 0AB8 BEA8 3D90 E1FC B5A8 9E83 7DE0 28E3 4D82
To claim this, I am signing this object:
require 'net/http' | |
require 'logger' | |
require 'mechanize' | |
logger = Logger.new(STDOUT) | |
req = Net::HTTP::Get.new '/' | |
drop_time = Time.local 2014, 12, 19, 12 | |
req['User-Agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10" |
require 'sneakers/runner' | |
task :environment | |
namespace :sneakers do | |
desc "Start processing jobs with all workers" | |
task :work => :environment do | |
silence_warnings do | |
Rails.application.eager_load! unless Rails.application.config.eager_load | |
end |
module PaymentGatewayCheck | |
@available = nil | |
MUTEX = Mutex.new | |
TASK = PeriodicTask.new(every: 5.seconds, run_immediately: !Rails.env.test?) do | |
begin | |
result = HTTParty.get ENV['PAYMENT_GATEWAY_PING_ENDPOINT'] | |
MUTEX.synchronize { @available = result.success? } | |
rescue SystemCallError | |
MUTEX.synchronize { @available = false } |
# Returns methods in the order of definition | |
FooClass.instance_methods(false) | |
=> [:methods, :excluding, :from, :superclass, :returned, :in, :the, :order, :they, :were, :defined] | |
# Returns a sorted list | |
FooClass.instance_methods - FooClass.superclass.instance_methods | |
=> [:defined, :excluding, :from, :in, :methods, :order, :returned, :superclass, :the, :they, :were] | |
# WAT |
sudo tcpdump -U -In -i en0 -s 2048 -A dst i.instagram.com | ack -o "(?<=Cookie: ).+" --flush > ~/Desktop/cookies |
I hereby claim:
To claim this, I am signing this object:
Function.prototype.curry = function() { | |
var fn = this; | |
var slice = Array.prototype.slice; | |
var args = slice.call(arguments); | |
return function() { | |
return fn.apply(this, args.concat(slice.call(arguments))); | |
} | |
} |
// Cannot init an NSManagedObject. Have to insert into an NSManagedObjectContext instance. | |
NSManagedObjectSubclass * scratchObj = [NSEntityDescription insertNewObjectForEntityForName:@"Foo" | |
inManagedObjectContext:AppDelegate.managedObjectContext]; | |
// Set the properties on our object, e.g. via UITextField IBOutlets | |
scratchObj.foo = @"foo"; | |
// Post the object. Assume use of an RKMapping here. | |
[[RKObjectManager sharedManager] postObject:scratchObj path:nil parameters:nil | |
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { |
// | |
// NSString+Inflections.m | |
// Zap | |
// | |
// Created by Stevie Graham on 28/10/2013. | |
// | |
#import "NSString+Inflections.h" | |
@implementation NSString (Inflections) |
NSString * const kAPIEndpoint = @"http://127.0.0.1:3000/"; | |
void SwizzleInstanceMethod(Class class, SEL dstSel, SEL srcSel) { | |
Method dstMethod = class_getInstanceMethod(class, dstSel); | |
Method srcMethod = class_getInstanceMethod(class, srcSel); | |
if (class_addMethod(class, dstSel, method_getImplementation(srcMethod), method_getTypeEncoding(srcMethod))) { | |
class_replaceMethod(class, dstSel, method_getImplementation(dstMethod), method_getTypeEncoding(dstMethod)); | |
} else { | |
method_exchangeImplementations(dstMethod, srcMethod); |