A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
A list of presenters at the Brooklyn Swift Developers Meetup with links to videos, slides and source code: http://www.meetup.com/Brooklyn-Swift-Developers
Taiki Suzuki - Flux & MVVM (Video)
Harlan Kellaway - Should Code Always be DRY? (Video)
It has been brought to my attention that there was more use for the unintended values()
functionality that I had outline in my "Other Languages" Java example below.
On the Swift Evolution mailing list, one developer outlined their requirement to loop through an array of enum
case values to add different states to objects.
Another example where a values
array would be useful if the developer wants to do something different for each different case, such as setting an image on a UIButton
subclass for each different UIControlState
#!/bin/bash | |
# | |
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script: | |
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go | |
# | |
# To use: | |
# | |
# $ cd ~/path-to/my-awesome-project | |
# $ go-build-all | |
# |
import UIKit | |
extension UIImage { | |
func resizeWith(percentage: CGFloat) -> UIImage? { | |
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: size.width * percentage, height: size.height * percentage))) | |
imageView.contentMode = .scaleAspectFit | |
imageView.image = self | |
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale) | |
guard let context = UIGraphicsGetCurrentContext() else { return nil } |
// 打印按钮的action及其target | |
function actionWithTargets(button) { | |
var allTargets = [button allTargets].allObjects(); | |
if (!allTargets) { | |
return "is not a uicontrol" | |
} | |
var allShow = []; | |
for (var i = 0; i < allTargets.length; i++) { | |
var target = allTargets[i]; | |
var actions = [button actionsForTarget: target forControlEvent: UIControlEventTouchUpInside]; |