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
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
@awood
awood / view-spec
Created December 16, 2013 15:04
A simple script to print out the spec file inside an SRPM.
#! /bin/sh
spec=$(rpm -qlp $1 | grep -E '\.spec$')
rpm2cpio $1 | cpio -i --to-stdout $spec
@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 / pki.markdown
Last active January 16, 2024 11:49
A brief discussion of ASN.1 and PKCS formats

What I Know About PKI

Abstract Syntax Notation One (ASN.1)

Much of the data in the PKI world is stored in ASN.1 so a basic understanding is necessary. ASN.1 is a way to describe data by starting from primitive types and building up to more complex types. Do you remember Backus-Naur Form? What about writing XML schemas in XSD? It's the same concept.

Let's say we have a Widget. Every Widget has a model name, a serial number, and some inspection information with the name of the inspector and the dates of the inspections. Our Widget then looks like this in ASN.1:

Widget ::= SEQUENCE {
    model IA5String, 

serialNumber INTEGER,

@awood
awood / solarized.less
Created March 19, 2014 21:13
A Less style-sheet for Pygments CSS classes using the Solarized color-scheme
/*
A Less style-sheet for Pygments using the Solarized color-scheme
Information on Solarized is at http://ethanschoonover.com/solarized
Two mixins, .solarized-dark and .solarized-light are provided for convenience
and if you wish to use your own primary and secondary colors, you may call the
.solarized mixin and provide parameters for the primary and secondary values.
The CSS class names are derived from the CSS classes that Pygments uses when
@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