Skip to content

Instantly share code, notes, and snippets.

View matthogan's full-sized avatar
👽

Matt Hogan matthogan

👽
View GitHub Profile
@matthogan
matthogan / UsageMetrics.java
Created February 24, 2022 15:15
Add username tag to Micrometer @counted and @timed
import io.micrometer.core.aop.CountedAspect;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.ImmutableTag;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import org.aspectj.lang.ProceedingJoinPoint;
//...
@Configuration
public class UsageMetrics {
@matthogan
matthogan / exportpubk.sh
Created January 4, 2022 23:51
Export the public key from pkcs12
openssl pkcs12 -in new.p12 -clcerts -nokeys | openssl x509 -outform der -pubkey -noout
@matthogan
matthogan / CopyKeyFromKeyStoreToNewKeyStore.java
Last active January 4, 2022 23:41
Copy a key from a keystore to a new keystore
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.KeyStore;
/**
* Transfers a specific alias corresponding to a key from an existing
* archive to a new one. Assumes p12 format.
* <p>
* Some keystores are full of keys, used as general purpose archives,
* and if some are 'unsupported' then errors like 'Warning unsupported bag
git push --set-upstream http://git-repo/path/project/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)
@matthogan
matthogan / clone_gitlab_group_subgroups.py
Last active June 3, 2021 17:02
Clone all gitlab repos in a group and reflect the group/project and group/subgroup/project layout in the final directory structure.
import gitlab
import os
import subprocess
def clone_repos(host, token, group, base_dir):
gl = gitlab.Gitlab(host, private_token=token)
group = gl.groups.list(search=group)[0]
clone_projects(group.projects.list(all=True, include_subgroups=True), base_dir)
@matthogan
matthogan / import-rds-certs.sh
Last active August 28, 2018 15:05 — forked from shareefhiasat/import-rds-certs.sh
import RDS certificates to java keystore on alpine / osx
curl https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem > rds-combined-ca-bundle.pem
dos2unix rds-combined-ca-bundle.pem
csplit -sk rds-combined-ca-bundle.pem "%BEGIN CERTIFICATE%0" "/BEGIN CERTIFICATE/" "{$(grep -c 'BEGIN CERTIFICATE' rds-combined-ca-bundle.pem | awk '{print $1 - 2}')}"
KS=rds.jks
rm $KS
for CERT in xx*; do
echo "$CERT"
# extract a human-readable alias from the cert
ALIAS=$(openssl x509 -noout -text -in $CERT |
perl -ne 'next unless /Subject:/; s/.*CN=//; print')