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
comment_char % | |
escape_char / | |
% This file is part of the GNU C Library and contains locale data. | |
% The Free Software Foundation does not claim any copyright interest | |
% in the locale data contained in this file. The foregoing does not | |
% affect the license of the GNU C Library as a whole. It does not | |
% exempt you from the conditions of the license if your use would | |
% otherwise be governed by that license. |
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 | |
# Universal Install Script | |
# https://xkcd.com/1654/ | |
pip install "$1" & | |
easy_install "$1" & | |
brew install "$1" & | |
npm install "$1" & | |
yum install "$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
- (RACSignal*) continueInBackground | |
{ | |
return [[RACSignal createSignal:^(id<RACSubscriber> subscriber) { | |
UIApplication* app = UIApplication.sharedApplication; | |
__block UIBackgroundTaskIdentifier taskID; | |
RACCompoundDisposable* compoundDisposable = [RACCompoundDisposable compoundDisposable]; | |
RACDisposable* backgroundTaskDisposable = [RACDisposable disposableWithBlock:^{ | |
[app endBackgroundTask:taskID]; | |
}]; |
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
// | |
// CollectionViewDataSource.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 10/14/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit |
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
// | |
// A half-baked approach (not thread-safe, poor disposable management) for creating | |
// aggregate collections from multiple signals of collection mutations. In this | |
// case we are concating multiple mutation streams into a single container. So for | |
// each inner signal we need to offset subsequent splices by the count of preceding | |
// items (which can be recovered by scanning previous splices). | |
// | |
// Example: | |
// | |
// let (first, sink1) = SignalProducer<Splice<Int>, NoError>.buffer() |
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
// Similar to `enumerate` but provides the collection's index type | |
// rather than an Int for the position | |
public func iterate<C: CollectionType>(collection: C) -> SequenceOf<(C.Index, C.Generator.Element)> { | |
var index = collection.startIndex | |
// type-inference doesn't want to work without this | |
return SequenceOf { _ -> GeneratorOf<(C.Index, C.Generator.Element)> in | |
return GeneratorOf { | |
if index == collection.endIndex { | |
return 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
protocol Randomizable { | |
static func random() -> Self | |
} | |
protocol IntervalRandomizable: Randomizable, Comparable { | |
static func random(interval: HalfOpenInterval<Self>) -> Self | |
static func random(interval: ClosedInterval<Self>) -> Self | |
} | |
extension CGFloat: Randomizable { |
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
private enum Either<T, U> { | |
case Left(Box<T>) | |
case Right(Box<U>) | |
} | |
public func zipWith<T, U, E>(otherSignal: Signal<U, E>)(signal: Signal<T, E>) -> Signal<(T, U), E> { | |
return Signal { observer in | |
var lock = NSRecursiveLock() | |
lock.name = "org.reactivecocoa.ReactiveCocoa.zipWith" |
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
#!/usr/bin/env swift | |
// | |
// Naive wrapper around CFStringTransform that attempts to transliterate | |
// Unicode strings to lower-case ASCII | |
// | |
// http://nshipster.com/cfstringtransform/ | |
// | |
import Foundation |
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
# Assuming the raw byte[] buffer from onPreviewFrame was written at $1 | |
INPUT=$1 | |
# Need preview size since we dumped to a raw file w/out header info | |
SIZE=1280x960 | |
# Converting to JPEG | |
ffmpeg -f image2 -vcodec rawvideo -s $SIZE -pix_fmt nv21 -i $INPUT out.jpeg | |
# Converting to PNG |
NewerOlder