Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@max-mapper
max-mapper / readme.md
Last active August 8, 2016 18:45
simple 4mb buffer proxy benchmarks

simple 4mb buffer proxy benchmarks

the goal: to do fast virtual host routing, e.g. to have a single process on a machine listening on port 80 and proxying data based on HTTP Host to other non-port-80 web processes on the same machine

many people use nginx for this because nginx is faster than node is currently for data-heavy applications (see below)

about these benchmarks

they use the JS proxies from https://github.com/substack/bouncy/tree/master/bench

@yocontra
yocontra / gulpfile.js
Last active January 1, 2016 00:29
gulpfile for a simple livereload static web server. this is a proof of concept that uses no plugins to do the work. obviously there are plugins that eliminate almost all of this code but i thought it would be a fun demonstration. this will trigger livereload any time any file is modified in the current working directory. it also serves the curre…
var gulp = require('gulp');
var gutil = require('gulp-util');
var express = require('express');
var path = require('path');
var tinylr = require('tiny-lr');
var createServers = function(port, lrport) {
var lr = tinylr();
lr.listen(lrport, function() {
gutil.log('LR Listening on', lrport);
@pgte
pgte / auth.md
Last active December 31, 2015 14:49

I built this service rendered over HTTPS.

We're using the Hawk protocol to authenticate message producers, but since the service will use HTTPS, Hawk is an overkill in my opinion.

Some of the drawbacks of using Hawk in my opinion:

  1. Signs whole message: overkill when you're using TLS
  2. Tries to be stateless on the server-side and implements a sort of message non-repeatability by including a timestamp inside the message. The timestamp has to be equal to the server-side time take or give 1 minute. This imposes time synchronizatin between client and server, which is hard to enforce.
@juliangruber
juliangruber / README.md
Last active March 24, 2021 02:00
lightweight node-websocketd

node-websocketd

A lightweight node port of websocketd, originally written in go.

Usage

node-websocketd --port=8080 ./count.sh
@caquino
caquino / syslog-ng.conf
Created November 26, 2013 16:54
syslog nginx configuration
source s_nginx_20 { pipe("/srv/logs/access.log" program_override("nginx-access-log")); };
source s_nginx_21 { pipe("/srv/logs/error.log" program_override("nginx-error-log")); };
filter f_nginx_20 { match("nginx-access-log" value("PROGRAM")); };
filter f_nginx_21 { match("nginx-error-log" value("PROGRAM")); };
destination d_remote { tcp("central.syslog", port(514)); };
log { source(s_nginx_20); filter(f_nginx_20); destination(d_messages); };
log { source(s_nginx_21); filter(f_nginx_21); destination(d_messages); };
@nzakas
nzakas / versioning.md
Created November 24, 2013 23:01
Versioning in a repo

Versioning in a Repository

Lately I've been doing a lot of thinking around versioning in repositories. For all the convenience and ubiquity of package.json, it does sometimes misrepresent the code that is contained within a repository. For example, suppose I start out my project at v0.1.0 and that's what's in my package.json file in my master branch. Then someone submits a pull request that I merge in - the version number hasn't changed even though the repository now no longer represents v0.1.0. The repository is actually now in an intermediate state, in between v0.1.0 and the next official release.

To deal with that, I started changing the package.json version only long enough to push a new release, and then I would change it to a dev version representing the next scheduled release (such as v0.2.0-dev). That solved the problem of misrepresenting the version number of the repository (provided people realize "dev" means "in flux day to day"). However, it introduced a yucky workflow that I really hate

@max-mapper
max-mapper / index.js
Created November 20, 2013 04:44
requirebin sketch
var media = require('rtc-media')
var animator = require('animator')
var whammy = require('whammy')
var RECORDING_LENGTH = 2000
var QUALITY = 1
var WIDTH = 640
var HEIGHT = 480
var frames = []
@max-mapper
max-mapper / index.js
Created November 20, 2013 00:59
requirebin sketch
var bcsv = require('binary-csv')
var xhr = require('xhr')
var bops = require('bops')
var through = require('through')
var url = require('url')
var createTable = require('data-table')
var insertCSS = require('insert-css')
var concat = require('concat-stream')
var Buffer = require('buffer').Buffer
@creationix
creationix / maze.js
Last active December 27, 2015 16:59
A simple maze generator I write for my programming class I'm teaching.
function makeMaze(width, height) {
// First we need to initialize the cells and the order list
// Each cell references the cell to it's left and top if there are any.
// Each wall between the cells has an order entry.
var cells = [];
var order = [];
for (var y = 0; y < height; y++) {
var row = cells[y] = [];
for (var x = 0; x < width; x++) {
@hekike
hekike / gist:7289302
Last active December 27, 2015 07:29
How to detect the filetype of the stream in NodeJS.
var
beginBuff,
beginBuffStr;
// type detection
if (chunkNum === 0) {
beginBuff = data.slice(0, 8);
beginBuffStr = beginBuff.toString('hex', 0, beginBuff.length);
// jpg