Skip to content

Instantly share code, notes, and snippets.

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

#!/bin/sh
# Prerequisites: debootstrap and schroot.
# Don't forget to adapt YOUR_USER_NAME below.
# Use the 32-bit version of Spotify (and Debian). The 64-bit version
# often crashes.
cd
debootstrap --arch i386 squeeze /var/chroot/debian-squeeze-i386 http://ftp.de.debian.org/debian/
# I am assuming you are running this on ubuntu saucy 13.10
apt-get update
apt-get -y install debootstrap schroot aufs-tools
modprobe aufs # don't really know what this does
mkdir -p /var/chroot
# plop down the schroot config for saucy ubuntu chroot
cat >/etc/schroot/schroot.conf <<EOF
[saucy]
description=Ubuntu Saucy (build box)
# ******************************
# * Quick guide to pythonicity *
# * by @csparpa *
# ******************************
# === ZEN ===
import this
# Courtesy http://plumberjack.blogspot.com/2010/12/colorizing-logging-output-in-terminals.html
# Tweaked to use colorama for the coloring
import colorama
import logging
import sys
class ColorizingStreamHandler(logging.StreamHandler):
color_map = {

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@zennro
zennro / gist:9807714
Created March 27, 2014 13:37
generate entropy for corosync-keygen
while /bin/true; do dd if=/dev/urandom of=/tmp/100 bs=1024 count=100000; for i in {1..10}; do cp /tmp/100 /tmp/tmp_$i_$RANDOM; done; rm -f /tmp/tmp_* /tmp/100; done & /usr/sbin/corosync-keygen
#!/usr/bin/env bash
# call like this on the target server:
# NODENAME='foo' CHEF_ENV='production' RUNLIST='["role[foo]","recipe[bar]"]' CHEFREPO='git@example.com:repo.git' bash <( curl -L https://raw.github.com/gist/1026628 )
# You will need to ensure that the ssh key is already set up on the server.
set -e
export CHEF_DIR="${HOME}/chef"
sudo rm -rf $CHEF_DIR
mkdir -p "$CHEF_DIR"
#!/usr/bin/env python
"""
- read subprocess output without threads using Tkinter
- show the output in the GUI
- stop subprocess on a button press
"""
import logging
import os
import sys
from subprocess import Popen, PIPE, STDOUT
#!/usr/bin/env python
"""Try to cause MemoryError by sending large data via multiprocessing.Pipe.
Context: http://stackoverflow.com/q/22150703
"""
from multiprocessing import Process, Pipe
def send_big_data(conn):
data = b"a" * (1 << 30) # 1GB
conn.send(data)