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){ |
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 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
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
<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
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
var fs = require('fs'), | |
request = require('request'); | |
request.get('http://res.cloudinary.com/hyper1/video/upload/v1453822340/blame_khmv2j.mp3').on('error', function(err) { | |
// handle error | |
}).pipe(fs.createWriteStream('2.mp3')); |
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 url = 'http://graph.facebook.com/517267866/?fields=picture'; | |
var http = require('http'); | |
http.get(url, function(res){ | |
var body = ''; | |
res.on('data', function(chunk){ | |
body += chunk; | |
}); |
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
n = Math.floor(Math.random() * 10 + 1) | |
console.log n |
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
clientId = '' # ID додатка | |
clientSecret = '' # Захисний ключ | |
vkRequest = require 'request-json' | |
client = vkRequest.createClient 'https://oauth.vk.com/' | |
params = 'access_token' + | |
'?client_id=' + clientId + | |
'&client_secret=' + clientSecret + | |
'&grant_type=client_credentials' | |
data = |
OlderNewer