Skip to content

Instantly share code, notes, and snippets.

romaonthego / NSDateFormatter cheat sheet
Last active Apr 13, 2021
Date Formats for NSDateFormatter
View NSDateFormatter cheat sheet
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
romaonthego / genpassword
Created Feb 11, 2011
Bash script: genpassword
View genpassword
charspool=('a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p'
'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' '0' '1' '2' '3' '4' '5' '6' '7'
'8' '9' '0' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '-' '_');
if [ $# -lt 1 ]; then
romaonthego / htmltest.m
Created Sep 23, 2013
UITextView with HTML text (iOS 7)
View htmltest.m
- (void)viewDidLoad
[super viewDidLoad];
UITextView *textView = [[UITextView alloc] init];
textView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:textView];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]];
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src='' width=70 height=100 />";



To create a method to persist and re-instantiate Mantle MTLModel objects to NSUbiquitousKeyValueStore (iCloud key-value store).


NSUbiquitousKeyValueStore can only store values of class NSNumber, NSString, NSDate, NSData, NSArray, and NSDictionary ("plist types"). The MTLNSUbiquitousKeyValueStore category on MTLModel has been designed to create an NSDictionary representation of a model object in a deeply recursive way, making it suitable for storage in an NSUbiquitousKeyValueStore.

View gist:6942007
typedef enum _UIBackgroundStyle {
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)
romaonthego / kill.rb
Created Dec 9, 2015 — forked from timonus/kill.rb
Deletes all yer iOS simulators
View kill.rb
#!/usr/bin/env ruby
device_types_output = `xcrun simctl list devicetypes`
device_types = device_types_output.scan /(.*) \((.*)\)/
runtimes_output = `xcrun simctl list runtimes`
runtimes = runtimes_output.scan /(.*) \(.*\) \(([^)]+)\)$/
devices_output = `xcrun simctl list devices`
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/
View Closure.swift
self.errorView = {
let view = UIView()
view.backgroundColor = UIColor.redColor()
self.errorLabel = {
let label = UILabel()
label.textAlignment = .Center
label.backgroundColor = UIColor.clearColor()
return label
romaonthego / gist:859697
Created Mar 8, 2011
Local IP on Debian/Ubuntu
View gist:859697
ifconfig|grep 'inet addr'|awk '{print $2}'|sed 's/addr://g'
romaonthego / gist:823233
Created Feb 11, 2011
Remove .DS_Store (Mac OS X)
View gist:823233
sudo find /WebServers -name ".DS_Store" -depth -exec rm {} \;
View MusicPlayer.m
MPMusicPlayerController *controller = [MPMusicPlayerController iPodMusicPlayer];
MPMediaPropertyPredicate *artistPredicate = [MPMediaPropertyPredicate predicateWithValue:@"The Killers"
MPMediaQuery *query = [[MPMediaQuery alloc] initWithFilterPredicates:[NSSet setWithArray:@[artistPredicate]]];
for (MPMediaItem *song in query.items) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];