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
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
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
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
Number.prototype.upto = function upto(end) { | |
var start = this; | |
function NumberIterator() { | |
this.current = start; | |
} | |
NumberIterator.prototype.next = function next() { | |
if (this.current > end) { | |
throw StopIteration; | |
} else { | |
return this.current++; |
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
// https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Media_events | |
// https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIDOMHTMLMediaElement | |
var Sounds = { | |
sounds: {}, | |
errors: [null, "ABORTED", "NETWORK", "DECODE", "SRC_NOT_SUPPORTED"], | |
register: function register(sounds) { | |
var errors = this.errors; | |
for (var i = 0, l = sounds.length; i < l; i++) { |
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
let self = require('self'), file = require('file'), url = require('url'); | |
let contextMenu = require('context-menu'); | |
let sym = gensym(), containerID = 'word-cloud-' + sym; | |
let item = contextMenu.Item({ | |
label: "Show Word Cloud", | |
onClick: function(context, item) { | |
let win = context.window, corpus = generateCorpus(win); | |
let scores = score(corpus), sorted = plist(scores); | |
sorted.sort(byScore); |
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
framework 'cocoa' | |
class HelloFS | |
PATH = '/hello.txt' | |
def contentsOfDirectoryAtPath(path, error: error) | |
[PATH.lastPathComponent] | |
end | |
def contentsAtPath(path) |
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 | |
# Run this script with sudo | |
launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist | |
cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.cse | |
cat >> /etc/cups/cupsd.conf <<EOF | |
# Show shared printers on the UW CSE network. | |
BrowseRemoteProtocols cups |
OlderNewer