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 fs = require('fs'); | |
| var http = require('http'); | |
| var util = require('util'); | |
| var file = './1G.file'; | |
| var stat = fs.statSync(file); | |
| http.createServer(function (req, res) { | |
| res.writeHead(200, {'Content-Type': 'octet-stream/binary', | |
| 'Content-Length': stat.size | |
| }); | |
| var rStream = fs.createReadStream(file); |
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
| // This code is fallback for https://github.com/Worlize/WebSocket-Node | |
| // add the broadcast to https://gist.github.com/1219165 | |
| // 2011.11.30 tato@http://www.facebook.com/javascripting | |
| // Example of how to fallback to alternative websocket library for old protocol clients | |
| // see https://gist.github.com/1148686 | |
| var http = require('http'), | |
| WebSocketRequest = require('websocket').request, |
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 uuid() { | |
| var uuid = "", i, random; | |
| for (i = 0; i < 32; i++) { | |
| random = Math.random() * 16 | 0; | |
| if (i == 8 || i == 12 || i == 16 || i == 20) { | |
| uuid += "-" | |
| } | |
| uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16); | |
| } |