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
function getPageQuery() { | |
var parts = window.location.search.substring(1).split("&"); | |
var query = {}; | |
for (var i = 0; i < parts.length; ++i) { | |
var pair = parts[i].split("="); | |
if (pair.length == 2) { | |
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); | |
} | |
} | |
return query; |
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 BOOL isKeyFrame(CMSampleBufferRef sample) | |
{ | |
auto a = CMSampleBufferGetSampleAttachmentsArray(sample, 0); | |
if (CFArrayGetCount(a) > 0) { | |
CFBooleanRef value; | |
auto b = CFDictionaryGetValueIfPresent | |
((CFDictionaryRef) CFArrayGetValueAtIndex(a, 0) | |
, kCMSampleAttachmentKey_NotSync | |
, reinterpret_cast<const void **>(&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
digraph exercise_6_1 { | |
a [shape = box, label = "a: snoc (empty, 0) <3>"]; | |
b [shape = box, label = "b: snoc (a, 1) <3>"]; | |
c [shape = box, label = "c: tail b <2>"]; | |
d [shape = box, label = "d: snoc (b, 2) <2>"]; | |
e [shape = box, label = "e: c ++ d <0>"]; | |
f [shape = box, label = "f: tail c <0>"]; | |
g [shape = box, label = "g: snoc (d, 3) <0>"]; |
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 Record { | |
let time: NSDate | |
let name: String | |
} | |
extension Array { | |
func sortedGroupBy(isOrderedBefore: (T, T) -> Bool) -> [[T]] { | |
let tmp = sorted(isOrderedBefore) | |
var out = [[T]]() | |
for (i, e) in enumerate(tmp) { |
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
// Playground - noun: a place where people can play | |
import UIKit | |
class MyControl { | |
private var closures: [(UIControlEvents, MyControl -> ())] = [] | |
init() {} | |
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
:- op(200, xfy, <--). | |
:- op(200, xfy, /^\). | |
:- op(200, xfy, /^ ). | |
:- op(200, xfy, ^\). | |
tree_empty(zip(nil, [])). | |
tree_lhs(zip(L, [step(lhs, V, R)|XS]), zip(node(V, L, R), XS)). | |
tree_rhs(zip(R, [step(rhs, V, L)|XS]), zip(node(V, L, R), XS)). | |
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 | |
public class UDKey<T> { | |
let key: String | |
let map: BiMap<AnyObject, T> | |
public init(_ key: String, _ map: BiMap<AnyObject, T>) { | |
self.key = key | |
self.map = map |
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
// This returns something like an ID of given type | |
func unsafeGetTypeId(type: Any.Type) -> uintptr_t { | |
return unsafeBitCast(type, uintptr_t.self) | |
} | |
func isOfType(value: Any, type: Any.Type) -> Bool { | |
return unsafeGetTypeId(reflect(value).valueType) == unsafeGetTypeId(type) | |
} | |
let a: Any = "Hello" |
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
var pc = new webkitRTCPeerConnection({"iceServers": [{"url": "stun:stun.l.google.com:19302"}]}); | |
pc.createDataChannel("hello"); | |
pc.createOffer(function (desc){ | |
pc.setLocalDescription(desc, function() { | |
console.log(desc.sdp); | |
}); | |
}); | |
/* | |
v=0 |