Skip to content

Instantly share code, notes, and snippets.

View lukewar's full-sized avatar

Lukasz Warchol lukewar

View GitHub Profile
@lukewar
lukewar / ruby-hash-new
Created April 27, 2022 08:13
Ruby Hash.new with default value
Hash.new { |h, k| h[k] = [] }

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@lukewar
lukewar / file-header.regex
Last active October 15, 2018 22:15
Remove file header comment
Xcode
((.|\n)*) Created by .*$
Appcode:
(.|\n)* Copyright

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:

grep -r advertisingIdentifier .
openssl pkcs12 -in cert.p12 -out cert.pem -nodes
-nodes - option if you want to export the private key unencrypted (plaintext):
- 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`
@lukewar
lukewar / Stringify macro
Created August 21, 2015 14:12
Generate string of argument
#define STRINGIFY(k) (@#k)
@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 / 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;