Skip to content

Instantly share code, notes, and snippets.

View carljparker's full-sized avatar

Carl Parker carljparker

View GitHub Profile
@carljparker
carljparker / hack.sh
Created July 3, 2022 19:52 — forked from e11s/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/3178087/hack.sh | sh
#
@carljparker
carljparker / NSDateFormatter.m
Last active August 27, 2015 18:21
NSDateFormatter Singleton
static NSDateFormatter *formatter = nil;
static dispatch_once_t onceToken;
dispatch_once( &onceToken, ^{
formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
});
@carljparker
carljparker / save-image.m
Last active August 29, 2015 14:26
iOS: Save an image file to the Documents directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.jpg"]; //Add the file name
[((Image *)obj).scaledImage writeToFile:filePath atomically:YES]; //Write the file
//
// retrieve the image
//
NSData *pngData = [NSData dataWithContentsOfFile:filePath];
UIImage *image = [UIImage imageWithData:pngData];
@carljparker
carljparker / load-image.m
Last active August 29, 2015 14:25
Objective-C: Load an Image from the App Bundle
UIImage * imageToScale = [UIImage imageNamed:@"desktop-image"];
@carljparker
carljparker / ViewControllerFromSBID.m
Last active August 29, 2015 14:22
Instantiate View Controller with Storyboard ID
//
// The type of relationship you establish determines when a connected
// view controller is instantiated by iOS, as follows:
//
// - If the relationship is a segue, the destination view controller is
// instantiated when the segue is triggered.
//
// - If the relationship represents containment, the child view
// controller is instantiated when its parent is instantiated.
//
@carljparker
carljparker / change-initial-vc-at-startup
Last active August 29, 2015 14:22
Change Initial View Controller at App Startup
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog( @"Window: %@", self.window.rootViewController );
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"MapKitNavigationController"];
{
ami: "amazon machine image",
dopt: "dhcp options set",
eni: "elastic IP address",
i: "instance",
igw: "internet gateway",
vol: "ebs volume",
vpc: "virtual private cloud"
}
@carljparker
carljparker / _vimrc
Created March 22, 2012 17:53
Carl's _vimrc (Windows 7)
"
" Never commit this file until you have had a chance to at least run vim with
" your changes, and preferably actually had a chance to test the changes
" themselves. There have been multiple time (at least three) when vim wouldn't
" even start correctly because of changes to my _vimrc configuration.
"
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
@carljparker
carljparker / gist:1314135
Last active September 27, 2015 18:38
F# Sample Code
//
// Learn more about F# at http://fsharp.net
//
open System;
open System.IO;
printfn "\n";