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
class CachedDateFormatter { | |
static let sharedInstance = CachedDateFormatter() | |
var cachedDateFormatters = [String: NSDateFormatter]() | |
func formatterWith(#format: String, timeZone: NSTimeZone = NSTimeZone.localTimeZone(), locale: NSLocale = NSLocale(localeIdentifier: "en_US")) -> NSDateFormatter { | |
let key = "\(format.hashValue)\(timeZone.hashValue)\(locale.hashValue)" | |
if let cachedDateFormatter = cachedDateFormatters[key] { | |
return cachedDateFormatter | |
} |
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
#!/bin/bash | |
alias npmrun='npm run' | |
alias _npmscripts_print="node -e \"console.log(Object.keys(require('./package.json').scripts, null, ' ').join(' '))\"" | |
_npmscripts_completion() | |
{ | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
opts=$( _npmscripts_print ) | |
COMPREPLY=( $(compgen -W "${opts}" -- $cur) ) | |
} | |
complete -F _npmscripts_completion npmrun |