Skip to content

Instantly share code, notes, and snippets.

View ralphtheninja's full-sized avatar
🏠
Working from home

ralphtheninja

🏠
Working from home
View GitHub Profile
@ralphtheninja
ralphtheninja / play2.js
Created March 4, 2013 17:17
This works. Apparently there has to be a final consumer of the last stdout, for example /dev/null in this case, or some other file descriptor.
#!/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'))
// 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
@ralphtheninja
ralphtheninja / client-nope.js
Created March 6, 2013 07:55
mux-demux and dnode, my brain is boiling and can't see why it's not working
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) {
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)
})
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 = {
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"
}

Writing node modules with voxel.js

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)

Table of contents

module.exports = function () {
var server = createMuxDemux()
var methods = {
protocols: function (cb) {
cb(getProtocols())
}
, open: function (protocol, cb) {
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
<!doctype html>
<html>
<body>
</body>
<script src=./mtgox.js></script>
</html>