Skip to content

Instantly share code, notes, and snippets.

View mortenjust's full-sized avatar

Morten Just mortenjust

View GitHub Profile
// https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/index.html#//apple_ref/occ/cl/CLPlacemark
CLGeocoder().reverseGeocodeLocation(location) { (placemarks, err) -> Void in
if let p = placemarks {
let address = p[0].name!
self.locationLabel.text = address
} else {
self.locationLabel.text = ""
let formatter = NSDateFormatter()
formatter.dateStyle = .NoStyle
formatter.timeStyle = .ShortStyle
let dateString = formatter.stringFromDate(taken)
timeTaken.text = " \(dateString) "
override func prefersStatusBarHidden() -> Bool {
return true
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
return UIStatusBarAnimation.Slide
func getDifferenceString(start:NSDate, end:NSDate) -> String {
let calendar: NSCalendar = NSCalendar.currentCalendar()
let components = calendar.components([.Day, .Hour, .Minute, .Second],
fromDate: start,
toDate: end,
options: [])
let d = components.day
let h = components.hour
func wordRangeAtIndex(index:Int, inString str:NSString) -> NSRange {
let tagger = NSLinguisticTagger(tagSchemes: [NSLinguisticTagSchemeTokenType], options: 0)
var r : NSRange = NSMakeRange(0,0)
tagger.string = str as String
tagger.tagAtIndex(index, scheme: NSLinguisticTagSchemeTokenType, tokenRange: &r, sentenceRange: nil )
return r
}
func wordAtIndex(index:Int, inString str:NSString) -> NSString {
return str.substringWithRange(wordRangeAtIndex(index, inString: str))
func selectFolder(){
let openPanel = NSOpenPanel();
openPanel.title = "Select a folder to watch for videos"
openPanel.message = "Videos you drop in the folder you select will be converted to animated gifs"
openPanel.showsResizeIndicator=true;
openPanel.canChooseDirectories = true;
openPanel.canChooseFiles = false;
openPanel.allowsMultipleSelection = false;
openPanel.canCreateDirectories = true;
openPanel.delegate = self;
Frame 1: 268 bytes on wire (2144 bits), 268 bytes captured (2144 bits) on interface 0
Interface id: 0 (en0)
Encapsulation type: IEEE 802.11 plus radiotap radio header (23)
Arrival Time: Nov 21, 2015 10:36:49.097915000 PST
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1448131009.097915000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
let rotate = CABasicAnimation(keyPath: "transform.rotation")
rotate.fillMode = kCAFillModeForwards
rotate.fromValue = 0.0
rotate.toValue = CGFloat(M_PI * 2.0)
rotate.duration = 1
rotate.repeatCount = Float.infinity
loaderView.layer?.position = CGPointMake(CGRectGetMidX(loaderView.frame), CGRectGetMidY(loaderView.frame))
loaderView.layer?.anchorPoint = CGPointMake(0.5, 0.5)
loaderView.layer?.addAnimation(rotate, forKey: nil)
// Appdelegate, view did finish loading
var win = NSApplication.sharedApplication().windows.first!
win.titlebarAppearsTransparent = true
win.movableByWindowBackground = true
win.styleMask = win.styleMask | NSFullSizeContentViewWindowMask;
win.title = ""