This file contains hidden or 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 | |
| FFMPEG=$(command -v ffmpeg) | |
| INFILE=$1 | |
| OUTFILE="${INFILE}.gif" | |
| TMPFILE="${INFILE}_gifify_palette.png" | |
| if ! $FFMPEG -L > /dev/null 2>&1; then | |
| echo "Run: brew install ffmpeg" | |
| exit 1 |
This file contains hidden or 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
| // | |
| // UIColor+hex.swift | |
| // | |
| // Created by Berik Visschers on 05-21. | |
| // Copyright (c) 2015 Berik Visschers. All rights reserved. | |
| // | |
| import UIKit | |
| extension UIColor { |
This file contains hidden or 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
| let simulator = UIDevice.currentDevice().model.rangeOfString("Simulator") != nil |
This file contains hidden or 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
| func exponentialMovingAverage(currentAverage: Double, newValue: Double, smoothing: Double) -> Double { | |
| return smoothing * newValue + (1 - smoothing) * currentAverage | |
| } | |
| // Usage: | |
| // var a = 3 | |
| // a = exponentialMovingAverage(a, 8, 0.5) | |
| // Swift 2 |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>IDECodeSnippetCompletionPrefix</key> | |
| <string>dispatch_after</string> | |
| <key>IDECodeSnippetCompletionScopes</key> | |
| <array> | |
| <string>CodeExpression</string> | |
| </array> |
This file contains hidden or 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
| (lldb) posinwindow 0x796a0e60 | |
| (CGPoint) $58 = (x=711, y=205.5) |
This file contains hidden or 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
| func log<T>(message: T, fileName: String = __FILE__, lineNumber: Int = __LINE__, args: CVarArgType...) { | |
| let date = NSDate() | |
| let processInfo = NSProcessInfo() | |
| let appName = processInfo.processName | |
| let combined = String(format: String(stringInterpolationSegment: message), arguments: args) | |
| println("\(date) \(appName) [\(fileName.lastPathComponent):\(lineNumber)] \(combined)") | |
| } |
This file contains hidden or 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
| var applicationActivityIndicators = 0 | |
| extension UIApplication { | |
| func startActivityIndicator() { | |
| applicationActivityIndicators++ | |
| UIApplication.sharedApplication().networkActivityIndicatorVisible = true | |
| } | |
| func stopActivityIndicator() { | |
| applicationActivityIndicators-- | |
| if applicationActivityIndicators <= 0 { |
This file contains hidden or 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 (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { | |
| // Load resources for iOS 6.1 or earlier | |
| } else { | |
| // Load resources for iOS 7 or later | |
| } | |
| // But only in XCode 5 |
This file contains hidden or 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
| def wrap(angle): | |
| while angle > 2 * pi: | |
| angle -= 2 * pi | |
| while angle < 0: | |
| angle += 2 * pi | |
| return angle | |
| def magnetometer_readings_to_tilt_compensated_heading(bx, by, bz, phi, theta, declinationRadians=0): | |
| """ Takes in raw magnetometer values, pitch and roll and turns it into a tilt-compensated heading value ranging from -pi to pi (everything in this function should be in radians). | |
| The correct value for declinationRadians can be found online: http://magnetic-declination.com/countries.php note that this value is in radians, not in degrees. |