Skip to content

Instantly share code, notes, and snippets.

View mkdynamic's full-sized avatar

Mark Dodwell mkdynamic

View GitHub Profile
@mkdynamic
mkdynamic / ajaxsubscribe.html
Last active December 7, 2017 08:18 — forked from jdennes/LICENSE
<!-- 1. Take your Campaign Monitor subscribe form as generated from within your account: -->
<form action="http://myaccount.createsend.com/t/r/s/aljhk/" method="post" id="subForm">
<div>
<label for="name">Name:</label><br /><input type="text" name="cm-name" id="name" /><br />
<label for="aljhk-aljhk">Email:</label><br /><input type="text" name="cm-aljhk-aljhk" id="aljhk-aljhk" /><br />
<input type="submit" value="Subscribe" />
</div>
</form>
@mkdynamic
mkdynamic / monkey.rb
Created December 15, 2013 05:23
Use class_eval for monkey patching classes, to avoid forgetting to load the target class and ending up with a more cryptic type error.
# 1. in one file, assuming that Foo is loaded/auto-loaded
class Foo
def monkey_patch
# ...
end
end
# 2. later, the real Foo (in another file) is loaded
class Foo < File
end
class Todo < ActiveRecord::Base
concerning :EventTracking do
included do
has_many :events
end
def latest_event
...
end
@mkdynamic
mkdynamic / jpp.rb
Created December 19, 2013 08:35
Pretty print JSON command.
#!/usr/bin/env ruby
require 'optparse'
require 'json'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-x", "--extended", "Use awesome print") do |*|

Launch your EC2 EBS instance with two SSDs on the second and third slots (after the root EBS volume), with this in your userdata:

#!/usr/bin/env bash

umount /dev/xvdb
umount /dev/xvdc
apt-get install mdadm -y
mkdir /u01

cat > /etc/init/mount-ephermal-ssd.conf <

-sws_flags fast_bilinear -sws_dither auto
-sws_flags fast_bilinear -sws_dither none
-sws_flags fast_bilinear -sws_dither bayer
-sws_flags fast_bilinear -sws_dither ed
-sws_flags fast_bilinear -sws_dither a_dither
-sws_flags fast_bilinear -sws_dither x_dither
-sws_flags fast_bilinear+accurate_rnd -sws_dither auto
-sws_flags fast_bilinear+accurate_rnd -sws_dither none
-sws_flags fast_bilinear+accurate_rnd -sws_dither bayer
-sws_flags fast_bilinear+accurate_rnd -sws_dither ed
@mkdynamic
mkdynamic / openssl.sh
Last active August 29, 2015 14:17 — forked from colby/openssl.sh
#!/bin/bash
awk=$(which awk || echo 'missing: install awk' && exit 1)
# update apt
sudo apt-get update
# get ssl related packages from simulated upgrade
sudo apt-get upgrade -s | grep ssl | grep Inst | $awk '{print $2}' | xargs -t sudo apt-get install -y
@mkdynamic
mkdynamic / openssl.sh
Last active August 29, 2015 14:17 — forked from colby/openssl.sh
#!/bin/bash
awk=$(which awk || echo 'missing: install awk' && exit 1)
# update apt
sudo apt-get update
# get ssl related packages from simulated upgrade
sudo apt-get upgrade -s | grep ssl | grep Inst | $awk '{print $2}' | xargs -t sudo apt-get install
#!/bin/bash
awk=$(which awk || echo 'missing: install awk' && exit 1)
# update apt
sudo apt-get update
# get ssl related packages from simulated upgrade
sudo apt-get upgrade -s | grep ssl | grep Inst | $awk '{print $2}' | xargs -t sudo apt-get -y install