This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIApplication { | |
static var applicationName: String { | |
let mainBundle = NSBundle.mainBundle() | |
let key = String(kCFBundleNameKey) | |
let value = mainBundle.objectForInfoDictionaryKey(key) as? String | |
return value ?? "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension TimeInterval { | |
func asHoursMinutesSeconds () -> (Int, Int, Int) { | |
let interval = Int(self) | |
return ( interval / 3600, interval % 3600 / 60, (interval % 3600) % 60) | |
} | |
/// Creates a string with hours, minutes, seconds, | |
/// divided by the given separator. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MD5_HASH=`md5 -s "$1" | awk -F"=" '{print $2}' | xargs` | |
wget -O $1.jpg https://www.gravatar.com/avatar/$MD5_HASH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name "/Pods" | xargs -0 wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#H1 Useful GIT commands | |
#H2 Which Git Branches contain the given commit | |
#H3 local | |
git branch --contains your_commit_hash | |
#H3 remote | |
git branch -a --contains your_commit_hash | |
#H2 Revert a merge commit that was already pushed | |
git revert -m 1 <commit-hash> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#avoid problems with standard installation directory | |
sudo gem update cocoapods -n /usr/local/bin | |
#install certain version of cocoapods | |
sudo gem install cocoapods -v 1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#autocorrect a single file | |
SCRIPT_INPUT_FILE_COUNT=1 SCRIPT_INPUT_FILE_0="Class.swift" swiftlint autocorrect --use-script-input-files | |
#show only swiftlint warnings | |
swiftlint 2>&1 | grep -i warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func urlEncodeString(_ string: String) -> String { | |
#if swift(>=3.0) | |
let allowedCharacterSet = (CharacterSet(charactersIn: "!*'();:@&=+$,/?%#[] ").inverted) | |
if let escapedString = string.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) { | |
return escapedString | |
} | |
#else | |
let allowedCharacterSet = (NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[] ").invertedSet) | |
if let escapedString = string.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacterSet) { | |
return escapedString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEV | |
fileprivate func isDebuggerAttached() -> Bool { | |
var info = kinfo_proc() | |
var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()] | |
var size = MemoryLayout<kinfo_proc>.stride | |
let junk = sysctl(&mib, UInt32(mib.count), &info, &size, nil, 0) | |
assert(junk == 0, "sysctl failed") | |
return (info.kp_proc.p_flag & P_TRACED) != 0 | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### which shell is used? | |
echo $SHELL | |
echo $0 |
OlderNewer