Skip to content

Instantly share code, notes, and snippets.

View lukewar's full-sized avatar

Lukasz Warchol lukewar

View GitHub Profile
@lukewar
lukewar / xcode-test
Created July 5, 2014 09:29
Running specs from command line.
xcodebuild test -workspace <>.xcworkspace -scheme <> -destination "platform=iOS Simulator,name=iPhone Retina (4-inch),OS=7.1
@lukewar
lukewar / block asynchronous
Last active August 29, 2015 14:10
Blocking asynchronous operation.
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
dispatch_group_t dispatchGroup = dispatch_group_create();
dispatch_group_enter(dispatchGroup);
[task runWithCompletion:^{
dispatch_group_leave(dispatchGroup);
}];
dispatch_group_wait(dispatchGroup, DISPATCH_TIME_FOREVER);
}];
@lukewar
lukewar / gist:80c44c7e440bd6458786
Created December 11, 2014 16:34
Inset free table view separator
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[tableView setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
@lukewar
lukewar / ISO8601-date-formatter
Last active August 29, 2015 14:14
ISO8601 parsing
#include <time.h>
// Source http://blog.soff.es/how-to-drastically-improve-your-app-with-an-afternoon-and-instruments/
+ (NSDate *)dateFromISO8601String:(NSString *)string {
if (!string) {
return nil;
}
struct tm tm;
@lukewar
lukewar / gcd watchdog
Created April 9, 2015 19:46
Implementation of watchdog using GCD
CGFloat timeout = 2;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(_timer, dispatch_time(DISPATCH_TIME_NOW, timeout * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, 0);
dispatch_source_set_event_handler(_timer, ^{
// custom code
dispatch_source_cancel(_timer);
@lukewar
lukewar / Stringify macro
Created August 21, 2015 14:12
Generate string of argument
#define STRINGIFY(k) (@#k)
- make sure you specified 'binary_basename' or 'binary_file'
- make sure your project has coverage enabled
- make sure that configuration you're using to gather coverage has *Build Active Architecture Only* `ONLY_ACTIVE_ARCH` set to `YES`
openssl pkcs12 -in cert.p12 -out cert.pem -nodes
-nodes - option if you want to export the private key unencrypted (plaintext):
grep -r advertisingIdentifier .

Keybase proof

I hereby claim:

  • I am lukewar on github.
  • I am lukewar (https://keybase.io/lukewar) on keybase.
  • I have a public key ASDI7f_Cs2zIpbUjgSZdgiEplHaq0l99a0rf9XvIazty1Ao

To claim this, I am signing this object: