Skip to content

Instantly share code, notes, and snippets.

@LutherBaker
LutherBaker / objectivec-cheatsheet.m
Created May 26, 2014 17:00
Objective-C Cheatsheet
//
// Sharing an instance
//
+ (id)sharedInstance {
static SharedInstanceClass *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
##
## Most Audio Units install to this location:
##
cd /Library/Audio/Plug-Ins/Components
##
## Other Audio Units install to:
##
cd ~/Library/Audio/Plug-Ins/Components
@LutherBaker
LutherBaker / ios-cheatsheet.m
Last active August 29, 2015 14:01
iOS Cheatsheet
//
// AppDelegate
//
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *root = nil; // replace this line!
self.window.rootViewController = root;
[self.window makeKeyAndVisible];
return YES;
// http://stackoverflow.com/questions/13122210/dynamically-format-a-float-in-a-nsstring
int precision = 2;
NSString *whatever=[NSString stringWithFormat:@"My float: %.*f", precision,aFloat];
// Asterisk in place of 2^^ ^^^^^^^^^ int variable
@LutherBaker
LutherBaker / 1_appium.sh
Last active May 24, 2022 23:22
Appium Cheatsheet
##
## minimize 'sudo' as much as possible
##
##
## note that this file is not meant to be RUN directly
## - consider this specific file simply a list of steps to complete
## - ie: copy and paste parts of this to your command line!
##
- (NSDate *)midnightDateForDate:(NSDate *)date {
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit)
fromDate:date];
[components setHour:0];
return [calendar dateFromComponents:components];
}
@LutherBaker
LutherBaker / gcd-semaphore.m
Last active August 29, 2015 14:01
Grand Central Dispatch
// https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/MapKit/MapKit.html
// Initialize the semaphore to 0 because there are no resources yet.
dispatch_semaphore_t snapshotSem = dispatch_semaphore_create(0);
// Get a global queue (it doesn't matter which one).
dispatch_queue_t queue = dispatch_get_global_queue(myQueuePriorityLevel, 0);
// Create variables to hold return values. Use the __block modifier because these
variables will be modified inside a block.
@LutherBaker
LutherBaker / calabash-cheatsheet.sh
Last active August 29, 2015 14:00
Calabash Cheatsheet
##
## update ruby, https://github.com/sstephenson/rbenv
##
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
##
@LutherBaker
LutherBaker / frank-cheatsheet.sh
Last active August 29, 2015 14:00
Frank Cheatsheet
# install frank
$ sudo gem install frank-cucumber
# setup project
$ frank setup
$ frank build
$ frank launch
$ frank inspect
@LutherBaker
LutherBaker / ruby-cheatsheet.sh
Last active August 29, 2015 14:00
Ruby Cheatsheet
$ sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install calabash-cucumber
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0