Skip to content

Instantly share code, notes, and snippets.

@DoubleMalt
DoubleMalt / technical-due-diligence.md
Last active October 4, 2019 18:20
A checklist what you should ask when talking over a code base

Technical Due Diligence

Architecture

  • Component Overview
  • Technologies (DB, Languages, Frameworks)

Functionalities

@jult
jult / sysctl.conf
Last active May 4, 2025 01:51
[Debian 12 update!] sysctl config for linux server with 32 GB DDR RAM or more, SSD and 1Gbe (or faster) NIC
# IPv6 Configuration
# -> note that I have disabled ip6 for our internet-connection (wan/eth0) because
# -> my upstream/ISP (still) does not do IPv6. The rest, even localhost, does ip6 stuff.
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.wan.disable_ipv6 = 1
# Packet Forwarding
@zveronline
zveronline / haproxy-cloudflare
Last active September 29, 2023 07:17 — forked from sielay/gist:0aa4077829f35f5e0310f9e0cc9fdc71
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
acl from_cf src -f /etc/haproxy/cf-ips
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
option forwardfor if-none

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@sielay
sielay / gist:0aa4077829f35f5e0310f9e0cc9fdc71
Created August 10, 2016 10:06
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
frontend www-http
bind :80
bind *:443 ssl crt /etc/haproxy/certs no-sslv3
capture request header X-Forwarded-For len 50
acl is_cf req.hdr(cf-connecting-ip) -m found
http-request set-header X-Client-IP %[src] if !is_cf
http-request set-header X-Client-IP %[hdr(cf-connecting-ip)] if is_cf
@thanpolas
thanpolas / Gruntfie.js
Last active December 26, 2015 16:48
Grunt Config for node server + livereload
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
express: {
options: {
// Override defaults here
},
web: {
options: {
@jonschlinkert
jonschlinkert / markdown-cheatsheet.md
Last active April 23, 2025 17:58
A better markdown cheatsheet.
@dmytro
dmytro / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
var playSingleChime = function()
{
var context = new webkitAudioContext(),
gain = context.createGainNode(),
osc = context.createOscillator();
osc.connect(gain);
gain.connect(context.destination);
osc.frequency.value = 1000.0;
var context = new webkitAudioContext(),
oscillator = context.createOscillator();
oscillator.type = oscillator.SQUARE;
oscillator.frequency.value = 1000;
oscillator.connect(context.destination);
oscillator.noteOn && oscillator.noteOn(0);
setTimeout('oscillator.disconnect()', 500);