Skip to content

Instantly share code, notes, and snippets.

View wddwycc's full-sized avatar
🎯
Focusing

duan wddwycc

🎯
Focusing
View GitHub Profile
@wddwycc
wddwycc / Use Undefined Var.swift
Last active August 29, 2015 14:18
use an undefined `var` in Swift
var background: SKSpriteNode
if (won) {
background = SKSpriteNode(imageNamed: "YouWin")
} else {
background = SKSpriteNode(imageNamed: "YouLose")
}
// do sth to background
// in swift 1.2, this can be applied for `let`!
@wddwycc
wddwycc / orientaitonCorrect.swift
Last active August 29, 2015 14:18
Get The right image from UIImagePicker
func sFunc_imageFixOrientation(img:UIImage) -> UIImage {
// No-op if the orientation is already correct
if (img.imageOrientation==UIImageOrientation.Up) {
return img;
}
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
var transform:CGAffineTransform = CGAffineTransformIdentity
if (img.imageOrientation==UIImageOrientation.Down
|| img.imageOrientation==UIImageOrientation.DownMirrored) {
self.navigationItem.prompt = "Add photos with faces to Googlyify them!"
@wddwycc
wddwycc / pathComponents.swift
Last active August 29, 2015 14:18
Use pathComponents in Swift
import Foundation
let string = "/var/controller_driver/secret_photo.png"
let components = string.pathComponents
//引入了Foundation之后String和NSString会自动转换!
@wddwycc
wddwycc / TriangleValue.swift
Created April 28, 2015 13:38
Get triangle Value from a delta position in UIKit and CALayer
if(deltaPosition == CGPointMake(0, 0)){return}
var radian:CGFloat
if(deltaPosition.y == 0){
if(deltaPosition.x > 0){radian = 0}
else{radian = -CGFloat(M_PI)}
}else if(deltaPosition.y > 0){
if(deltaPosition.x > 0){radian = atan(deltaPosition.y / deltaPosition.x)}
else if(deltaPosition.x == 0){radian = CGFloat(M_PI_2)}
else{radian = -atan(deltaPosition.y / deltaPosition.x) - CGFloat(M_PI)}
@wddwycc
wddwycc / pAnime.swift
Created May 6, 2015 12:31
从某个点上弹出窗口View的动画
class ViewController: UIViewController,UITextFieldDelegate {
var pressed = false
@IBOutlet weak var sampleView: UIView!
var initTransform:CATransform3D{
return CATransform3DScale(CATransform3DMakeTranslation(0, self.sampleView.layer.bounds.height / 2 , 0), 1, 0, 1);
}
var normalTransform:CATransform3D{
return CATransform3DMakeTranslation(0, self.sampleView.layer.bounds.height/2, 0)
@wddwycc
wddwycc / crashReport
Created September 25, 2015 04:36
The crash report for 'cannot create CocoaTouch Class'
Process: Xcode [2124]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 6.4 (7720)
Build Info: IDEFrameworks-7720000000000000~8
App Item ID: 497799835
App External ID: 813293765
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [2124]
@wddwycc
wddwycc / floatingActionButton.js
Created September 29, 2015 05:15
floating action button use Framer.js in framer Studio
bg = new BackgroundLayer
backgroundColor: "#C8C9C1",
perspective: 1000
hide = false
# 实际的宽度应该是150
container = new Layer
backgroundColor: "#FFFFFF",
width: 200,
@wddwycc
wddwycc / dynamicHeight.swift
Created January 6, 2016 14:31
uitableviewCell里动态的textview高度
class DDTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.estimatedRowHeight = 60
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.registerNib(UINib(nibName: "DDTableViewCell", bundle: nil), forCellReuseIdentifier: "DDTableViewCell")
}
}
@wddwycc
wddwycc / DockerBasic
Last active January 15, 2016 03:25
How To Docker
1.运行/停止镜像
从images里读docker-whale镜像,然后运行bin/bash.[CMD]
$ docker run -i -t docker-whale /bin/bash
2.重启镜像
$ docker start kickass_sammet
3.附着到镜像.
$ docker attach kickass_sammet
(kickass_sammet是系统随机给的container名字,之后可以换掉,然后可以用id来代替名字唤起docker命令.)