Skip to content

Instantly share code, notes, and snippets.

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

Pedro Teixeira pgte

🏠
Working from home
View GitHub Profile
#! /bin/sh
### BEGIN INIT INFO
# Provides: sweepyd
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
### END INIT INFO
# Author: Pedro Teixeira(http://metaduck.com)
[ENVIRONMENT]:
servers:
broadcast:
bind_address: # the IP address for the server receiving UDP broadcasts. Default is 255.255.255.255
port: # the UDP port for receiving broadcasts. Default is 10000
public:
bind_address: #the IP address for the server receiving UDP commands specific to this host. Default is 0.0.0.0 (all interfaces)
port: # the UDP port for receiving direct commands. Default is 10001
private:
port: # the UDP port for receiving private commands. Default is 10002
var sys = require( 'sys' );
var http = require('http');
var form_doc = '\
<html> \
<body>\
<form method="POST" action="/body">\
<input type="submit" name="test" value="Body" />\
</form>\
<form method="POST" action="/nobody">\
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
var net = require('net');
net.createServer(function (socket) {
socket.setEncoding("utf8");
socket.write("Echo server\r\n");
socket.on("data", function (data) {
socket.write(data);
});
socket.on("end", function () {
socket.end();
});
fs.readFile('/etc/passwd', function (err, data) {
if (err) throw err;
console.log(data);
});
var http = require('http');
var fs = require('fs');
var sys = require('sys');
var filename = 'test.mov';
var content_type = 'video/quicktime';
http.createServer(function (request, response) {
response.writeHead(200, {
'Content-Type': content_type
var filename = "log.txt";
(function(filename) {
fs.open(filename, 'r', 0666, function(err, fd) {
sys.log('opened file '+filename);
});
})(filename);
filename = "/etc/passwd";
@pgte
pgte / step.js
Created September 14, 2010 10:47
var Step = require('step');
Step(
function readSelf() {
fs.readFile(__filename, this);
},
function capitalize(err, text) {
if (err) {
throw err;
}
fs.open('/etc/passwd', 'r', 0666, function(err, fd) {
http = require('http');
http.createClient(80, 'www.myserver.net');
// ...
});