Skip to content

Instantly share code, notes, and snippets.

View test
1 23 test!
ciao test
View svn checkout one file
svn checkout <url_of_big_dir> <target> --depth empty
cd <target>
svn up <file_you_want>
@jeremyj
jeremyj / delete stray snapshots
Created Oct 22, 2014
Delete stray snapshots
View delete stray snapshots
require 'aws-sdk'
KEY = 'xxx'
SEC = 'yyy'
ec2 = AWS::EC2.new(:access_key_id=> KEY, :secret_access_key=> SEC, :region=> 'eu-west-1')
volumes = ec2.volumes.tagged('Backup','backup','BACKUP').tagged_values('true','True','TRUE')
snapshots = ec2.snapshots.with_owner(:self).tagged('aws_sm').tagged_values('true')
@jeremyj
jeremyj / haproxy rate limiting
Last active Jun 15, 2020
haproxy rate limiting
View haproxy rate limiting
HTTP request limiting ===================================================================================================================
frontend ft_web
# Use General Purpose Couter (gpc) 0 in SC1 as a global abuse counter
# Monitors the number of request sent by an IP over a period of 10 seconds
stick-table type ip size 1m expire 10s store gpc0,http_req_rate(10s)
tcp-request connection track-sc1 src
# refuses a new connection from an abuser
tcp-request content reject if { src_get_gpc0 gt 0 }
@jeremyj
jeremyj / watch haproxy sticky tables
Created Oct 16, 2014
watch haproxy sticky tables
View watch haproxy sticky tables
watch -n 1 'echo "show table http" | socat unix:/var/run/haproxy.sock -'
watch -n 1 'echo "show table public" | socat unix:/var/run/haproxy.sock -'
@jeremyj
jeremyj / delete leftover CreateImage snapshots
Last active Aug 29, 2015
delete leftover CreateImage snapshots
View delete leftover CreateImage snapshots
#!/usr/bin/ruby
require 'rubygems'
require 'aws-sdk'
KEY = 'xxx'
SEC = 'xxx'
REGION = 'eu-west-1'
ec2 = AWS::EC2.new(:access_key_id=> KEY, :secret_access_key=> SEC, :region=> REGION)
@jeremyj
jeremyj / regex for IP addresses
Last active Aug 29, 2015
regex for IP addresses
View regex for IP addresses
sed 's/\,\ [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}//g'
@jeremyj
jeremyj / Ubuntu Ruby Nogokiri requirements:
Created Oct 9, 2014
Ubuntu Ruby Nogokiri requirements:
View Ubuntu Ruby Nogokiri requirements:
Ubuntu Ruby Nogokiri requirements:
ruby2.0
libxslt-dev
libxml2-dev
ruby1.9.1-dev
build-essential
@jeremyj
jeremyj / Serial Communication in OSX Terminal
Last active Aug 29, 2015
Serial Communication in OSX Terminal
View Serial Communication in OSX Terminal
screen /dev/tty.usbserial 9600
@jeremyj
jeremyj / Bash increment variable count
Last active Aug 29, 2015
Bash increment variable count
View Bash increment variable count
#!/bin/bash
i=0
while [ $i -le 10 ]; do
i=$(($i+1))
echo $i
done