Skip to content

Instantly share code, notes, and snippets.

@DanielMuller
DanielMuller / mysql_to_athena.sh
Created March 15, 2018 18:30
Extract data from MySQL and upload to S3 for access with Athena
#!/bin/bash
DBUSER=my_username
DBPASS=my_secret_password
DBHOST=my_hostname
DBNAME=my_database_name
TABLE=my_table
BUCKET=my_bucket
yesterdayFile=$(date -d '1 day ago' +"%Y-%m-%d")'.tsv'
@DanielMuller
DanielMuller / http_dump
Created February 6, 2016 18:08
Dump HTTP headers
# From here: http://serverfault.com/questions/504431/human-readable-format-for-http-headers-with-tcpdump/633452#633452
sudo tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'
#!/bin/bash
aws rds modify-db-parameter-group --db-parameter-group-name mysql56-improved --parameters \
ParameterName=character_set_server,ParameterValue=utf8,ApplyMethod=pending-reboot \
ParameterName=collation_server,ParameterValue=utf8_unicode_ci,ApplyMethod=pending-reboot \
ParameterName=tmp_table_size,ParameterValue={DBInstanceClassMemory/16},ApplyMethod=pending-reboot \
ParameterName=max_heap_table_size,ParameterValue={DBInstanceClassMemory/16},ApplyMethod=pending-reboot \
ParameterName=query_cache_type,ParameterValue=1,ApplyMethod=pending-reboot \
ParameterName=query_cache_size,ParameterValue=131072,ApplyMethod=pending-reboot \
ParameterName=table_open_cache,ParameterValue=2500,ApplyMethod=pending-reboot \
@DanielMuller
DanielMuller / openttd_timelapse.py
Created July 29, 2014 18:54
Create a timelapse of a region from your OpenTTD game using the saved games
#!/usr/bin/python
import argparse
import glob
import os
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from distutils.spawn import find_executable
import time
import re
@DanielMuller
DanielMuller / ebs_autoscale.sh
Last active February 2, 2024 13:15
Allow autoscaling EBS volumes based on disk usage
#!/bin/bash
# Allows to attach and remove EBS volumes managed under LVM to
# have a dynamically sized partition attached to an EC2 instance
#
# Intance needs either to be launched with a role able to access to relevant AWS API endpoints
# or the credentials can be hardcoded in the config.
#
# Minimal IAM Role:
# {