Skip to content

Instantly share code, notes, and snippets.

@maakuth
maakuth / kcat-timestamps.py
Created June 21, 2023 09:58
Kcat timestamp parser
#!/usr/bin/env python3
# Use with kcat -f "%p,%o,%T\n" to parse message timestamps
from sys import argv
from datetime import datetime
import csv
for row in csv.reader(open(argv[1], 'r'), delimiter=','):
print(f"Partition {row[0]} offset {row[1]}: {datetime.fromtimestamp(int(row[2])/1000)}")
#!/usr/bin/env python3
"""
Yksinkertainen Long Playn epubien noutovempele.
Tarvitaan Python, Selenium, Firefox ja Geckodriver
Testatut versiot:
- Python 3.11.2
- Selenium 4.8.3
- Geckodriver 0.32.2 (https://github.com/mozilla/geckodriver)
- Firefox 111.0.1
@maakuth
maakuth / xfs.txt
Last active October 9, 2020 11:51
Badly prepared benchmarks from my system, moving from mdraid+LVM to ZFS with SSD L2ARC.
#Note: This is backed by degraded md-raid6 PV
Using uid:1000, gid:1000.
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
@maakuth
maakuth / indexer.rb
Created October 2, 2020 13:49
Here's a small thing I made that parses file_id.diz files from inside zip files and outputs some files into Internet Archive metadata format. I used this one to populate https://archive.org/details/suomipelit?tab=collection
#!/usr/bin/env ruby
require 'csv'
require 'zip'
require 'pp'
Zip.force_entry_names_encoding = 'ISO-8859-1'
entries = []
#!/usr/bin/env ruby
rooms = `sudo -u postgres psql synapse -t -c "select room_id from rooms;"`.split("\n")
rooms.reject! {|r| r.strip == "" }
rooms.each_with_index do |r, i|
`./synapse-compress-state -p 'postgresql://USERNAME:PASSWORD@HOSTNAME/DBNAME' -r '#{r.strip}' -o out#{i}.sql -t`
end

Keybase proof

I hereby claim:

  • I am maakuth on github.
  • I am maakuth (https://keybase.io/maakuth) on keybase.
  • I have a public key ASDar8sqDv1PSDPWqzg6lderRehi3yacdrhe7HqOgtnDWwo

To claim this, I am signing this object:

@maakuth
maakuth / backup.sh
Created August 20, 2013 07:18
Neat way to getting consistent backups of stuff by utilizing LVM snapshots. In my setup /backuptarget is an USB hard drive, but it could be sshfs, smb or nfs share just as well.
#!/bin/sh
. /etc/environment
lvcreate -l90%FREE -s -n rootsnap /dev/host/root
#XFS specific: Mounting ignoring uuid because the original volume has same uuid
mount -o ro,nouuid /dev/host/rootsnap /mnt/rootsnap
mount /backuptarget
@maakuth
maakuth / mendeley-biblatex-dateconversion
Created April 23, 2013 07:11
Sed command to change dd/mm/yy dates to yyyy-mm-dd. I did this to make Mendeley dates work with our faculty LaTeX template (https://yousource.it.jyu.fi/latex-thesis-classes/ttl-gradu).
sed -e "s_\(..\)\/\(..\)\/\(..\)_20\3-\2-\1_"
@maakuth
maakuth / img2pdf.sh
Created November 7, 2015 12:34
Shell utility script to compress images into reasonably sized PDFs
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage $0 img1.png img2.tif img3.pdf"
echo "Requires ghostscript, imagemagick"
fi
for file in "$@"
do
@maakuth
maakuth / tulosta.sh
Created March 19, 2012 10:12
Printing script for University of Jyväskylä
#!/bin/bash -e
#
# Printing made easy for your Linux laptop in the University of Jyväskylä.
# Public domain. Original work by Zouppen and cedx.
#
# Before using, send your public key to charra (to avoid password prompt)
# and put the following in your ~/.ssh/config:
#
# Host charra
# User YOUR_USERNAME