Skip to content

Instantly share code, notes, and snippets.

Marak / echoHttpRequest.js
Last active Mar 26, 2021
Echo HTTP requests
View echoHttpRequest.js
module['exports'] = function echoHttp (hook) {
console.log("Console messages are sent to /logs");
Marak / git-commit-prefixes
Created May 18, 2011 — forked from indexzero/git-commit-prefixes
Short list of Git commit prefixes used at Nodejitsu
View git-commit-prefixes
[api]: New apis / changes to apis
[test]: Update test/* files
[dist]: Changes to submodules, version bumps, updates to package.json
[minor]: Small changes
[doc]: Updates to documentation
[ux]: Updates to UX
[fix]: Bug fixes
[bin]: Update binary scripts associated with the project
[merge]: Resolved git merge from upstream or otherwise
[refactor]: Refactor of existing code with no external API changes
Marak / vlcrc.js
Created Oct 5, 2011 — forked from garth/vlcrc.js
Remote control multiple VLC apps via the command line using nodejs
View vlcrc.js
// To start vlc with telnet remote control:
// ./VLC --extraintf rc --rc-host
// To connect to multiple vlc's
// node vlcrc.js host1:3000 host2:3000
var net = require('net');
var readline = require('readline');
//addresses of servers
Marak / image.js
Last active Sep 10, 2019 image hook for manipulating images using ImageMagick
View image.js
var gm = require('gm');
module['exports'] = function image (hook, callback) {
Marak / base64.js
Created Feb 8, 2011
An extremely simple implementation of base64 encoding / decoding using node.js Buffers
View base64.js
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
* (C) 2010, Nodejitsu Inc.
var base64 = exports;
base64.encode = function (unencoded) {
Marak / imageResize.js
Last active Jul 31, 2019 example microservice for resizing images
View imageResize.js
module['exports'] = function imageResize (hook, callback) {
// GraphicsMagick fully supported
var gm = require('gm');
// for a more complete example that supports file uploads and streaming uploads
// see:
// grab an image as a url
// no file has been uploaded, fallback to the image "url" parameter
var stream ='');
hook.res.writeHead(200, { 'Content-Type': 'image/png' });


So HAProxy is primalery a load balancer an proxy for TCP and HTTP. But it may act as a traffic regulator. It may also be used as a protection against DDoS and service abuse, by maintening a wide variety of statistics (IP, URL, cookie) and when abuse is happening, action as denying, redirecting to other backend may undertaken ([haproxy ddos config], [haproxy ddos])

Marak / transcodeVideo.js
Last active Jan 14, 2019
Hook for transcoding video streams using FFMpeg
View transcodeVideo.js
var Transcoder = require('stream-transcoder');
module['exports'] = function transcodeVideoStream (hook) {
var readStream =;
hook.debug('Opening read stream to video');
hook.res.writeHead(200, {
"Content-Type": "video/mp4"
Marak / transform.js
Last active Aug 26, 2018
Transform incoming streams of HTTP data
View transform.js
module['exports'] = function logParser (hook) {
// If the hook is not currently streaming, req has already been fully buffered
if (!hook.streaming) {
// To test a streaming Hook you can use Curl:
// echo "foo" | curl --header "content-type: application/octet-stream" --data-binary @-
return hook.res.end('No streaming request detected. \n\nTo test streaming data to this Hook try running this Curl command: \n\n echo "foo" | curl --header "content-type: application/octet-stream" --data-binary @-');
Marak / mockreadwritestream.js
Created May 20, 2011 — forked from indexzero/mockreadwritestream.js
A mock stream for node.js that is both Readable and Writeable.
View mockreadwritestream.js
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
// No need to do anything here, it's just a mock.
util.inherits(MockReadWriteStream, events.EventEmitter);