Skip to content

Instantly share code, notes, and snippets.

View mkdynamic's full-sized avatar

Mark Dodwell mkdynamic

View GitHub Profile
@mkdynamic
mkdynamic / web-servers.md
Created September 30, 2022 00:29 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
#!/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
@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
@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
-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

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 <

@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 |*|
class Todo < ActiveRecord::Base
concerning :EventTracking do
included do
has_many :events
end
def latest_event
...
end
@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