Skip to content

Instantly share code, notes, and snippets.

@kidmose
kidmose / sanMatch.py
Created March 23, 2021 07:55
Matching domain names to SubjectAltName (SAN), with approximate wildcard handling as per HTTPS (RFC2818)
def sanMatch(san, domain):
"""If a `san` (Subject Alternative Name) matches (includes) 'domain`
Note: This does some rough, inaccurate wildcard matching; `*`
matches *one or more* prefixed domain name components (or
sub-domain labels in DNS terms). RFC2818 specifies that `*`
matches any *single* domain name component, or a fragment
thereof. This has bee OK for my usage.
* On SANs in X.509 certificates:
@kidmose
kidmose / move_repo_to_github.sh
Created March 9, 2021 13:17
Take a local cloned git repo, created it on github, and make sure all branches from the old origin is now on github
#!/usr/bin/env bash
git remote rename origin old
gh repo create $(basename $(pwd)) --private --confirm
git checkout master
git push -u origin master
for branch in $(git for-each-ref --format='%(refname:lstrip=-1)' refs/remotes/old \
| grep -v '^HEAD$' | grep -v '^master$' ); do
git checkout --track old/$branch
@kidmose
kidmose / default.nix
Created June 26, 2020 08:56
Nix shell for python with mutable python modules (I.e. `pip install ...` works like in a virtualenv`)
with import <nixpkgs> {};
let
python = pkgs.python38.buildEnv.override {
# throw in some default stuff that is always nice to have
extraLibs = with pkgs.python38Packages; [
numpy
ipython
jupyter
pandas
@kidmose
kidmose / install_grub.sh
Created April 11, 2019 20:09
reinstall grub2 with EFI
#!/bin/bash
# https://superuser.com/questions/376470/how-to-reinstall-grub2-efi
# and some of mine
if ! [ $(id -u) = 0 ]; then
echo "I am not root!"
exit 1
fi
@kidmose
kidmose / Makefile
Created October 19, 2017 08:22
Makefile for building building latex into html suitable for word import
# Handy for converting (any?) latex into HTML, formatted such that Microsoft Word reads it nicely.
# Copyright: WTFPL, http://www.wtfpl.net/
# Author: Egon Kidmose <kidmose@gmail.com>
# Requires: working latex, make and tex4ht
# Dependecy installation on linux mint, debian like:
# sudo apt-get install tex4ht dvipng
# Usage:
# make clean word
word:
@kidmose
kidmose / print-any-file.sh
Created August 16, 2017 09:16
Convert any file or dir to something printable, and wrap it in some (wacky) XML.
#!/bin/bash
# Convert any file or dir to something printable, and wrap it in some (wacky) XML.
#
# Usage example:
# find . -exec ./printer.sh {} \; > out.txt
FILE=$1
TYPE=$(file -b $FILE)
if [[ "$TYPE" == "directory" ]]; then
@kidmose
kidmose / install-latex-from-apt-get.sh
Last active November 6, 2019 09:48
List of all the aptitude packages that I commonly use when writing LaTeX, for easy installation on debian-like distros (Ubuntu, mint).
apt-get install -qy \
lmodern `# lmodern.sty` \
texlive-binaries \
texlive-base \
texlive-lang-european `# danish in babel` \
texlive-latex-base \
texlive-latex-recommended \
texlive-fonts-recommended `# for scalable fonts` \
texlive-fonts-extra `# dsfont.sty` \
texlive-science \
@kidmose
kidmose / afs-installation.md
Last active November 13, 2017 11:41
AFS installation procedure

AFS installation instructions

Instructions for installing AFS, as used at Electronics Department, Aalborg University, under linux mint 18. This is based on my personal experienced and serves as documentation to me, but might be useful for other. Pull suggestions/PRs welcome.

Based on https://it-wiki.es.aau.dk/wiki/AFS_on_Debian/Ubuntu and adjusted to work based on my experience.

@kidmose
kidmose / iwlist-scan-to-csv.sh
Last active October 12, 2016 19:56
Converts output of `iwlist <WLAN-IF> scan` from rubbish to CSV
#!/bin/bash
# Copyright (C) 2016 Egon Kidmose
# 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, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#
# Converts output of `iwlist <WLAN-IF> scan` from rubbish to CSV
#
# Example:
#
/var/log/suricata/eve.json {
rotate 10
size 100M
nocompress
missingok
create
sharedscripts
postrotate
/bin/kill -HUP $(cat /var/run/suricata.pid)
endscript