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 socket | |
port = 3001 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('localhost', port)) | |
s.listen(5) | |
while 1: | |
client, address = s.accept() | |
data = client.recv(1024) | |
if data: |
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
<?php | |
require_once dirname(__FILE__) . '/../lib/simpletest/autorun.php'; | |
function retry($f, $delay = 10, $retries = 3) | |
{ | |
try { | |
return $f(); | |
} catch (Exception $e) { | |
if ($retries > 0) { | |
sleep($delay); |
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
/* Polyfill indexOf. */ | |
var indexOf; | |
if (typeof Array.prototype.indexOf === 'function') { | |
indexOf = function (haystack, needle) { | |
return haystack.indexOf(needle); | |
}; | |
} else { | |
indexOf = function (haystack, needle) { | |
var i = 0, length = haystack.length, idx = -1, found = false; |
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
require "socket" | |
require "bencode" | |
class Nrepl | |
attr_reader :socket, :stream | |
def initialize(hostname, port) | |
@socket = TCPSocket.open(hostname, port) | |
@stream = BEncode::Parser.new(socket) | |
end |
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
/* c.f. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto */ | |
/* A version that mutates the argument object. */ | |
Object.prototype.merge = function (other) { | |
other.__proto__ = this; | |
return other; | |
}; | |
/* A version that does not mutate the argument object. */ |
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 fo = require('fo'), | |
Promise = require('pacta').Promise, | |
add = function add (x) { | |
return function (y) { | |
return x + y; | |
}; | |
}; | |
fo.unsafeSetValueOf(Promise.prototype); | |
fo.unsafeSetValueOf(Function.prototype); |
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.prototype.partial = function () { | |
var f = this, | |
partialArgs = [].slice.call(arguments); | |
return function () { | |
var args = [].slice.call(arguments); | |
return f.apply(null, partialArgs.concat(args)); | |
}; | |
}; |
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 http = require('./promised-http'), | |
Promise = require('pacta').Promise; | |
var promisedPrefixes = http.get('http://codenames.clivemurray.com/data/prefixes.json'), | |
promisedAnimals = http.get('http://codenames.clivemurray.com/data/animals.json'); | |
promisedPrefixes.conjoin(promisedAnimals).spread(function (prefixes, animals) { | |
return JSON.stringify({ | |
prefixes: JSON.parse(prefixes), | |
animals: JSON.parse(animals) |
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
# Description: | |
# Suggesting solid gold, business appropriate business names since 2013. Using Clive Murray's excellent | |
# http://codenames.clivemurray.com/ | |
# | |
# Dependencies: | |
# "rsvp": "1.2.0" | |
# | |
# Configuration: | |
# None | |
# |
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 vm() { | |
caller=$1 | |
vm=$2 | |
command=$3 | |
case "$command" in | |
start) | |
VBoxManage startvm "$vm" --type headless | |
;; | |
stop) |