Skip to content

Instantly share code, notes, and snippets.

Sam Roberts sam-github

Block or report user

Report or block sam-github

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sam-github
sam-github / dsl-print
Created Mar 6, 2012
Example of a lua DSL language
View dsl-print
#!/usr/bin/env lua
--[[
dsl-print [some.dsl]
Example of a lua DSL language, that can use function call or assignment to define
keys, and uses call sequence to implicitly define nesting.
]]
function dsl(code, file)
local loaded, estr = loadstring(code, file)
@sam-github
sam-github / dsl.lua
Created Dec 7, 2012
Another DSL in lua, for Vasiliy
View dsl.lua
print"TABLE"
function directory(path)
print("directory", path)
return function(attrs)
for key,value in pairs(attrs) do
print("", key, value)
end
end
View cluster-exit.js
var cluster = require('cluster')
, net = require('net');
if (cluster.isMaster) {
console.log('master: node version', process.version);
var worker = cluster.fork();
worker.on('online', function() {
console.log('master: on worker/online');
});
View exit-with-signal.js
assert = require('assert')
cluster = require('cluster');
if(cluster.isMaster) {
worker=cluster.fork();
worker.on('exit', function(code, signal) {
console.log('worker on exit', code, signal, 'process.exitCode', worker.process.exitCode)
})
worker.on('online', function() {
console.log('worker pid', worker.process.pid)
worker.kill('SIGTERM')
@sam-github
sam-github / publish 2.0.1
Last active Dec 28, 2015
npmjs.org 404ing on a package tarball
View publish 2.0.1
sam@samtu:~/w/sn/slc (release/2.0.0 *% u=) % npm install -g strong-slc
npm http GET https://registry.npmjs.org/strong-slc
npm http 304 https://registry.npmjs.org/strong-slc
npm http GET https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm http 404 https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at WriteStream.<anonymous> (/usr/local/stow/node/lib/node_modules/npm/lib/utils/fetch.js:57:12)
npm ERR! at WriteStream.EventEmitter.emit (events.js:117:20)
npm ERR! at fs.js:1596:14
@sam-github
sam-github / gist:7534247
Created Nov 18, 2013
npm publish, then tarball is 404
View gist:7534247
sam@samtu:~/w/sn/slc (release/2.0.0 % u=) % npm publish
npm http PUT https://registry.npmjs.org/strong-slc
npm http 201 https://registry.npmjs.org/strong-slc
npm http GET https://registry.npmjs.org/strong-slc
npm http 200 https://registry.npmjs.org/strong-slc
npm http PUT https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz/-rev/1-3087bd76554a3769731e0808c6daec05
npm http 201 https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz/-rev/1-3087bd76554a3769731e0808c6daec05
npm http PUT https://registry.npmjs.org/strong-slc/2.0.0/-tag/latest
npm http 201 https://registry.npmjs.org/strong-slc/2.0.0/-tag/latest
+ strong-slc@2.0.0
@sam-github
sam-github / -
Last active Dec 28, 2015
demonstrate how cluster in node v0.10 doesn't close server handles when no workers need them
View -
var cluster = require('cluster')
var net = require('net');
var spawn = require('child_process').spawn;
if(cluster.isMaster) {
cluster.fork()
cluster.on('exit', function() {
//cluster.disconnect(); // if .disconnect() is called, it closes the serverHandlers
@sam-github
sam-github / -
Created Nov 25, 2013
show how to deliver SIGTERM to a cluster worker
View -
assert = require('assert')
cluster = require('cluster');
if(cluster.isMaster) {
worker=cluster.fork();
worker.on('online', function() {
// pause, to give worker time to establish signal handler
setTimeout(function() {
worker.process.kill('SIGTERM')
}, 100);
});
View cluster-disconnect-message.js
var cluster = require('cluster');
if(cluster.isMaster) {
cluster.fork()
.on('online', function() {
this.disconnect();
});
} else {
process.on('internalMessage', function(msg) {
console.log('internalMsg', msg);
View d.js
var domain = require('domain');
d = domain.create();
d.enter()
d.on('error', function(er) {
d.exit();
console.log('hmm, er');
process.nextTick(function() {
throw er;
});
});
You can’t perform that action at this time.