hw-1

Swift 下怎么使用 KVO

Swift 下怎么使用 KVO

1
2
3
4
5
6
person.addObserver(self, forKeyPath: "age", options: .new, context: nil)

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
// 输出改变后的新值
print(change![NSKeyValueChangeKey.newKey]!)
}

UIGraphicsBeginImageContextWithOptions – returned Image has a unwanted border

UIGraphicsBeginImageContextWithOptions – returned Image has a unwanted border

1
2
func UIGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat).
A Boolean flag indicating whether the bitmap is opaque. If you know the bitmap is fully opaque, specify YES to ignore the alpha channel and optimize the bitmap’s storage. Specifying NO means that the bitmap must include an alpha channel to handle any partially transparent pixels.

Xcode View Debug

###Xcode View Debug

1
2
3
4
5
6
7
8
9
10
11
12
po [[UIWindow keyWindow] _autolayoutTrace]
expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]

AMBIGUOUS LAYOUT


expr [((UIView *)0x102c48950) bringSubviewToFront:(UIView*)0x102c4e6b0]
expr ((UIView *)0x102c1a070).backgroundColor = [UIColor redColor]
expr ((UIView*)0x102c4e6b0).alpha = 1

expr -l Swift -- import UIKit
expr -l Swift -- unsafeBitCast(0x7f88a8cc2050, to: UIView.self).backgroundColor = UIColor.red

osx svn server create

###osx svn server create

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
mkdir -p  ~/Documents/svn
svnadmin create ~/Documents/svn/myexample

sed -i '' 's/#anon-access.*/anon-access = none/g' ~/Documents/svn/myexample/conf/svnserve.conf
sed -i '' 's/#auth-access.*/auth-access = write/g' ~/Documents/svn/myexample/conf/svnserve.conf
sed -i '' 's/#password-db.*/password-db = passwd/g' ~/Documents/svn/myexample/conf/svnserve.conf
sed -i '' 's/#authz-db.*/authz-db = authz/g' ~/Documents/svn/myexample/conf/svnserve.conf

cat <<EOF >> ~/Documents/svn/myexample/conf/authz
[/]
harry = rw
jianglincen = rw
sally = rw

EOF

cat <<EOF >> ~/Documents/svn/myexample/conf/passwd
[/]
[users]
harry = harryssecret
sally = sallyssecret

EOF

svnserve -d -r ~/Documents/svn/myexample

svn import ~/Downloads/myexampleProj svn://192.168.1.235/myexample/myexampleProj --username=harry --password=harryssecret -m "myexampleProj"

jenkins for osx mojave

###jenkins for osx mojave

1
2
3
4
5
6
7
8
9
10
设置开机自启动:sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist
取消开机自启动:sudo launchctl unload -w /Library/LaunchDaemons/org.jenkins-ci.plist
手动启动:Java -jar jenkins.war
后台启动(默认端口):nohup java -jar jenkins.war &
后台启动(指定端口):nohup java -jar jenkins.war -httpPort=88 &
后台启动(HTTPS):nohup java -jar jenkins.war -httpsPort=88 &

jenkins 错误java.lang.OutOfMemoryError: Java heap space
sudo defaults read /Library/Preferences/org.jenkins-ci heapSize
sudo defaults write /Library/Preferences/org.jenkins-ci heapSize 1024m

python virtualenv for osx

###python virtualenv for osx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pip_install virtualenv
pip_install virtualenvwrapper

// export WORKON_HOME=`pwd`
source ~/Library/Python/2.7/bin/virtualenvwrapper.sh

lsvirtualenv -b

mkvirtualenv pyzk
workon pyzk

lssitepackages
cdvirtualenv
cdsitepackages
cdsitepackages pip

cpvirtualenv env1 env3
rmvirtualenv env2

deactivate

github fork update

###github fork update

1
2
3
4
5
6
7
//github fork update
git remote -v
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git fetch upstream
git checkout master
git merge upstream/master
git push origin master