Skip to content

Instantly share code, notes, and snippets.

View coolnalu's full-sized avatar
🌴

Terry Xu coolnalu

🌴
View GitHub Profile
//////////////////////////////////////////////////////////
//
// Chater 3 - Transition
//
//////////////////////////////////////////////////////////
// Apple changed its name
apple.name = "Apple Inc"
// On sick leave
//////////////////////////////////////////////////////////
//
// Chapter 2 - Jobs' Eras
//
//////////////////////////////////////////////////////////
let apple = Company(name: "Apple Computer",
ceo: steve)
steve.job = Job(company: apple,
startDate: formatter.dateFromString("4/1/76")!)
//////////////////////////////////////////////////////////
//
// Chapter 1 - Births
//
//////////////////////////////////////////////////////////
var steve: Person! = Person(name: "Steven Jandali",
gender: .Male,
birthday: formatter.dateFromString("2/24/55")!)
steve.name = "Steve Jobs"
import Foundation
enum Gender {
case Male, Female
}
class Company {
var name: String
var ceo: Person? {
didSet {
@coolnalu
coolnalu / gist:d23ccb47026b00f75abb
Created February 3, 2015 16:36
Extract values as comma separated list from file
# find and print string matches abc:[0-9]+ in file.txt
sed -n 's/^.*\(abc:[0-9]\+\).*$/\1/p' file.txt | \
# break pattern by colon
awk 'BEGIN{FS=":"};{PRINT $2}' | \
# join lines with comma
tr "\\n" ","
@coolnalu
coolnalu / gist:67a9cb14a1a9c286c8c6
Created December 3, 2014 23:08
Subtle Mac OSX Hacks

Disable Dashboard

defaults write com.apple.dashboard mcx-disabled -boolean YES; killall Dock
# Revert
# defaults write com.apple.dashboard mcx-disabled -boolean NO; killall Dock

Insert Spacer on the Dock

defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'; killall Dock
@coolnalu
coolnalu / gist:7993319
Last active December 31, 2015 13:29
IE6

Symptom: Text “suddenly” disappeared

Possible Fix: Set position:relative on the div whose text is missing! I added position:relative for one of its parent div then had the error. Reference

Symptom: Unusual/Excessive/Too much white space for a floating div

Possible Fix: set display:inline on your div. This is likely to be the silver bullet for the problem. Reference

Symptom: Negative margin clipped/cut off/not shown completely

@coolnalu
coolnalu / gist:7993182
Created December 16, 2013 19:50
Find deleted files in SVN history
# first find the commit that deleted the file
svn log --verbose
# copy it out, use the revision number found, suppose it's 100
svn copy -r 100 https://{URL}/dir/file dir
# and you may likely to see this!
# svn: '/svn/crg/!svn/bc/103/dir/file' path not found
# after some digging, need to add @revision number to the end of the file
@coolnalu
coolnalu / gist:7993154
Last active December 31, 2015 13:29
Pure CSS triangle
.triangle {
width: 0;
height: 0;
border: none;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}
/* Reference */
@coolnalu
coolnalu / gist:7993121
Created December 16, 2013 19:46
git-svn restore master branch from origin
# recover master branch from svn remote
git checkout -b master
# recover master branch from git remote
git checkout --track -b master origin