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
#import <UIKit/UIKit.h> | |
#import <AVFoundation/AVFoundation.h> | |
#import <CoreGraphics/CoreGraphics.h> | |
#import <CoreVideo/CoreVideo.h> | |
#import <CoreMedia/CoreMedia.h> | |
/*! | |
@class AVController | |
@author Benjamin Loulier | |
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
void Bitmap2Yuv420p(boost::uint8_t *destination, boost::uint8_t *rgb, | |
const int &width, const int &height) { | |
const std::size_t image_size = width * height; | |
boost::uint8_t *y = destination; | |
boost::uint8_t *u = destination + image_size; | |
boost::uint8_t *v = destination + image_size + image_size / 4; | |
boost::uint8_t *r = rgb; | |
boost::uint8_t *g = rgb + 1; | |
boost::uint8_t *b = rgb + 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
#!/usr/bin/python | |
#original script by Rob Napier <[email protected]> | |
#updates by github.com/gngrwzrd | |
#Script to link in all your old SDKs every time you upgrade Xcode | |
#Create a directory somewhere to store older SDKs in | |
#Under it, put all the platform directories: | |
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform | |
#Under those, store the SDKs: |
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
static OSStatus | |
SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, | |
uint8_t *signature, UInt16 signatureLen) | |
{ | |
OSStatus err; | |
SSLBuffer hashOut, hashCtx, clientRandom, serverRandom; | |
uint8_t hashes[SSL_SHA1_DIGEST_LEN + SSL_MD5_DIGEST_LEN]; | |
SSLBuffer signedHashes; | |
uint8_t *dataToSign; | |
size_t dataToSignLen; |
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 | |
# The script does automatic checking on a Go package and its sub-packages, including: | |
# 1. gofmt (http://golang.org/cmd/gofmt/) | |
# 2. goimports (https://github.com/bradfitz/goimports) | |
# 3. golint (https://github.com/golang/lint) | |
# 4. go vet (http://golang.org/cmd/vet) | |
# 5. race detector (http://blog.golang.org/race-detector) | |
# 6. test coverage (http://blog.golang.org/cover) | |
set -e |
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
// Based on https://gist.github.com/kristopherjohnson/adde22d2c53adfb756a1 | |
// Warning, this is insanely slow to compile in Beta6 (can take several minutes) | |
// Remove some of the |> lines to speed things up | |
// For more on |>, see http://undefinedvalue.com/2014/07/13/fs-pipe-forward-operator-swift | |
infix operator |> { precedence 50 associativity left } | |
// "x |> f" is equivalent to "f(x)" | |
public func |> <T,U>(lhs: T, rhs: T -> U) -> U { | |
return rhs(lhs) |
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 debounce( delay:NSTimeInterval, #queue:dispatch_queue_t, action: (()->()) ) -> ()->() { | |
var lastFireTime:dispatch_time_t = 0 | |
let dispatchDelay = Int64(delay * Double(NSEC_PER_SEC)) | |
return { | |
lastFireTime = dispatch_time(DISPATCH_TIME_NOW,0) | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, |
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
enum Result<A> { | |
case Success(Box<A>) | |
case Failure(NSError) | |
} | |
// Due to current swift limitations, we have to include this Box in Result. | |
// Swift cannot handle an enum with multiple associated data (A, NSError) where one is of unknown size (A) | |
final class Box<T> { | |
let unbox: T | |
init(_ value: T) { self.unbox = value } |
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
import Foundation | |
// MARK: - Comparable | |
extension NSDecimalNumber: Comparable {} | |
public func ==(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool { | |
return lhs.compare(rhs) == .OrderedSame | |
} |
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
struct User { | |
let id: Int | |
let name: String | |
let email: String? | |
} | |
extension User: JSONDecodable { | |
static func create(id: Int, name: String, email: String?) -> User { | |
return User(id: id, name: name, email: email) | |
} |
OlderNewer