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
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 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 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 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 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 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 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 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 deadlineTime = DispatchTime.now() + .seconds(100) | |
let semaphore = DispatchSemaphore(value: 1) | |
DispatchQueue.global().asyncAfter(deadline: deadlineTime) { | |
semaphore.signal() | |
} | |
semaphore.wait() |
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
# Paste these lines into your ~/.bashrc or other shell initialisation script | |
# Note that for most of these, your gitconfig has to have the aliasses from the .gitconfig in this gist | |
alias co='git checkout' | |
alias st='git status' | |
alias add='git add' | |
alias commit='git commit' | |
# Amend anything that is staged |
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
1) `sudo apt-get install git-core` | |
Setup git remote | |
2) `scp -r <your project> <your username>@<ip of raspberry pi>:` | |
3) `ssh <your username>@<ip of raspberry pi>:` | |
4) `cd <your project>` | |
5) `git config --bool core.bare true` | |
6) Go back to your local machine (Ctrl-D) |