PID=$(ps aux | grep -e 'vagrant' | grep -v grep | awk '{print $2}') && kill -s 9 $PID 2> /dev/null
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
// | |
// Created by Adam Kirk on 6/22/15. | |
// | |
import UIKit | |
extension UIView { | |
var x: CGFloat { | |
get { |
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
// | |
// Created by Adam Kirk on 6/22/15. | |
// | |
import UIKit | |
extension UIScrollView { | |
var contentOffsetX: CGFloat { | |
get { |
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
// | |
// Q.swift | |
// Created by Adam Kirk on 6/6/15. | |
// | |
import Foundation | |
public typealias QBlock = () -> Void | |
func serialQueueWithName(name: String) -> NSOperationQueue { |
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 Foundation | |
public class Promise<T> { | |
public typealias PromiseSuccessBlock = (result: T) -> Void | |
public typealias PromiseFailureBlock = (error: NSError?) -> Void | |
public typealias PromiseAlwaysBlock = () -> Void | |
private(set) var successBlocks = [PromiseSuccessBlock]() | |
private(set) var failureBlocks = [PromiseFailureBlock]() |
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 UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
assert(red >= 0 && red <= 255, "Invalid red component") | |
assert(green >= 0 && green <= 255, "Invalid green component") | |
assert(blue >= 0 && blue <= 255, "Invalid blue component") | |
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0) | |
} |
So dumb. If you're trying to use boundingRectForGlyphRange…
or lineFragmentRectForGlyphAtIndex…
on a UITextView's
NSLayoutManager, you will get slightly wrong coordinates if the text is longer than a few thousand characters.
…until you:
textView.layoutManager.allowsNonContiguousLayout = false
Then it works perfectly.
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 DEBUG | |
func dLog(message: AnyObject, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
NSLog("%@", "[\(filename):\(line)] \(function) - \(message)") | |
} | |
func uLog(message: AnyObject, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
let message = NSString(format: "%@", "\(function) - \(message)") as String | |
let alertView = UIAlertView(title: "[\(filename):\(line)]", message: message, delegate:nil, cancelButtonTitle:"OK") | |
alertView.show() | |
} |
-
Use heroku pgbackups to get url of latest backup:
heroku pgbackups:url
-
Download the .dump file.
-
Create a db to restore into:
psql -c "create database firehose_live_backup"
(note: show current dbs with psql
then \list
)
To create a copy of a database, first make sure the destination doesn't exist:
psql -c "DROP DATABASE firehose_development;"
Then:
psql -c "CREATE DATABASE firehose_development WITH TEMPLATE firehose_test;"