Skip to content

Instantly share code, notes, and snippets.

View sepastian's full-sized avatar
💭
\_ . |‾‾‾| o-`o

Sebastian Gassner sepastian

💭
\_ . |‾‾‾| o-`o
View GitHub Profile
@sepastian
sepastian / heap.rb
Last active October 3, 2022 13:54
Heap in Ruby
class Heap
def initialize(*elems)
@h= heapify(elems)
end
def inspect
return '(empty)' if @h.empty?
@h
.group_by.with_index{ Math.log2(_2+1).to_i }
.map{ |l,vs| vs.join(' ') }
.join("\n")
@sepastian
sepastian / annotate_images_with_timestamp.sh
Created August 1, 2022 08:13
Annotate images with timestamp, in parallel
#!/bin/bash
# Options to -draw are not well documented;
# see: https://www.imagemagick.org/Usage/fonts/
set -euo pipefail
IFS=$'\n\t'
indir="/media/sebastian/3161-3938/DCIM"
@sepastian
sepastian / extract_pdf_images_in_parallel.sh
Created May 4, 2022 13:16
Extract PDF images in parallel
# For each page in input.pdf,
# generate image(s) in PNG format
# named output_<PAGE>.png
# where PAGE is a 4-digit zero-padded number.
pdfinfo input.pdf \
| grep Pages \
| awk -F'[: ]*' '{print $2}' \
| xargs seq \
| parallel \
'\
1. Download and install the official PPD files
See https://www.konicaminolta.de/de-de/support/download-center
Latest version at time of writting is `BH554ePPDLinux_300000000MU.zip`
2. Find out printer's IP address
On the printer, press
@sepastian
sepastian / nmcli_eduroam_uni_passau.sh
Last active April 3, 2023 13:57
Add nmcli connection for eduroam at university of Passau
# Setup eduroam connection using personal certificate (802-1.x WPA EAP)
# at the University of Passau.
#
# PREREQUISITES
#
# Instructions based on "Manuelle Einrichtung" [1] and Stackoverflow [2].
#
# 0) mkdir ~/.eduroam # create dir holding certificate files
# 1) download private key in PKCS#12 format [3], save as ~/.eduroam/eduroam.p12
# 2) download radius root certificate [4], save as ~/.eduroam/radius_rootcert.pem
@sepastian
sepastian / qemu_win10_guest.md
Last active December 19, 2022 15:15
QEMU: Win10 guest on Debian host
@sepastian
sepastian / generate_user_credentials.py
Created December 10, 2020 15:01
Generate user credentials for Solr BasicAuthentication
#!/usr/bin/env python3
# Copyright 2020 Sebastian Gassner <sebastian.gassner@gmail.com>
# License: MIT
# Based on java.org.apache.solr.security.Sha256AuthenticationProvider
#
# Usage: generate_user_credentials.py USER PASS
#
# Then add the output into security.json under 'credentials'.
@sepastian
sepastian / xml_attribute_ignoring_namespace.sh
Created December 10, 2020 11:20
Query XML attribute value by xpath using xmllint and ignoring namespace
#!/bin/bash
# See https://stackoverflow.com/questions/40796231/how-does-xpath-deal-with-xml-namespaces.
# To ignore namespaces use local-name(), for example:
#
# xmllint --xpath '//*[local-name()="structMap" and @TYPE="LOGICAL"]/*[local-name()="div"]/@TYPE' meta.xml
# Working example.
cat <<EOXML | xmllint --xpath '//*[local-name()="structMap" and @TYPE="LOGICAL"]/*[local-name()="div"]/@TYPE' -
<?xml version="1.0" encoding="UTF-8"?>
@sepastian
sepastian / rsync_by_ext.sh
Created December 9, 2020 15:07
rsync certain files by extension
# From: https://stackoverflow.com/questions/11111562/rsync-copy-over-only-certain-types-of-files-using-include-option?answertab=active#tab-top
#
# -m avoids creating empty directories
#
# --include must be specified before --exclude
sudo rsync -avzm --include="*/" --include='meta.xml' --exclude="*" source/ target/
@sepastian
sepastian / nikon_d7000_hdmi.md
Last active April 17, 2024 17:53
Nikon D7000 full screen HDMI output

Purpose

Stream HDMI video from a Nikon D7000, for usage in online meetings, video recording, etc.

Based on this video on Youtube.

Steps

1) Download firmware