Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
//This sample is how to use websocket of Tomcat. | |
package wsapp; | |
import java.io.IOException; | |
import java.nio.ByteBuffer; | |
import java.nio.CharBuffer; | |
import java.util.ArrayList; | |
import org.apache.catalina.websocket.MessageInbound; | |
import org.apache.catalina.websocket.StreamInbound; | |
import org.apache.catalina.websocket.WebSocketServlet; |
// | |
// GPUImageTextureInput+CIImage.h | |
// GPUImage | |
// | |
// Created by Sam Soffes on 3/4/14. | |
// Copyright (c) 2014 Sam Soffes. All rights reserved. | |
// | |
#import "GPUImageTextureInput.h" |
import CoreGraphics | |
import Foundation | |
import UIKit | |
class GradientLabel : UILabel { | |
let gradient: CGGradient! | |
let alignedToSuperview: Bool! |
import Foundation | |
// Compressing and decompressing a UUID to 22 characters via base64. | |
// Works great as a Swift playground. These articles were helpful: | |
// http://blog.codinghorror.com/equipping-our-ascii-armor/ | |
// http://69.195.124.60/~jasondoh/2013/08/14/creating-a-short-guid-in-objective-c/ | |
let identifier = NSUUID().uuidString | |
let base64TailBuffer = "=" | |
func compress(identifier: String) -> String? { |
#include "Encoding.h" | |
/* ------------------------------------------------------------------- */ | |
static void output_callback(void* outputCallbackRefCon, | |
void* sourceFrameRefCon, | |
OSStatus status, | |
VTEncodeInfoFlags infoFlags, | |
CMSampleBufferRef sampleBuffer); | |
// Open-ended range operators | |
// | |
// 100... is equivalent to 100...Int.max | |
// ...-100 is equivalent to Int.min...-100 | |
// ..<3 is equivalent to Int.min..<3 | |
import Swift | |
/// Conforming types provide static `max` and `min` constants. | |
protocol MinMaxType { |
var initalArray = [1, 2, 3] | |
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray) | |
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count)) |
extension UIView { | |
func addConstaintsToPinHorizontalEdgesToSuperView(padding: CGFloat = 0) { | |
prepareForConstraints() | |
self.superview!.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(padding)-[view]-(padding)-|", | |
options: NSLayoutFormatOptions(0), | |
metrics: ["padding":padding], | |
views: ["view":self])) | |
} | |
func addConstaintsToPinVerticalEdgesToSuperView(padding: CGFloat = 0) { |