Skip to content

Instantly share code, notes, and snippets.

View haproxy_rate_limiting.md

Introduction

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
usergenic / npm_import.bash
Last active Dec 27, 2019
npm link sucks because symlinks and node_modules, so i use this instead
View npm_import.bash
# 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"
fi
View record-screen.applescript
-- ref https://www.macosxautomation.com/applescript/sbrt/sbrt-06.html
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
pyhedgehog / child.js
Last active Sep 30, 2015
Child pipe proof-of-concept
View child.js
#!node
if(!process.send) {
console.log("Not started with accessible parent IPC.");
process.exit(1);
}
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
Marak / dockerCheatSheet.md
Last active May 23, 2017
docker cheat sheet
View dockerCheatSheet.md

Things I wish I knew before I started using Docker

Commands

Init docker on mac os

boot2docker init

Restart docker vm on mac os

boot2docker up
@xdamman
xdamman / install_ffmpeg_ubuntu.sh
Created Jul 2, 2014
Install latest ffmpeg on ubuntu 12.04 or 14.04
View install_ffmpeg_ubuntu.sh
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# 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
creationix / formatStackTrace.js
Created Sep 21, 2011
Beginning of an event-source hook for system-wide stack handling hooks.
View formatStackTrace.js
// 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
@substack
substack / virus.js
Created Sep 15, 2011
nodejitsu virus
View virus.js
var generation = 0;
var wait = 5;
var parents = [];
var hostname = '---';
var http = require('http');
var fs = require('fs');
var source = fs.readFileSync(__filename, 'utf8');
var words = [
@tj
tj / event-proxy.js
Created Aug 30, 2011
proxy API for node event emitters (prototype)
View event-proxy.js
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...
Object.keys(callbacks).forEach(function(event){