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
operator infix --> {} | |
func --> (instance: Any, key: String) -> Any? { | |
let mirror = reflect(instance) | |
for index in 0 ..< mirror.count { | |
let (childKey, childMirror) = mirror[index] | |
if childKey == key { | |
return childMirror.value | |
} | |
} |
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
// F#'s "pipe-forward" |> operator | |
// | |
// Also "Optional-chaining" operators |>! and |>& | |
// | |
// And adapters for standard library map/filter/sorted | |
infix operator |> { precedence 50 associativity left } | |
infix operator |>! { precedence 50 associativity left } | |
infix operator |>& { precedence 50 associativity left } | |
infix operator |>* { precedence 50 associativity left } |
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
// Curried Functions in Swift | |
// Juan C. Montemayor (@norsemelon) | |
// Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l | |
// Syntax: func name (x1: t1)(x2: t2) -> t { ... } | |
// Note: it has a paren pair for every variable, as opposed to `(x1: t1, x2: t2)` | |
func addTwoNumbers(a: Int)(b: Int) -> Int { | |
return a + b | |
} | |
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 | |
import QuartzCore | |
class ViewController: UIViewController { | |
@IBOutlet weak var label: UILabel | |
@IBOutlet weak var counter: UILabel | |
override func viewDidLoad() { | |
super.viewDidLoad() |
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 python | |
# | |
# git-flip-flop: checks out two or more commits in a periodic cycle | |
# | |
# Save on your $PATH as git-flip-flop | |
# | |
# EXAMPLES | |
# | |
# Check out abc1234, then def5678, then abc1234, etc, with | |
# the default 2s between each checkout |
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 | |
/** | |
Toggles assertion of Core Data managed object contexts. Only available when DEBUG is defined. | |
When enabled, your application will throw an exception when accessing or modifying entities in a context other than their own. | |
*/ | |
void TCBToggleAssertingContextQueues(); | |
#endif |
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 python | |
# Quick and dirty demonstration of CVE-2014-0160 by | |
# Jared Stafford (jspenguin@jspenguin.org) | |
# Modified so that it finds cookies | |
import sys | |
import struct | |
import socket | |
import time | |
import select |
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
// | |
// DUXClientsManager.h | |
// | |
// | |
// Created by Kevin Vitale on 3/25/14. | |
// | |
// | |
@class RACSignal; |
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
#ifndef NS_DESIGNATED_INITIALIZER | |
#if __has_attribute(objc_designated_initializer) | |
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer)) | |
#else | |
#define NS_DESIGNATED_INITIALIZER | |
#endif | |
#endif |
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
// I wish something like this (with a better name for the keyword): | |
@missing UILabel *titleLabel { | |
UILabel *label = [[UILabel alloc] init]; | |
return label; | |
}; | |
// Could turns into this: | |
@interface ViewController () |