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 / 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 = []
@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.
#!/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 / 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
try:
import lxml.etree as ET
except:
import xml.etree.ElementTree as ET
import requests
def getRss():
lang = "fi"
url = "http://feeds.yle.fi/areena/v1/series/1-1440981.rss?lang={0}".format(lang)
return requests.get(url).content
@maakuth
maakuth / split.theme
Created December 10, 2014 12:27
Theme to highlight irssi split screens. Based on irssi default theme, modified by Heikki IIRC
# When testing changes, the easiest way to reload the theme is with /RELOAD.
# This reloads the configuration file too, so if you did any changes remember
# to /SAVE it first. Remember also that /SAVE overwrites the theme file with
# old data so keep backups :)
# TEMPLATES:
# The real text formats that irssi uses are the ones you can find with
# /FORMAT command. Back in the old days all the colors and texts were mixed
# up in those formats, and it was really hard to change the colors since you
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def isPalindrome(whatever):
reverse = ''
for c in whatever:
reverse = c + reverse
return reverse == whatever