Skip to content

Instantly share code, notes, and snippets.

@mmb
mmb / cloudformation_a_record_from_eip.json
Created September 29, 2015 06:58
creating a route 53 A record pointing to an elastic ip
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"aRecord": {
"Properties": {
"HostedZoneId": {
"Ref": "hostedZone"
},
"Name": "test.mmbtest.com",
"ResourceRecords": [
@mmb
mmb / graphite_grafana.sh
Last active August 4, 2017 20:06
graphite/statsd/grafana setup on new Amazon Linux instance
# graphite/statsd/grafana setup on new Amazon Linux instance
# add http://graphite/ to grafana as a data source
sudo su
yum update --assumeyes
yum install --assumeyes docker
service docker start
docker \
run \
@mmb
mmb / gist:15e62996d2053bba7e21
Last active August 29, 2015 14:27
watch Cloud Foundry gorouter routing table on bosh-lite
watch -d 'curl -s http://router:router@10.244.0.22:8080/routes \
| jq -r "to_entries[] | .key+\" \"+.value[].address+\" \"+.value[].route_service_url" | \
column -t'
#!/bin/bash
set -e
COPY_PATH=$(mktemp -t add_key)
MOUNT_PATH=/Volumes/mmb
KEY_EXPIRES_AT=$(date -v18H -v0M -v0S +%s)
NOW=$(date +%s)
KEY_LIFETIME=$(($KEY_EXPIRES_AT - $NOW))
if [ "$KEY_LIFETIME" -lt "1" ]; then
@mmb
mmb / gist:a260ccc14b739b73c181
Created March 28, 2015 08:08
WeeChat python script to print python version and path
import sys
import weechat
if weechat.register('test', 'test', 'test', 'test', 'test', 'shutdown', ''):
weechat.prnt('', str(sys.version))
weechat.prnt('', str(sys.path))
@mmb
mmb / run_and_eject.sh
Last active August 29, 2015 14:17
shell script that ejects the USB drive it's on
#!/bin/bash
set -e
COPY_PATH=/tmp/mount_mmb.sh
MOUNT_PATH=/Volumes/mmb
cat > $COPY_PATH << EOF
#!/bin/bash
set -e
@mmb
mmb / rmagick_anim_test.rb
Created December 2, 2014 05:09
How to tell if an image is animated using rmagick
require 'rmagick'
img_list = Magick::ImageList.new('http://i.imgur.com/Txjn52a.gif')
p img_list.size
img_list = Magick::ImageList.new('http://i.imgur.com/UthfKGQ.jpg')
p img_list.size
@mmb
mmb / gist:3cee36e6fd16bf33df0b
Created July 31, 2014 06:46
Rack::Test::UploadedFile doesn't respond to encoding
def create
@src_image = SrcImage.new(src_image_params)
@src_image.user = current_user
read_image_data @src_image
respond_to do |format|
if @src_image.save
create_success(format)
else
@mmb
mmb / gist:f2ae27e66df8c473a2ce
Created July 12, 2014 04:27
test wkhtmltopdf header
<!DOCTYPE html>
<p>hello</p>
@mmb
mmb / plz_verify
Last active August 29, 2015 14:03
When USB drives are mounted, check them for a script called plz_verify.sh and run it if found.
#!/usr/bin/env ruby
# When USB drives are mounted, check them for a script called plz_verify.sh
# and run it if found.
#
# symlink all USB volumes you want to check into ~/usb
# ln -s /Volumes/mmb ~/usb/mmb
require 'logger'
require 'set'