$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices server.c -o server
$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices client.c -o client
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 padding(str string) string { | |
return strings.Repeat("0", 8 - len(str)) + str | |
} |
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
log = console.log.bind(console); | |
var assert = require('assert'); | |
function test() { | |
var tests = Array.prototype.slice.call(arguments); | |
function next() { | |
if(!tests.length) return; | |
var args = Array.prototype.slice.call(arguments); | |
args.push(next); | |
var t = tests.shift(); |
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
{ | |
"manifest_version": 2, | |
"name": "Chrome Socket API Server", | |
"description": "listen & accept for socket", | |
"version": "0.1", | |
"app": { | |
"background": { | |
"scripts": ["server.js"] | |
} | |
}, |
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
DEBUG = false; | |
TEST = true; | |
noop = function() {}; | |
log = assert = noop; | |
if (DEBUG) { | |
log = console.log.bind(console); | |
} | |
if (TEST) { | |
assert = function(a,b,m) { console.assert(a.toString() === b.toString(), m); }; |
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
# REST と WebSocket | |
t_wada さんとちょっと話す機会があったので、ここまでに考えてたことを一旦まとめて見たいと思う。 | |
REST については、「Web を支える技術」でお茶を濁さず、本家論文なども参照されたし。 | |
## REST | |
REST はプロトコルでもアーキテクチャでもなく、アーキテクチャスタイルです。 | |
そこにはいくつかの原則があり、最も重要な原則の一つにステートレス性があります。 |
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 log = console.log.bind(console); | |
function choiceReadLength(length) { | |
if (length <= 8) return 8; | |
if (length <= 16) return 16; | |
if (length <= 32) return 32; | |
throw new Error('too large length'); | |
} | |
function choiceReadMethod(readLength) { |
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
readme.md | |
rendered.html | |
remain.txt |
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
// Reference | |
// http://tools.ietf.org/html/rfc6455 | |
// http://www.w3.org/TR/2011/WD-websockets-20110929/ | |
// https://github.com/einaros/ws | |
// https://github.com/Worlize/WebSocket-Node | |
// http://ja.wikipedia.org/wiki/WebSocket | |
// http://www.slideshare.net/You_Kinjoh/javascript-websocket P.68 | |
// http://d.hatena.ne.jp/gtk2k/20120203/1328274962 | |
var log = console.log.bind(console); |
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 System.Directory | |
import Data.List | |
findDotIndex :: String -> Int | |
findDotIndex a = case findIndex (=='.') a of | |
Just x -> x | |
otherwise -> 0 | |
splitAtDot :: String -> (String, String) | |
splitAtDot x = splitAt (findDotIndex x) x |