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 / 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 / reader.py
Last active April 4, 2016 19:44
ASN1 Reader that examines X509 certificates for extensions under OID 1.3.6.1.4.1.2312
#! /usr/bin/env python3
import sys
import base64
import binascii
import re
from pyasn1.type import univ, namedtype, tag, constraint, namedval
from pyasn1.codec.der import decoder
try:
@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 / gradleup
Created June 3, 2019 15:35
Zsh function to find gradlew by going up through parent directories
#! /bin/zsh
gradleup() {
local curdir="$PWD"
while [[ "`pwd`" != "$HOME" && "`pwd`" != '/' ]]; do
if [[ -e gradlew ]]; then
local result=$(realpath ./gradlew)
break
fi
@awood
awood / eclipse_conf.md
Last active July 23, 2020 16:10
XML configuration for integrating Flake8 with the Eclipse GrepConsole plugin.

In the Eclipse External Tool Configuration window, I set Flake8 up as follows:

  • Location: /usr/bin/flake8
  • Working Directory: empty
  • Arguments: --format="%(code)s %(text)s [%(path)s:%(row)d:%(col)d]" ${project_loc}

With this Flake8 format, the information about the error is printed first and the location second.

I could not figure out a way to get Eclipse to print a proper relative directory (Even using ${resource_path} printed a leading slash). Nor could I figure out how to get GrepConsole's base directory setting to read from an Eclipse variable. The result with the default Flake 8 format was that in order for everything to work, I had to use absolute path names which crowded all the useful information out of the immediately visible portion of the console. With the custom format, the interesting stuff comes first and the dross is at the end.

@awood
awood / en_24
Created July 2, 2015 14:31
Locale file for USA but using 24-hour time
escape_char /
comment_char %
% Locale for English locale in the USA
% Compile this with `localedef -f UTF-8 -i en_24 en_24.UTF-8`
% Then set the system to use it with `localectl set-locale "LC_TIME=en_24.UTF-8"`
LC_IDENTIFICATION
title "English locale for the USA"
source "Free Software Foundation, Inc."
@awood
awood / logging.properties
Last active May 2, 2022 09:54
Non-rotating Tomcat logging.
# In Fedora 20, Tomcat 7 has an annoying habit of creating log files that are named
# "catalina.YYYY-MM-DD.out" with the day's date filled in the file name. It is a pain in
# the neck to have to remember the date every time I want to look at the log file and
# tab completion doesn't help because it will only complete as far as the most common
# string which in the case of the date is usually the year.
# StackOverflow to the rescue: http://stackoverflow.com/questions/4511845
# My solution was slightly different though. I set "rotatable" to false, but instead of
# adding a "suffix" option in /etc/tomcat/logging.properties, I just changed the "prefix" option to
# remove the period.
@awood
awood / podman-intellij.md
Created April 19, 2023 17:29
Connecting Intellij to Podman

IntelliJ has support for working with Podman but there are some hoops you need to jump through first. The first obstacle is getting the podman API up and running continually. Normally the API is only up while needed and then shuts down. You can change this by creating a local systemd unit file that starts the API server for you when you log in. Here's the unit file:

[Unit]
Description=Podman API Service for IntelliJ
Documentation=man:podman-system-service(1)
StartLimitIntervalSec=0

[Service]
Type=exec
@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,