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
$ coffee child_process_example.coffee | |
Launching child processes | |
Before fork | |
After fork | |
I am a child process | |
I am a child process | |
I am a child process | |
I am a child process | |
I am a child process | |
I am a child process |
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
launcher = require('./child_process_launcher') | |
console.log 'Launching cluster' | |
launcher.launch() |
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
child_process = require 'child_process' | |
numCPUs = require('os').cpus().length | |
exports = module.exports = launch: -> | |
console.log 'Before fork' | |
child_process.fork("#{__dirname}/another_process") for i in [0...numCPUs] | |
console.log 'After fork' |
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
$ coffee cluster_example.coffee | |
Launching cluster | |
Before the fork | |
I am the master, launching workers! | |
After the fork | |
Launching cluster | |
Before the fork | |
I am a worker! | |
After the fork | |
Launching cluster |
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
launcher = require('./cluster_launcher') | |
console.log 'Launching cluster' | |
launcher.launch() |
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
cluster = require 'cluster' | |
numCPUs = require('os').cpus().length | |
exports = module.exports = launch: -> | |
console.log 'Before the fork' | |
if (cluster.isMaster) | |
console.log 'I am the master, launching workers!' | |
cluster.fork() for i in [0...numCPUs] | |
else |
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
module.exports.setForegroundColor = (color)-> | |
process.stdout.write "\x1b[3#{color}m" | |
module.exports.setBackgroundColor = (color)-> | |
process.stdout.write "\x1b[4#{color}m" | |
module.exports.moveTo = (x, y) -> | |
{ x, y } = transform(x,y) | |
process.stdout.write "\x1b[#{y};#{x}f" |
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
#!/usr/bin/env node | |
// vim:ft=js ts=2 sw=2 et : | |
// -*- mode:javascript -*- | |
var vimtronner = require('../lib/vimtronner'); | |
vimtronner(process.argv); |
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
{ | |
"name": "vimtronner", | |
"version": "0.0.9", | |
"description": "A multi-player Vim trainer.", | |
"main": "lib/vimtronner.js", | |
..., | |
"dependencies": { | |
"socket.io": "", | |
"socket.io-client": "", | |
"commander": "", |
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
onGameChange: (game)=> | |
@io.sockets.in(game.name).emit 'game', game.toJSON() |