Skip to content

Instantly share code, notes, and snippets.

View NicholasTD07's full-sized avatar

Nicholas T. NicholasTD07

  • Sydney, Australia
View GitHub Profile
@NicholasTD07
NicholasTD07 / swift-sort-by-nsdate.swift
Created July 27, 2015 04:10
Sort Swift array by NSDate
sturct Post {
let content: String
let createdAt: NSDate
}
var posts: [Post] = []
// getMorePosts -> [Post]
posts.extend(getMorePosts())

Xcode 7.0 beta 4 can not open Storyboard files - WHY I THINK XCODE HATES ME

"cant connect to iOS agent"

Possible Problems

Wrong version of icu4c

Xcode 7.0 beta 4 needs icu4c 54, but 55 is active.

@NicholasTD07
NicholasTD07 / git-workflow.md
Last active August 29, 2015 14:24
My Git Workflow

My Git Workflow

g = git

About Fine Grained Git Commits

  • Easier to tell what's changed in one line, preferbally in 50 - 72 characters
  • Easier to revert unwanted, published and shared changes by git revert
@NicholasTD07
NicholasTD07 / clean-up-ghost-devices.sh
Created July 15, 2015 07:28
Clean up ghost iOS simulators in `xcrun simctl`
#!/bin/sh
# I was having ghost devices in my iOS Simulator.
# There were multiple device for one device type, one OS.
# For example, there were at least 4-5 devices for iPhone 6, OS 8.4
# USE IT AT YOUR OWN RISK
devices=(`xcrun simctl list devices | grep -v '^[-=]' | cut -d "(" -f2 | cut -d ")" -f1`)
for device in $devices; do
@NicholasTD07
NicholasTD07 / clean-up-simulators.sh
Created July 15, 2015 04:26
Remove all unavailable iOS simulators
#!/bin/sh
# "Delete all unavailable devices."
xcrun simctl delete unavailable
@NicholasTD07
NicholasTD07 / Branch base point after release branch exist.md
Last active August 29, 2015 14:24
Swift ZHI - Development Notes

Branch base point after release branch exists

git merge-base develop release/Xcode-6.3.2-Swift-1.2

It gives the commit before develop and release/ start to differentiate.

WHY?

" For Vundle, uncomment next line
" Plugin 'Lokaltog/vim-easymotion'
" easymotion
let g:EasyMotion_smartcase = 1 " turn on case insensitive feature
let g:EasyMotion_do_mapping = 0 " disable default mappings
let g:EasyMotion_use_smartsign_us = 1 " 1 will match 1 and !
let g:EasyMotion_use_upper = 1
let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ;'
@NicholasTD07
NicholasTD07 / Argo-decode-classes.swift
Last active August 29, 2015 14:22
Argo doesn't work with subclass (Swift 1.2 AND 2.0)
import XCTest
import Argo
import Runes
class SuperClass {
let something: String
init(something: String) {
self.something = something
}
@NicholasTD07
NicholasTD07 / protocol-as-parameter.swift
Created June 8, 2015 05:52
Swift protocol as parameter for both class and struct.
protocol Named: class {
var name: String { get set }
}
class Person: Named {
var name: String
init(name: String) {
self.name = name
}
@NicholasTD07
NicholasTD07 / argo-enxtenison.swift
Last active August 29, 2015 14:22
Argo extension example
import Argo
let json = [
"urlString": "http://www.example.com",
"timestamp": 1433132865,
"date": "20150525",
"intString": "12345",
]
struct ExampleModel {