Skip to content

Instantly share code, notes, and snippets.

@atsuya
atsuya / gist:1111126
Created July 28, 2011 07:00
fs stat thing on node 0.4.10
> require('fs').statSync('/usr')
{ dev: 234881026,
ino: 19201463,
mode: 16877,
nlink: 14,
uid: 0,
gid: 0,
rdev: 0,
size: 476,
blksize: 4096,
@atsuya
atsuya / gist:1111128
Created July 28, 2011 07:00
fs stat thing on node 0.5.2
> require('fs').statSync('/usr')
{ dev: 234881026,
ino: 19201463,
mode: 16877,
nlink: 14,
uid: 0,
gid: 0,
rdev: 0,
size: 476,
blksize: 4096,
@atsuya
atsuya / vote_nko_css.css
Created August 28, 2011 15:08
vote nko css
body { color: white; }
@atsuya
atsuya / gist:1408333
Created November 30, 2011 07:25
client: parsing multipart/form-data using connect 1.8
<form action="/" method="post" enctype="multipart/form-data">
<input type="text" name="name" placeholder="Name:" />
<input type="file" name="images" multiple="multiple" />
<input type="submit" value="Upload" />
</form>
@atsuya
atsuya / gist:1408334
Created November 30, 2011 07:26
server: parsing multipart/form-data using connect 1.8
req.body.images.forEach(function(image){
var kb = image.size / 1024 | 0;
res.write('<li>uploaded ' + image.name + ' ' + kb + 'kb</li>');
});
app.use(express.bodyParser({
uploadDir: '/tmp/uploads'
}));
@atsuya
atsuya / browser
Created December 6, 2011 07:30
websocket binary data test - socket.io
io.sockets.on('connection', function (socket) {
socket.on('message', function(data) {
console.log(Buffer.isBuffer(data));
console.log(data);
var buf = new Buffer(5);
buf.writeUInt8(0x3, 0);
buf.writeUInt8(0x4, 1);
buf.writeUInt8(0x23, 2);
buf.writeUInt8(0x42, 3);
@atsuya
atsuya / browser
Created December 6, 2011 07:42
websocket binary data test - websocket.io
var socket = null;
$(function() {
socket = new WebSocket('ws://localhost:3000');
socket.binaryType = 'arraybuffer';
socket.onmessage = function(message) {
receiveBinary(message);
};
setTimeout(sendBinary, 1000);
@atsuya
atsuya / browser
Created December 6, 2011 07:49
websocket binary data test - websocket-node
var socket = null;
$(function() {
socket = new WebSocket('ws://localhost:3000');
socket.binaryType = 'arraybuffer';
socket.onmessage = function(message) {
receiveBinary(message);
};
setTimeout(sendBinary, 1000);
@atsuya
atsuya / gist:1518844
Created December 25, 2011 07:21
assert readme

original code and test is comming from node.js, and modify them to browser compatible.

コンマ以降のところはどういう意味なのでしょう?

for example Mocha can test on bi-side, but dosen't has assertion itself.

butの後にitがあった方がいいですね。

actuary, this Assert.js can running on node.js too.