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
http = require('http') | |
fs = require('fs') | |
readableStream = fs.createReadStream('file.txt') | |
data = '' | |
http.Server((res, req) -> | |
readableStream.on 'data', (chunk) -> | |
data += chunk | |
return |
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
<meta charset="utf-8"> | |
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> | |
<script> | |
var socket = io.connect('ws://localhost:3333'); | |
socket.on('news', function (data) { | |
console.log(data); | |
socket.emit('my other event', { my: 'data' }); | |
}); | |
</script> |
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 request = require("request") | |
var url = "http://developer.cumtd.com/api/v2.2/json/GetStop?" + | |
"key=d99803c970a04223998cabd90a741633" + | |
"&stop_id=it" | |
request({ | |
url: url, | |
json: true | |
}, function (error, response, body) { |
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('http'); | |
var server = new http.Server(function(req, res){ | |
res.setHeader('Content-Type', 'application/json'); | |
var json = JSON.stringify({ | |
foo: "bar" | |
}); | |
res.end(json); | |
}).listen(3333); |
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
window.onload = function(){ | |
var context = new AudioContext() || new webkitAudioContext(), | |
request = new XMLHttpRequest(); | |
request.open("GET", "audio_file.mp3", true); | |
request.responseType = "arraybuffer"; | |
request.onload = function(){ | |
context.decodeAudioData(request.response, onDecoded); | |
} | |
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('http'); | |
var url = require('url'); | |
var server = new http.Server(function(req, res){ | |
console.log(req.method, req.url); | |
var urlParsed = url.parse(req.url, true); | |
console.log(urlParsed); | |
if(urlParsed.pathname = '/echo' && urlParsed.query.message){ |
NewerOlder