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 / Blocked-by-GFW.md
Last active November 26, 2015 06:56
Fucking GFW making life even harder.

Blocked by GFW

GFW makes it harder (by blocking things) for me to use these:

  • Anything use https
  • berks
  • git
  • carthage
  • Websites (some)
  • Google
@NicholasTD07
NicholasTD07 / weird-xcode-problems?.md
Created November 26, 2015 08:13
Solution to (some) Weird Xcode Problems

Weird Xcode Problems?

rm -rf /Library/Developer/ (Or, you can rename it. It's probably safer to rename it.)

This fixed

  • Xcode 6.4: icons in Simulator were garbled
@NicholasTD07
NicholasTD07 / things-go-wrong-in-swift-2.1.swift
Created January 12, 2016 10:58
Things go wrong in Swift 2.1
/// # Things go wrong in Swift 2.1
/// ## A protocol overriding/giving default implementation to its parent's methods
/// If you have a class conform to this protocol and try compile, you will get segmentation fault 11.
protocol SingleSectionTableViewDataSource: UITableViewDataSource {
typealias ItemType
var items: [ItemType] { get set }
}
static func getPrimes(to n: Int) -> [Int] {
let xmody = (1...n)
.map { x in (1...n).map { y in x % y } }
let primes = xmody
.map { mods in
mods.enumerate()
.filter { y, mod in mod == 0 }
.map { y, mod in y + 1 } // divisors for x
}
@NicholasTD07
NicholasTD07 / no-bouncing-dock-icons-macOS.sh
Created August 2, 2016 02:18
Dock icons, STOP BOUNCING ALL DAY!
#!/bin/sh
main() {
no_bouncing_dock_icons
}
no_bouncing_dock_icons() {
defaults write com.apple.dock no-bouncing -bool TRUE
killall Dock
}
protocol ActionType { }
struct InitialAction: ActionType { }
class Store<State> {
var state: State!
typealias Reducer = (State?, ActionType) -> State
final let reducer: Reducer
init(with reducer: @escaping Reducer) {
// Swift 3
protocol ActionType { }
struct InitialAction: ActionType { }
class Store<State> {
var state: State!
typealias Reducer = (State?, ActionType) -> State
final let reducer: Reducer
@NicholasTD07
NicholasTD07 / codecov-with-spm.md
Created May 10, 2017 23:29
Generate code coverage report with Swift Package Manager

Set up

gem install xcov # required | might need sudo
gem install fastlane # optional | might also need sudo

Generate code coverage report

@NicholasTD07
NicholasTD07 / goget-which-plan-to-get.py
Last active July 11, 2018 01:01
Which GoGet plan should I pick?
WEEKS = 52
MONTHS = 12
# per year
def starter(hours_per_week, days_per_month):
base = 49
hourly = 10.65
daily = 87
@NicholasTD07
NicholasTD07 / clean_up_and_create_sims.rb
Last active October 11, 2018 23:38
This script can be used to delete all your iOS simulators and recreate the ones you want.
require 'pp'
require 'fastlane'
require 'snapshot/reset_simulators'
# Run the script where you have fastlane installed with `bundle exec ruby clean_up_and_create_sims.rb`
def delete_all_iOS_sims
FastlaneCore::Simulator.delete_all
end