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
var http = require("http"); | |
// Broken multiproxy - req.socket returns undefined for second hostname when | |
// it's equal to first hostname. | |
function sendRequest(hostname) { | |
var options = { | |
host: hostname, | |
port: 80, | |
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
import re | |
def make_replacer(d): | |
"bind dictionary to replacement function" | |
return lambda m: d.get(m.group(1), m.group(0)) | |
def subs(template, obj): | |
"substitute values from obj into ${vars} in template" | |
repl = make_replacer(obj) | |
return re.sub("""\$\{(\w+)\}""", repl, template) |
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
t = ["one", "two", "one", "four", "one", "two", "three"] | |
hist = {} | |
for x in t: | |
hist[x] = hist.get(x, 0) + 1 |
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
require.extensions[".json"] = function (module, filename) { | |
module.exports = JSON.parse(require("fs").readFileSync(filename, "utf8")) | |
} |
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
// Two ways to serve transparent GIF | |
var buf = new Buffer([ | |
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, | |
0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, | |
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, | |
0x02, 0x44, 0x01, 0x00, 0x3b]); | |
res.send(buf, { 'Content-Type': 'image/gif' }, 200); |
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
// A rough sketch of how a NodeJS service might look | |
// Take 2 - keep services flat. | |
service = require('browserplus').service; | |
log = require('browserplus').log; | |
service.name = "HelloWorld"; | |
service.version = "1.0.1"; | |
service.doc = "A hello world service for BrowserPlus"; |
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'm Lloyd Hilaiel from BrowserPlus. | |
[show the yahoo cow, moo] | |
This screencast explores the question, *how do we make uploading from the Browser, better?* | |
[textual question showing on screen] | |
What does better mean? |
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'm Lloyd Hilaiel from BrowserPlus. `[show the yahoo cow, moo]` | |
This screencast explores the question, *how do we make uploading from the Browser, better?* `[textual question | |
showing on screen]` | |
What does better mean? | |
* Better means *easier* for the user to select the content they wish to upload `[easier floats in lower left | |
portion of screen]` | |
* Better also means the selected content should transfer *faster*. `[faster floats in lower |
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
old |
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
# Ruby Range Check with Default Value | |
# if args['level'] is from (-1..9) return args['level], otherwise return -1 | |
level = (-1..9).include?(args['level']) ? args['level'] : -1 |