Open ~/.bash_profile
in your favorite editor and add the following content to the bottom.
# Git branch in prompt.
parse_git_branch() {
import Foundation | |
struct EquatableValueSequence<T: Equatable> { | |
static func ==(lhs: EquatableValueSequence<T>, rhs: T) -> Bool { | |
return lhs.values.contains(rhs) | |
} | |
static func ==(lhs: T, rhs: EquatableValueSequence<T>) -> Bool { | |
return rhs == lhs | |
} |
prefix func ++(inout x: Int) -> Int { | |
x = x + 1 | |
return x | |
} | |
postfix func ++(inout x: Int) -> Int { | |
let oldX = x | |
x = x + 1 | |
return oldX | |
} |
// | |
// AppConst.swift | |
// AdBlockSample | |
// | |
// Created by bright on 2016/11/26. | |
// Copyright © 2016年 bright. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
import Foundation | |
extension UITextField { | |
func containsOnlyNumbers(string: String, maximumDecimalPlaces: NSInteger, maximumValue: NSInteger) -> Bool { | |
// Check that textfield only contains allowed number of decimal places (this can also be done in regex, but avoiding so that is easier to understand and debug | |
if string.characters.contains(".") { | |
if string.componentsSeparatedByString(".").count > 2 { | |
return false | |
} else { | |
let newStringSplitAtDecimal = string.componentsSeparatedByString(".") |
extension PHPhotoLibrary { | |
typealias PhotoAsset = PHAsset | |
typealias PhotoAlbum = PHAssetCollection | |
static func saveImage(image: UIImage, albumName: String, completion: (PHAsset?)->()) { | |
if let album = self.findAlbum(albumName) { | |
saveImage(image, album: album, completion: completion) | |
return | |
} |
import Foundation | |
import CoreTelephony | |
class OperatorInfo { | |
func id() -> String { | |
let networkInfo = CTTelephonyNetworkInfo() | |
let carrier = networkInfo.subscriberCellularProvider | |
let mcc = carrier!.mobileCountryCode | |
let mnc = carrier!.mobileNetworkCode |
prefix func ++(inout x: Int) -> Int { | |
x = x + 1 | |
return x | |
} | |
postfix func ++(inout x: Int) -> Int { | |
let oldX = x | |
x = x + 1 | |
return oldX | |
} |
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; | |
} | |
- (void)viewWillDisappear:(BOOL)animated | |
{ | |
[super viewWillDisappear:animated]; | |
[[NSNotificationCenter defaultCenter] removeObserver:self]; |
alias gs='git status' | |
alias gsu='git status -uno' | |
alias gp='git pull --rebase' | |
alias gl='git log' | |
alias glf='git log -p' | |
alias glp='git log --pretty=oneline' | |
alias glg='git log --pretty=format:"%h %s" --graph' | |
alias gd='git diff' | |
alias gss='git stash save' | |
alias gsl='git stash list' |