Skip to content

Instantly share code, notes, and snippets.

View lukeredpath's full-sized avatar
🏠
Working from home

Luke Redpath lukeredpath

🏠
Working from home
View GitHub Profile
xcodebuild do |x|
x.name = "LROAuth2Client"
x.prefix = "lib"
x.build_dir = "build"
scheme :device do |t|
t.target = "#{x.name}-Device"
t.configuration = "Release"
end
LRRestyRequestMultipartFormData *multipart = [[LRRestyRequestMultipartFormData alloc] init];
[multipart addPart:^(LRRestyRequestMultipartPart *part) {
part.name = @"upload";
part.fileName = @"My holiday.jpg"
part.contentType = @"image/jpeg";
part.data = UIImageJpegRepresentation(myImage);
}];
[multipart addPart:^(LRRestyRequestMultipartPart *part) {
class SMSTester
def initialize
@number_of_sms = 0
@number_expected = 0
end
def should_have_received_message_containing
@number_expected += 1
# do something that might send an SMS
@number_of_sms_sent += # introspect this somehow?
BetaBuilder::Tasks.new do |config|
config.target = "MyApp"
config.configuration = "Adhoc"
config.deploy_to = "http://mywebsite/betas/"
end
# rake beta:build
# rake beta:package
# rake beta:deploy
@implementation UIView (extensions)
- (void)bringToFrontOfWindow
{
[[self window] bringSubviewToFront:self];
}
@end
@lukeredpath
lukeredpath / process_last_months_finance_reports.rb
Created November 15, 2010 13:28
Loop through each finance report and run it using my process_finance_report script, creating an invoice in FreeAgent.
#!/usr/bin/env ruby
SECONDS_IN_DAY = (24*60*60)
REPORT_ROOT = File.expand_path("~/Documents/Business/Accounts/iTunes Finance Reports")
# I group US and WW on the same invoice as they are both in USD
INVOICE_GROUPS = [%w{AU}, %w{CA}, %w{GB}, %w{EU}, %w{US WW}, %w{JP}]
one_month_ago = Time.now - (30 * SECONDS_IN_DAY)
# My "fetch_finance_reports" script puts reports in a sub-dir e.g. 2010-09-Aug
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_3_2
BOOL MultiTaskingIsSupported() {
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
backgroundSupported = device.multitaskingSupported;
}
return backgroundSupported;
}
#else
@lukeredpath
lukeredpath / gist:784308
Created January 18, 2011 11:35
test.md
> @lukeredpath i *always* get that black screen. i simply type my password to unlock and i have my session back!
@lukeredpath
lukeredpath / NiceTests.m
Created January 18, 2011 18:56
Keeping tests readable and fluent!
- (void)testCanPerformGetRequestToResourceAndExtractTheResponseAsAString
{
mimicGET(@"/simple/resource", andReturnBody(@"plain text response"), ^{
[client get:resourceWithPath(@"/simple/resource") delegate:self];
});
assertEventuallyThat(&lastResponse, is(responseWithStatusAndBody(200, @"plain text response")));
}
- (void)testCanPostStringToResourceAndHaveThatValueEchoedBack
- (LRRestyResponse *)get:(NSString *)urlString;
{
__block LRRestyResponse *response = nil;
[self get:urlString withBlock:^(LRRestyResponse *theResponse) {
response = [theResponse retain];
}];
while (response == nil) {
[[NSRunLoop currentRunLoop] runForTimeInterval:0.1];