Skip to content

Instantly share code, notes, and snippets.

View Marak's full-sized avatar


View GitHub Profile
procrastinatio /
Created October 25, 2017 06:04
Rate limiting with HAproxy


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])

usergenic / npm_import.bash
Last active May 6, 2022 13:01
npm link sucks because symlinks and node_modules, so i use this instead
# Given a single argument, being the folder to a local copy of the npm package to "install"
# copy it to the local node_modules folder, then make sure it has no node_modules of its own.
# This way you can npm install locally afterwards to cover remaining dependencies and
# everything will work right.
function npm_import {
export pkgname=`basename $1`
export pkgdir="node_modules/$pkgname"
if [ -d "$pkgdir" ]; then
rm -rf "$pkgdir"
-- ref
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
pyhedgehog / child.js
Last active September 30, 2015 14:05
Child pipe proof-of-concept
if(!process.send) {
console.log("Not started with accessible parent IPC.");
process.on('message', function(json) {
console.log('parent->child message passed', json);
process.send({type:'got', payload:json});
if(json.type === 'exit') process.exit(0);
Marak /
Last active June 20, 2024 13:33
docker cheat sheet

Things I wish I knew before I started using Docker


Init docker on mac os

boot2docker init

Restart docker vm on mac os

boot2docker up
xdamman /
Created July 2, 2014 21:03
Install latest ffmpeg on ubuntu 12.04 or 14.04
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
creationix / formatStackTrace.js
Created September 21, 2011 22:29
Beginning of an event-source hook for system-wide stack handling hooks.
// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
tj / event-proxy.js
Created August 30, 2011 05:58
proxy API for node event emitters (prototype)
var EventEmitter = require('events').EventEmitter;
var request = new EventEmitter;
function Proxy(emitter, callbacks) {
if (!(this instanceof Proxy)) return new Proxy(emitter, callbacks);
var self = this;
// callbacks...