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
export interface Meta<T> { | |
meta: T; | |
} | |
export type AnyType = string | symbol; | |
export interface Action<Type extends AnyType, Payload> { | |
type: Type; | |
payload: Payload; | |
error?: boolean; |
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/sh | |
test "$@" | |
RESULT=$? | |
if [[ $RESULT -eq 0 ]]; then | |
echo true | |
else | |
echo false | |
fi |
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
func chunk<T : Sliceable where T.Index : Strideable>( | |
s: T, | |
#from: T.Index, | |
#to: T.Index, | |
#by: T.Index.Stride | |
) -> GeneratorOf<T.SubSlice> { | |
var g = stride(from: from, to: to, by: by).generate() | |
return GeneratorOf<T.SubSlice> { | |
if let start = g.next() { |
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
enum Quadrant { | |
case BottomLeft | |
case TopLeft | |
case BottomRight | |
case TopRight | |
static func forPoint(point: CGPoint) -> Quadrant { | |
switch (point.x, point.y) { | |
case (let x, let y) where x >= 0 && y >= 0: | |
return .TopRight |
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 => { associativity left } | |
func => <K : Hashable, V>(key: K, value: V) -> (K, V) { | |
return (key, value) | |
} | |
let pairs: (String, Int)[] = [ | |
"e" => 10, | |
"t" => 7, | |
"i" => 2 | |
] |
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 prefix ~ {} | |
@prefix func ~(pattern: String) -> NSRegularExpression! { | |
var error: NSError? | |
return NSRegularExpression.regularExpressionWithPattern( | |
pattern, | |
options: nil, | |
error: &error) | |
} |
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
<?php | |
class Context { | |
private $args = array(); | |
private $func = NULL; | |
public function __construct() { | |
$args = func_get_args(); | |
$func = array_pop($args); |
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
this.Generator && (function(g, global) { | |
var __send = g.prototype.send; | |
g.prototype.send = function send(value) { | |
var result = __send.call(this, value); | |
if (result.done) { | |
throw new StopIteration(); | |
} | |
return result.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
#!/usr/bin/env macruby | |
framework 'CoreFoundation' | |
class Range | |
def to_core_range | |
location = self.begin | |
length = (self.exclude_end? ? self.end : self.end.succ) - location | |
CFRange.new(location, length) | |
end |
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
module Env | |
MACRUBY_FRAMEWORK_BIN = 'MacRuby.framework/Versions/Current/usr/bin/macruby' | |
MACRUBY_CANDIDATES = [ | |
"/System/Library/PrivateFrameworks/#{MACRUBY_FRAMEWORK_BIN}", | |
"/Library/Frameworks/#{MACRUBY_FRAMEWORK_BIN}" | |
] | |
def self.find_macruby | |
MACRUBY_CANDIDATES.each do |path| | |
return path if File.exist?(path) |