Skip to content

Instantly share code, notes, and snippets.


Alex Chamberlain apchamberlain

  • Between jobs... hire me!
  • Columbia County, OR
View GitHub Profile
apchamberlain /
Last active Jul 16, 2018
One-line web servers

Instant Webservers! Just add electrons!

All these run on localhost:8000 unless otherwise noted and serve the index.html file in the current directory in an insecure session, i.e, open in any browser. All except Python's SimpleHTTPServer allow multiple simultaneous client connections. The Node http-server module is the most robust although none of these is suitable for production. The true one-liners (all but Node) should all run without any dependencies on a standard OS X or Linux install.

Python 2

    python -m SimpleHTTPServer


    python2 -m SimpleHTTPServer
apchamberlain /
Created Jun 9, 2015
a horrible horrible hack
#!/usr/bin/env perl
# usage: script 'command' 'time'
# time format must be: 14/01/09 21:21
my $printprefix = 'VIAGRA: ';
my $silent = (@ARGV[2] eq '--silent' || @ARGV[2] eq '-s')? 1 : 0;
use Time::Piece;
my $start = Time::Piece->new;
apchamberlain / csv2json.rb
Created Apr 29, 2015
Simple CSV-to-JSON with no external dependencies other than the default OS X Ruby install. Because I keep forgetting how to do this. Pipe through `jq` for prettier output.
View csv2json.rb
#!/usr/bin/env ruby
require 'json'
# Beware, this doesn't support embedded escaped commas, but it does
# handle quotes around field values with spaces in them correctly.
class Array
def to_h()
apchamberlain / dotsshslashconfig
Created Apr 23, 2015
SSH config for optimum TRAMP
View dotsshslashconfig
Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
Compression yes
# Also make sure that .bashrc is empty or minimal on the destination, and sshd is as new as possible
apchamberlain /
Last active Sep 9, 2015
Produce manifest code for testing Puppet with a catalog of 'n' classes with 'm' resources each.
#!/usr/bin/env perl
# Produce test code for 'n' classes with 'm' resources each for site.pp
# e.g., ./samplePPgen 1 1000 foo # 1 class with 1000 resources on node foo
# e.g., ./samplePPgen 1000 2 # 1000 classes with 2 resources each on default
# If parameters are omitted, the default output is 10 classes with 10
# file resources each, on the default node (meaning all nodes if you
apchamberlain / service-completion.bash
Last active Dec 24, 2015
bash completion for 'service' command on Linux
View service-completion.bash
# Add bash completion for services: it tries to complete the service you want
# based on the output of "service --status-all"
# Source this as a separate file from your .bash_profile or just copy and paste into it
# Inspired by
__service_known_services() {
service --status-all |awk '{print $1}'