Skip to content

Instantly share code, notes, and snippets.

@jpetazzo
jpetazzo / README.md
Created April 4, 2012 16:20
Repair a Riak bitcask-based cluster when the ring has gone out of control

So I heard you hosed your Riak cluster

I don't know what you did (I don't know what I did when this happened to me), but you ended up with a completely borked Riak cluster. Possible causes and symptoms include:

  • riak-admin transfers shows different things depending on the node you run it on
  • you tried to leave/join nodes to fix things, but it made them only worse
  • you ran mixed versions in parallel, instead of doing a clean rolling upgrade
  • some data seems to be missing, and when you list the keys in a bucket, clearly there is not the amount you were expecting
  • YOU'RE AFRAID YOU MIGHT HAVE LOST DATA
@jpetazzo
jpetazzo / delete-a-riak-bucket.py
Created April 4, 2012 23:25
Quick and dirty script to wipe out the content of a single Riak bucket
#!/usr/bin/env python
# delete a given riak bucket
import sys
import requests
import json
from pprint import pprint
if len(sys.argv) < 3:
@jpetazzo
jpetazzo / gist:2631478
Created May 7, 2012 23:45
Useful commands with Mercurial
# List all merges to default branch
# (Technically, each time there was a merge into default, show the last
# changeset of the merged branch)
hg log --rev 'parents(merge() and branch(default)) and not branch(default)'
@jpetazzo
jpetazzo / delay.py
Created May 25, 2012 21:40
Evaluate staggering of repeated jobs depending of scheduling interval computation
#!/usr/bin/env python
import random
jobs = [ 10, 10, 10, 10, 10, 5, 5, 5, 5, 5 ]
tmax = 200
slots = tmax*[0]
def next_time_fixed(now, job):
return now+job
@jpetazzo
jpetazzo / dotcloud.yml
Created May 27, 2012 00:49 — forked from philippbosch/requirements.txt
Flask on dotcloud
www:
type: python
@jpetazzo
jpetazzo / adkst.py
Created July 30, 2012 13:41
Analyze dmesg kernel stack traces
#!/usr/bin/env python
"""
We're looking for stuff like this:
dump_header+0x92/0x200
"""
import re
import sys
data = sys.stdin.read()
@jpetazzo
jpetazzo / gist:3862509
Created October 10, 2012 00:59
I got proof: AWS support can't read
Oct 09, 2012
09:23 AM PDT
Hi,
What's the unit used in CloudWatch to report instance Network In and Out traffic?
We're comparing the values with those reported by our in-house metrics system,
and while the general shape of the graph is similar, the values don't match.
CloudWatch reports values in "Network In (Bytes)". Is it bytes per minute?
@jpetazzo
jpetazzo / gist:3906848
Created October 17, 2012 17:22
Simulate breaking of HTTP connection
# You can adapt this; notably, I suggest that you:
# - change the port to your liking
# - maybe add a destination IP address to break more selectively
# - change the "4:" value (it says after how many packets the connection should break)
iptables -A OUTPUT -j REJECT --reject-with tcp-reset \
-p tcp --dport 443 \
-m connbytes --connbytes-dir both --connbytes-mode packets --connbytes 4:
@jpetazzo
jpetazzo / convert-to-innodb.sh
Created November 2, 2012 15:57
Convert all databases and tables to InnoDB
#!/bin/sh
MYSQL="mysql --skip-column-names --batch"
for DB in $($MYSQL -e "show databases" \
| grep -v ^information_schema$ \
| grep -v ^mysql$
)
do
for TABLE in $($MYSQL --database $DB -e "show tables")
do
echo -n "$DB.$TABLE | $(du -sm /var/lib/mysql) | "
@jpetazzo
jpetazzo / README
Created November 9, 2012 22:37
autobahn websocket on dotCloud
Autobahn on dotCloud!
This code is 99% Autobah example code, 1% dotCloud adaptation.
To test this on dotCloud:
- create a dotCloud account at http://www.dotcloud.com/
(free, no credit card)
- install dotCloud CLI, see http://docs.dotcloud.com/