Skip to content

Instantly share code, notes, and snippets.

Andreas Madsen AndreasMadsen

  • Computationally Demanding
  • Copenhagen, Denmark
Block or report user

Report or block AndreasMadsen

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
@AndreasMadsen
AndreasMadsen / test.js
Created Jun 15, 2011
Forever – listen to emit
View test.js
/*jslint white: true, devel: true, debug: true, onevar: true,
node: true, undef: true, nomen: true, regexp: false,
plusplus: false, bitwise: true, unparam: false, es5: true,
newcap: true, on: true, strict: true */
(function (global, undefined) {
"use strict";
require.paths = [ '/Users/Andreas/.node_modules', '/usr/local/lib/node_modules' ];
@AndreasMadsen
AndreasMadsen / emitter.js
Created Jun 15, 2011
Simpel http server
View emitter.js
var http = require('http');
http.createServer(function (req, res) {
res.end();
}).listen(1337, "127.0.0.1");
console.log('emitter.js running');
@AndreasMadsen
AndreasMadsen / Terminal
Created Jun 15, 2011
Forever - living dead processors
View Terminal
Andreas-Madsens-MacBook-Pro:~ Andreas$ cd Sites/WebNodes/interface/
Andreas-Madsens-MacBook-Pro:interface Andreas$ node test.js
Output forever list:
Number of open processors: 0
null
start emitter.js
emitter.js is started
Output forever list:
Number of open processors: 1
[0] node /Users/Andreas/Sites/WebNodes/interface/emitter.js [4483, 4482] /Users/Andreas/Sites/WebNodes/interface/log/S9H7.log 0:0:0:0.38
@AndreasMadsen
AndreasMadsen / test.js
Created Jun 15, 2011
forever – load return undefined
View test.js
/*jslint white: true, devel: true, debug: true, onevar: true,
node: true, undef: true, nomen: true, regexp: false,
plusplus: false, bitwise: true, unparam: false, es5: true,
newcap: true, on: true, strict: true */
(function (global, undefined) {
"use strict";
//get the forever module
var forever = require("forever"),
@AndreasMadsen
AndreasMadsen / UDPdebug.js
Created Jul 6, 2011
something is wrong when I send a UDP message
View UDPdebug.js
console.log('Version: ' + process.version);
var dgram = require('dgram'),
path = require("path");
var server = dgram.createSocket("unix_dgram"),
datagramPath = path.join(process.cwd(), "datagram_socket.udp");
server.on("message", function (message) {
console.log("message event fired");
@AndreasMadsen
AndreasMadsen / test-methods.js
Created Nov 5, 2011 — forked from dominictarr/test-methods.js
node-http-proxy methods not working
View test-methods.js
var http = require('http')
, httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
//
// Put your custom server logic here
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000
@AndreasMadsen
AndreasMadsen / test-methods.js
Created Nov 5, 2011 — forked from dominictarr/test-methods.js
node-http-proxy methods not working
View test-methods.js
var http = require('http')
, httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
//
// Put your custom server logic here
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000
View cluster.js
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@AndreasMadsen
AndreasMadsen / cluster.js
Created Nov 14, 2011
SIGCHLD emit when worker rescive SIGTERM
View cluster.js
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
View test.js
var cluster = require('cluster');
var http = require('http');
console.log(cluster.isMaster ? "master" : "worker" + " :: " + process.pid);
if (cluster.isMaster) {
// Fork workers.
cluster.setupMaster({workers: 1});
cluster.on('fork', function (worker) {
You can’t perform that action at this time.