Skip to content

Instantly share code, notes, and snippets.

View kinwahlai's full-sized avatar

KinWah Lai kinwahlai

  • Odd-e Singapore
  • Singapore
View GitHub Profile
@kinwahlai
kinwahlai / UICollectionViewScroll.swift
Created February 22, 2018 16:31 — forked from jlnquere/UICollectionViewScroll.swift
XCUITests: scroll UICollectionView to find one of it's offscreen UICollectionViewCell by id
// Thanks to @MonsieurDart for the idea :)
func scroll(collectionView:XCUIElement, toFindCellWithId identifier:String) -> XCUIElement? {
guard collectionView.elementType == .collectionView else {
fatalError("XCUIElement is not a collectionView.")
}
var reachedTheEnd = false
var allVisibleElements = [String]()
while !reachedTheEnd {

Vim Alphabet

a

a enter into insert mode after the character your cursor is on

A enter into insert mode at the end of the current line

b

@kinwahlai
kinwahlai / xcode_ramdisk.sh
Created July 18, 2017 04:30 — forked from derjohng/xcode_ramdisk.sh
Create a RAM disk for using with XCode, with Umount disks method
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
DEV_CACHES_DIR="/Users/$USERNAME/Library/Developer/Xcode/DerivedData"
DEV_CACHES_SHADOW_DIR="/Users/$USERNAME/Library/Developer/Xcode/DerivedData_shadow"
defaults write xcodebuild PBXNumberOfParallelBuildSubtasks 4
defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
defaults write com.apple.dt.Xcode PBXNumberOfParallelBuildSubtasks 4
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
defaults write com.apple.dt.Xcode ExplainWhyBuildCommandsAreRun -bool true
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool true
#!/bin/sh
wget http://ipinfo.io/ip -qO -
@kinwahlai
kinwahlai / gist:ea95665b88eacbb6a611
Created March 1, 2016 04:18 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@kinwahlai
kinwahlai / raspberry-pi-vpn-router.md
Created February 12, 2016 00:47 — forked from superjamie/raspberry-pi-vpn-router.md
Raspberry Pi VPN Router

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2015-09-24-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@kinwahlai
kinwahlai / byobuCommands
Created December 23, 2015 21:47 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@kinwahlai
kinwahlai / performance_mesaure.swift
Created December 9, 2015 01:23
function to measure block code executed
func measure(title: String, block: (finish:()-> Void) -> Void) {
let startTime = CFAbsoluteTimeGetCurrent()
block {
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
print("\(title):: Time: \(timeElapsed)")
}
}
@kinwahlai
kinwahlai / inject_DVTPlugInCompatibilityUUID.sh
Last active December 30, 2015 00:30
To insert new DVTPlugInCompatibilityUUID into plugin's Info.plist
#! /usr/bin/env sh
# assumption: Xcode is always installed at /Applications
# STEPS:
# use plistbuddy to read $INFOPLIST_FILE::DVTPlugInCompatibilityUUIDs array
# get new DVTPlugInCompatibilityUUID [ defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID ]
# check new DVTPlugInCompatibilityUUID already in the array
# YES: end
# NO: use plistbuddy to write the new DVTPlugInCompatibilityUUID into the array and write out to file