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 / 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 / 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

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 / 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())
@NicholasTD07
NicholasTD07 / all-fonts-in-iOS-app.swift
Created August 17, 2015 08:07
Find all the font in an iOS app
for fontFamily in UIFont.familyNames() {
println("family: \(fontFamily)")
for font in UIFont.fontNamesForFamilyName(fontFamily as! String) {
println("font: \(font)")
}
}
//
// NSDate+timeAgo.swift
//
//
// Created by Nicholas Tian on 19/08/2015.
// Copyright (c) 2015 nickTD. All rights reserved.
//
import Foundation
@NicholasTD07
NicholasTD07 / iOS-UI-in-code-with-SnapKit.swift
Last active August 27, 2015 09:07
Doing iOS UI in code with SnapKit
import UIKit
import SnapKit
class SomeViewController: UIViewController {
var addButton = UIButton()
var helloWorldLabel = UILabel()
override func viewDidLoad() {
let superView = view
let views = [
@NicholasTD07
NicholasTD07 / clean-up-merged-branches.py
Last active October 1, 2015 07:36
Remove all merged branches
#!/usr/bin/env python2
# Remove all merged branches, except ignored as specified in IGNORE_BRANCHES
import subprocess
IGNORE_BRANCHES = ['master', 'develop']
def main():
checkout_branch('master')
merged_branches_except_ignored = filter_branches_with_ignores(
@NicholasTD07
NicholasTD07 / TimeTracking.swift
Last active March 5, 2021 01:26
I use this to know how many hours I work a day.
#!/usr/bin/env xcrun swift
// Usage: path/to/TimeTracking.swift
// Go to bottom to see how it's used.
// The MIT License (MIT)
// Copyright (c) 2015 Nicholas T.
// Permission is hereby granted, free of charge, to any person obtaining a copy
@NicholasTD07
NicholasTD07 / how-to-download-iOS-simulator-in-command-line-and-install-it.md
Last active November 20, 2024 11:05
How to Download iOS Simulator (Xcode) in Command Line and Install it

How to Download iOS Simulator (Xcode) in Command Line and Install it

For faster connection speed and more flexibility.

Steps

  1. Start Xcode in command line by running this in commandline /Applications/Xcode.app/Contents/MacOS/Xcode
  2. Start downloading of the simulator
  3. Cancel it. YES CANCEL IT!
  4. You will get a message like this: