Skip to content

Instantly share code, notes, and snippets.

@kentliau
kentliau / CalculatorView.swift
Last active November 27, 2016 21:29 — forked from natecook1000/CalculatorView.swift
An IBInspectable Calculator Construction Set (Swift 3)
// CalculatorView.swift
// as seen in http://nshipster.com/ibinspectable-ibdesignable/
//
// (c) 2015 Nate Cook, licensed under the MIT license
/// The alignment for drawing an String inside a bounding rectangle.
import UIKit
enum NCStringAlignment {
@kentliau
kentliau / open-chrome-tabs-in-safari.scpt
Last active July 16, 2023 15:52 — forked from paulirish/open-chrome-tabs-in-safari.scpt
open all chrome tabs of all windows in safari
tell application "Google Chrome"
set window_list to every window
repeat with the_window in window_list
# For each Window in Chrome, create a new Window in Safari respectively
tell application "Safari"
make new document
activate
@kentliau
kentliau / TreeView.swift
Created September 17, 2016 17:41 — forked from chris-hatton/TreeView.swift
Weekend Playground fun: TreeView
import UIKit
typealias Bough = (rotation:CGFloat, length: CGFloat, scale: CGFloat, hue: CGFloat)
final class TreeView : UIView {
private let limit = 10
private let boughs : [Bough] = [
(rotation: -25, length: 85, scale: 0.75, hue: 0.04),
(rotation: 30, length: 100, scale: 0.65, hue: 0.02)
@kentliau
kentliau / quick-osx-keydnap-check
Created September 6, 2016 11:43
Does a quick check for OS X malware OSX/Keydnap.
if [ -f "/Applications/Transmission.app/Contents/Resources/License.rtf" ] || [ -f "/Volumes/Transmission/Transmission.app/Contents/Resources/License.rtf" ] || [ -f "$HOME/Library/Application Support/com.apple.iCloud.sync.daemon/icloudsyncd" ] || [ -f "$HOME/Library/Application Support/com.apple.iCloud.sync.daemon/process.id" ] || [ -f "$HOME/Library/LaunchAgents/com.apple.iCloud.sync.daemon.plist" ] || [ -d "/Library/Application Support/com.apple.iCloud.sync.daemon/" ] || [ -f "$HOME/Library/LaunchAgents/com.geticloud.icloud.photo.plist" ]; then echo "OSX/Keydnap detected."; else echo "You're good."; fi
@kentliau
kentliau / screen_test.html
Last active August 28, 2016 21:14
Quick and dirty LCD screen color test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Screen test</title>
<style>
html, body {
width: 100%;
height: 100%;
}
@kentliau
kentliau / .bash_profile
Last active August 29, 2015 14:23
Multiple Java version switching
# List all available Java version and currect set Java version
/usr/libexec/java_home -verbose
# Switch to the Java version you want temporarily
export JAVA_HOME="`/usr/libexec/java_home -v '1.6*'`"
# Run your desire Java application (.jar) in your desire version
java -jar application.jar
@kentliau
kentliau / download_all_chrome.sh
Created May 4, 2015 09:08
Download all Chrome, Canary, Chromium using wget
#!/bin/sh
wget -O chrome-mac.zip "https://download-chromium.appspot.com/dl/Mac" && wget "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg" && wget "https://storage.googleapis.com/chrome-canary/GoogleChromeCanary.dmg"
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@kentliau
kentliau / JSONView.css
Last active July 6, 2019 21:31
JSONView dark theme (Google Chrome Extension)
body {
white-space: pre;
font-family: 'Ubuntu Mono';
font-size: 16px;
line-height:20px;
color: white;
background-color: #2B2A27;
}
.property {