Skip to content

Instantly share code, notes, and snippets.

View awood's full-sized avatar

Alex Wood awood

  • Red Hat
  • Raleigh, NC
View GitHub Profile
@awood
awood / README.md
Last active August 29, 2015 13:56
Auto-resolving your Docker containers

For development, I run Docker containers that start up running sshd. Then I ssh to those machines and do my development work. It works great but finding the host name to ssh into was always a chore. It usually involved something like docker inspect my_container | grep IPAddress and then copying the address. Very tedious. I'd rather just type ssh root@my_container. So I did some searching and came up with a solution similar to http://blog.oddbit.com/2013/10/04/automatic-dns-entries-for-libvirt-domains/

What we will do is have incrond create a hosts file every time a container is started or stopped. Then we will set NetworkManager to use dnsmasq and resolve names through that hosts file.

The below instructions work on Fedora 20. For other distributions, you're on your own, but the principles should be the same.

  1. Set NetworkManager to use dnsmasq by adding the following under the [main] block of /etc/NetworkManager/NetworkManager.conf

dns=dnsmasq

@awood
awood / hush.py
Last active August 29, 2015 13:57
An XChat plugin to mimic WeeChat's "smart filter" by hiding join, part, and quit messages from inactive users.
#! /usr/bin/env python
# Copyright 2014 Alex Wood
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@awood
awood / branch-diff.md
Created April 22, 2014 18:14
What changes have been made to a given branch?

Ever wanted to see all the changes that someone has made on a branch and only those changes? Doing a “git diff” won’t help because that will also show the changes that have been made on the branch you’re diffing against. You could use “git merge-base” but that only goes to the last merge. What we need to do is find the oldest common ancestor between the branches and then diff the branch in question against that ancestor. Luckily, you can do this with a git alias.

Add the following to your ~/.gitconfig:

@awood
awood / responsive-columns.less
Created April 24, 2014 18:51
A simple LESS style sheet that you can use in Bootstrap 3 to create columns of uniform height.
// Courtesy of http://www.minimit.com/articles/solutions-tutorials/bootstrap-3-responsive-columns-of-same-height
.column-rules(@type) {
.container-@{type}-height {
display: table;
padding-left: 0px;
padding-right: 0px;
}
.row-@{type}-height {
@awood
awood / README.md
Last active August 29, 2015 14:00
Zsh function to run repoquery against mock configs

Drop mock-repoquery in the ~/.zfunc directory and add the following to your ~/.zshrc:

fpath=( ~/.zfunc "${fpath[@]}" )
autoload -Uz mock-repoquery
@awood
awood / awood.asc
Created March 13, 2015 13:55
My public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFT/V8wBEADFTEasiDcGrCBjVxtF06zZ7gRYcHA9/Cn92EOVNA/q9zoB3EEc
PtBYX1jA6GgdRiE2hcoDCwBx5ya6qz90JC3FHn8b+lQupLTG2EUNcyKNHQjc+i0N
JD8hYIhueKMEJPiPrvPLWkAFqofTZLAamdju41hCMXpFMOXQyfXgijmjRmaamH+7
xP5lyEt59umyRqftJUFew9hTOEjP+rWQaSlyN3Q9BEG9L0FlkFM2mv8z6O25t083
cNgI3sYN7mNK1a5IRilHzLJx8txSxSgjsPIFQcOJ+J0CZ+jXndHrM3fgwT4SLsQf
O9E0MJsgRQY7Ry2OHDwfiT5s7KffCnfypyY4kjErJ4v/gT9+F9UksKufnOpOLSF7
M/0w9IBtMy8wP+mmT6sp4s+z98EtyIQLwsmxrkPtcjMnKKUQuY73gX17FFEMS/K9
@awood
awood / tar_fixer.py
Created May 15, 2015 13:51
A Python class to give tarballs created by git-archive from tree references a consistent hash value.
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
import re
import struct
import sys
@awood
awood / keybase.md
Created June 1, 2015 15:54
keybase.md

Keybase proof

I hereby claim:

  • I am awood on github.
  • I am awood (https://keybase.io/awood) on keybase.
  • I have a public key whose fingerprint is 95BC 3319 CC7A DA09 7D9A F4C6 298D 1D54 9977 9B18

To claim this, I am signing this object:

CmdUtils.CreateCommand({
names: ["rhbug"],
arguments: [{role: "object",
nountype: noun_arb_text,
label: "bug number"}],
description: "Look up a bug in Red Hat's Bugzilla.",
author: { name: "Alex Wood", email: "awood@redhat.com"},
icon: "https://bugzilla.redhat.com/images/favicon.ico",
_bugPage: function(id) {
@awood
awood / java-specs.sh
Created October 2, 2013 16:25
A simple shell script to grab Java spec files so you can examine and learn from them. It looks in source repositories for items with a BuildRequires on jpackage-utils. Then it grabs the location for that SRPM, downloads it, and extracts the spec file. This script is probably Fedora specific.
#! /bin/bash
packages=$(repoquery --qf "%{name}" --archlist=src --enablerepo='*-source' --whatrequires jpackage-utils | sort | uniq)
for p in $packages; do
srpm_location=$(repoquery --qf "%{location}" --archlist=src --enablerepo='*-source' $p)
srpm=$(curl -s -O -w '%{filename_effective}' $srpm_location)
rpm2cpio $srpm | cpio --quiet -id ${p}.spec
rm $srpm
done