This is a short guide that will teach you the workflows that have been figured out by the voxel.js community for writing node modules + sharing them on NPM and Github. It is assumed that you have a basic understanding of JavaScript, github and the command line (if not you can check out an introduction to git and the command line or learn JS basics from JavaScript for Cats)
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
#!/usr/bin/env node | |
var spawn = require('child_process').spawn | |
, child = spawn('mplayer', ['-']) | |
, fs = require('fs') | |
, movie = fs.createReadStream('./video') | |
movie.pipe(child.stdin) | |
child.stdout.pipe(fs.createWriteStream('/dev/null')) |
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
// Load the TCP Library | |
net = require('net'); | |
// Keep track of the chat clients | |
var clients = []; | |
// Start a TCP Server | |
net.createServer(function (socket) { | |
// Identify this 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
var dnode = require('dnode') | |
var MuxDemux = require('mux-demux') | |
var net = require('net') | |
var client = MuxDemux() | |
var d = dnode() | |
d.on('remote', function (remote) { | |
console.log('in remote') | |
remote.foo(function (p) { |
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 stream = createStream() | |
net.createServer(function (con) { | |
con.on('data', function (data) { | |
console.log('S <- ' + data.toString()) | |
}) | |
stream.on('data', function (data) { | |
console.log('S -> ' + data.toString()) | |
}) | |
stream.pipe(con).pipe(stream) | |
}) |
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 dnode = require('dnode') | |
var MuxDemux = require('mux-demux') | |
var pauseStream = require('pause-stream') | |
module.exports = function () { | |
var client = MuxDemux() | |
var d = dnode() | |
d.on('remote', function (remote) { | |
var peer = { |
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
installall('levelup', __dirname, function (err, paths) { | |
if (err) throw err; | |
console.log(paths); | |
}); | |
/* | |
{ | |
"0.7.0": "/levelup/0.7.0", | |
"0.6.0": "/levelup/0.6.0" | |
} |
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
module.exports = function () { | |
var server = createMuxDemux() | |
var methods = { | |
protocols: function (cb) { | |
cb(getProtocols()) | |
} | |
, open: function (protocol, cb) { |
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
sudo apt-get update | |
sudo apt-get install -y git-core build-essential libssl-dev libboost-all-dev libdb5.1-dev libdb5.1++-dev libgtk2.0-dev | |
git clone https://github.com/bitcoin/bitcoin.git | |
cd bitcoin/src | |
make -f makefile.unix clean; make -f makefile.unix USE_UPNP= bitcoind | |
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
<!doctype html> | |
<html> | |
<body> | |
</body> | |
<script src=./mtgox.js></script> | |
</html> |