Skip to content

Instantly share code, notes, and snippets.

@oseiskar
oseiskar / parse_nordea_nda.py
Created September 2, 2022 14:11
Convert Nordea corporate electronic account statement NDA format to CSV
"""
Parses the electronic account statements in the data format used by the
Finnish bank Nordea (.nda / "TITO") and converts it to CSV.
Usage:
python parse_nordea_nda.py < Konekielinen-tiliote\(YY-MM-DD\).nda > result.csv
OR parse multiple:
@oseiskar
oseiskar / extract_gradle_poms.bash
Created September 15, 2020 17:34
Extract dependency information from a Gradle project by examining its build cache
#!/bin/bash
#
# Extract dependency information from a gradle projects by simply checking
# what its build scripts download in the Gradle cache and extracting the POM
# XML files from each.
#
# Usage:
#
# ./this_script.bash path/to/project "./gradlew assembleDebug"
#
@oseiskar
oseiskar / varint-decode.c
Created May 31, 2020 18:41
Decodes "varint-delimited" protocol buffer messages and wraps them into a normal protocol buffer repeated message container with tag 1
#include <stdio.h>
static int convertHeaderAndGetLength(FILE *in, FILE *out, int typedTag) {
int value = 0;
int bitshift = 0;
int first = 1;
while (1) {
int byte = fgetc(in);
if (byte == EOF) {
if (!first) fprintf(stderr, "unexpected EOF on length read\n");
@oseiskar
oseiskar / ble_scan.py
Created April 26, 2020 20:03
Linux BLE sniffer
"""
BLE sniffer for Linux. Requires hcidump and hcitool executables to
be available (e.g., apt-get install bluez-hcidump). Run as root.
Works with Python 2.7 (which is still the likely version of system Python)
If you get
Set scan parameters failed: Input/output error
try to fix with:
@oseiskar
oseiskar / misc-ffmpeg.bash
Created January 18, 2020 09:02
Miscellaneous FFmpeg scripts
# record lossless video to screengrab.mp4 after waiting 5 seconds, override without asking
sleep 5 && \
ffmpeg -y -video_size 1920x1080 -framerate 25 -f x11grab -i $DISPLAY -c:v libx264 -crf 0 -preset ultrafast screengrab.mp4
# lossless encoding of screengrab.mp4 with high quality, no audio ("-an", instead of "-c:a copy")
# CRF: "For x264, sane values are between 18 and 28. The default is 23"
# from start to 2 minutes
ffmpeg -ss 00:00:00 -i screengrab.mp4 -t 00:02:00 -c:v libx264 -preset slow -crf 22 -an output.mp4
# change video container without re-encoding
@oseiskar
oseiskar / drop_library_soname_suffixes.py
Created December 14, 2019 11:26
Remove Linux SO_VERSION suffixes (e.g., libfoo.so.1.2 -> libfoo.so) from a single ELF binary or a folder
# MIT License
#
# Copyright (c) 2019 Otto Seiskari
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@oseiskar
oseiskar / sine_wave_reconstruction.ipynb
Created August 18, 2018 20:40
Amplitude and phase reconstruction simulation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oseiskar
oseiskar / rc_discharge.ipynb
Created June 16, 2018 14:05
RC discharge simulation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oseiskar
oseiskar / pathos-multiprocessing-example.py
Created March 24, 2018 07:05
Python multiprocessing and exception handling example with pathos
from pathos.multiprocessing import ProcessingPool as Pool
def parallel_map(func, array, n_workers):
def compute_batch(i):
try:
return func(i)
except KeyboardInterrupt:
raise RuntimeError("Keyboard interrupt")
p = Pool(n_workers)
@oseiskar
oseiskar / simdkalman-kaggle-example.ipynb
Last active February 17, 2023 19:54
simdkalman example: Kaggle Web Traffic Time Series Forecasting
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.