Skip to content

Instantly share code, notes, and snippets.

Alex Chamberlain apchamberlain

  • Between jobs... hire me!
  • Columbia County, OR
Block or report user

Report or block apchamberlain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@apchamberlain
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 http://en.newinstance.it/2011/06/30/ssh-bash-completion/
__service_known_services() {
service --status-all |awk '{print $1}'
}
@apchamberlain
apchamberlain / samplePPgen.pl
Last active Sep 9, 2015
Produce manifest code for testing Puppet with a catalog of 'n' classes with 'm' resources each.
View samplePPgen.pl
#!/usr/bin/env perl
# Produce test code for 'n' classes with 'm' resources each for site.pp
#
# Usage: ./samplePPgen CLASSCOUNT RESOURCECOUNT NODENAME
# 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
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
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
apchamberlain / viagra.pl
Created Jun 9, 2015
a horrible horrible hack
View viagra.pl
#!/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
apchamberlain / instantwebservers.md
Last active Jul 16, 2018
One-line web servers
View instantwebservers.md

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 http://127.0.0.1:8000 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

or

    python2 -m SimpleHTTPServer
You can’t perform that action at this time.