Skip to content

Instantly share code, notes, and snippets.

David Wooldridge z0mbix

Block or report user

Report or block z0mbix

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
View vim-tip.md
  • Run vim without loading ~/.vimrc: vim -u NONE
  • Add quotes around a select word (Requires vim-surround): S"
  • Select entire word no matter where the cursor is: viw
  • Select entire word including trailing space no matter where the cursor is: vaw
  • Enclose entire line in quotes (Needs vim-surround plugin): yss”
  • Comment out paragraph (Requires vim-commentary): gcap
  • Delete quotes around a string: ds"
  • Convert buffers to tabs: :tab ball
  • Close buffer: :bd
  • Uppercase selection: gU
@z0mbix
z0mbix / puppet-custom-fact-role.sh
Created Jul 7, 2015
Get an Ec2 instance's role from a tag
View puppet-custom-fact-role.sh
#!/usr/bin/env bash
meta_url="http://169.254.169.254/latest/meta-data"
instance_id=$(curl -sf ${meta_url}/instance-id)
role=$(aws ec2 describe-tags --filters \
"Name=resource-type,Values=instance" \
"Name=resource-id,Values=${instance_id}" \
"Name=key,Values=role" \
| jq -r .Tags[].Value)
@z0mbix
z0mbix / ec2-get-instance-tags
Created Jul 3, 2015
Bootstrap an EC2 instance with it's role, environment and name
View ec2-get-instance-tags
#!/usr/bin/env bash
meta_url="http://169.254.169.254/latest/meta-data"
instance_id=$(curl -sf ${meta_url}/instance-id)
# Get role
aws ec2 describe-tags --filters \
"Name=resource-type,Values=instance" \
"Name=resource-id,Values=${instance_id}" \
"Name=key,Values=role" \
@z0mbix
z0mbix / ssh-ec2
Created Jul 3, 2015
SSH to an EC2 instance by name
View ssh-ec2
#!/usr/bin/env bash
#
# SSH to an EC2 instance by name
#
# You need the AWS cli (pip install awscli)
#
if [[ -z $1 ]]; then
echo 'You must specify an instance name!'
exit 1
@z0mbix
z0mbix / tcpdump-es-capture
Created Dec 19, 2014
Capture Elasticsearch Queries
View tcpdump-es-capture
# tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
14:32:33.525122 IP 127.0.0.1.49777 > 127.0.0.1.9200: Flags [P.], seq 313752908:313753888, ack 2465010394, win 257, options [nop,nop,TS val 2684167067 ecr 2684167066], length 980
E...^.@.@............q#...}L...............
..#...#.GET /index/_search HTTP/1.1
Host: 127.0.0.1:9200
Accept: */*
Content-Length: 845
Content-Type: application/x-www-form-urlencoded
View post-deploy-gif
# http://replygif.net/about
# You need jq and rl
if which rl >/dev/null; then
replygif_api_key='39YAprx5Yi'
tags=(pleased approval excited party clapping dance happy)
random_tag=${tags[$RANDOM % ${#tags[@]} ]}
gif=$(curl -s http://replygif.net/api/gifs?api-key=${replygif_api_key}\&tag=${random_tag} | jq .[].file -r | rl -c1)
hipchat_message="(success) -> ${gif}"
fi
@z0mbix
z0mbix / os x syncthing plist howto
Created May 29, 2014
Example launchd plist for syncthing
View os x syncthing plist howto
Create the XML plist file ~/Library/LaunchAgents/net.syncthing.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.syncthing</string>
<key>Program</key>
<string>/Users/zombie/bin/syncthing</string>
View gist:10504385
### Keybase proof
I hereby claim:
* I am z0mbix on github.
* I am z0mbix (https://keybase.io/z0mbix) on keybase.
* I have a public key whose fingerprint is 310E C49B 374C EE0B 5A53 DB8E FFCE 5C10 5D81 AB88
To claim this, I am signing this object:
@z0mbix
z0mbix / gist:8407613
Last active Jan 3, 2016
Packer.io Rackspace UK cloud configuration failure
View gist:8407613
I have exported SDK_USERNAME, SDK_PASSWORD and SDK_PROVIDER=rackspace-uk
I already use these credentials with other rackspace API tools like pyrax.
$ packer validate staging-web-rackspace.json
Template validated successfully.
$ cat staging-web-rackspace.json
{
"builders":
@z0mbix
z0mbix / install-etcd-centos-6.5
Created Jan 10, 2014
Problems installing etcd on centos 6.5
View install-etcd-centos-6.5
# cat /etc/redhat-release
CentOS release 6.5 (Final)
golang from EPEL:
# rpm -qi golang
Name : golang Relocations: (not relocatable)
Version : 1.1.2 Vendor: Fedora Project
Release : 4.el6 Build Date: Fri 20 Sep 2013 16:21:49 BST
Install Date: Thu 09 Jan 2014 15:14:13 GMT Build Host: buildvm-17.phx2.fedoraproject.org
You can’t perform that action at this time.