Skip to content

Instantly share code, notes, and snippets.

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
@toddlers
toddlers / ec2tags.rb
Created July 8, 2013 14:38
Hack to get ec2 tags to facter. Depends on aws-cli (https://github.com/aws/aws-cli), jq (http://stedolan.github.io/jq/) and the JSON RubyGem (http://rubygems.org/gems/json)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") =! nil
instance_id = Facter.value("ec2_instance_id")
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region sa-east-1 | jq '[.Tags[] | {key: .Key, value: .Value}]'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
fact = "ec2_tag_#{tag["key"]}"
@toddlers
toddlers / git_file_delete.txt
Created July 12, 2013 11:39
You can use the — option in git log to see the commit history for a file, even if you have deleted the file.
# see the changes for a file, even if it was deleted
git log -- [file_path]
# limit the output to only the last commit that touched the file
git log -1 -- [file_path]
# include some statistics, eg. how many files were deleted
git log -1 --stat -- [file_path]
@toddlers
toddlers / oozie.txt
Created July 21, 2013 07:35
oozie info
Apache Oozie
=============
What is Oozie
--------------
Oozie is an extensible, scalable and reliable system to define, manage, schedule, and execute complex Hadoop workloads via web services. More specifically, this includes:
* XML-based declarative framework to specify a job or a complex workflow of dependent jobs.
* Support different types of job such as Hadoop Map-Reduce, Pipe, Streaming, Pig, Hive and custom java applications.
@toddlers
toddlers / golangsetup.sh
Created July 23, 2013 14:59
setting up golang on mac osx
# OS X Go Setup
# Assumes:
# + Homebrew has been installed correctly.
# + Homebrew-cask has been tapped and installed correctly.
# Install Go lang latest (1.1.1 as of May 13, 2013)
###############################################################################
brew install go
<% if @colo == "a" then -%>
server server1 foo1.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
server server2 foo2.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
server server3 foo3.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
<% elsif @colo == "b" then -%>
server server1 foo1.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
server server2 foo2.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
server server3 foo3.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
<% elsif @colo == "c" then -%>
server server1 foo1.com:8088 check port 8088 inter 5000 rise 2 fall 3 maxconn 5000
@toddlers
toddlers / haproxy.conf
Last active March 6, 2023 10:02
haproxy config with directives explained
global
log 127.0.0.1 local1 info info
user haproxy
group haproxy
daemon
#quiet
#debug
stats socket /var/run/haproxy/haproxy.sock mode 0600 level admin
defaults
@toddlers
toddlers / haproxy_add_remove.txt
Created July 25, 2013 14:36
Adding servers in haproxy without restarting haproxy
Adding a serverA ipA:portA to the 'query_backend':
echo "add server query_backend/serverA ipA:portA check inter 3000 rise 2 fall 3 maxconn 50" | socat stdio unix-connect:/var/haproxy.socket
Removing serverA again:
echo "remove server query_backend/serverA" | socat stdio unix-connect:/var/haproxy.socket
@toddlers
toddlers / git-loglive.sh
Created August 2, 2013 05:03
watching live logs of git repo
#!/bin/bash
while :
do
clear
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
sleep 1
done