Skip to content

Instantly share code, notes, and snippets.

View jonathanschilling's full-sized avatar

Jonathan Schilling jonathanschilling

View GitHub Profile
@jonathanschilling
jonathanschilling / demo_PyQt5_QSlider_matplotlib.py
Created September 30, 2020 08:27
A PyQt5 demo with embedded matplotlib figure and toolbar and a QSlider to modify the plot data.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import numpy as np
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QMainWindow, QVBoxLayout, QSlider, QApplication
import matplotlib
@jonathanschilling
jonathanschilling / compare_source_trees.sh
Last active November 4, 2020 20:07
Compare two (Fortran) source trees
#!/bin/bash
# reference source tree is in current working directory
# source tree to compare against is in $1
clear
for i in `find . -name '*.f*'`
do
echo $i
diff --color $i $1$i
@jonathanschilling
jonathanschilling / translate_java_comments.py
Last active November 11, 2020 15:33
Translate comments in (Java) source code using Google Translate
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 10 20:28:00 2020
Translate the comments found in a given (Java) source code file
from Japanese to English using Google Translate.
Run from bash as follows to iterate over all files found in a given directory:
> for i in `find src/jp/riken/kscope/ -name "*.java"` ; do python3 ../translate_java_comments.py $i ; done
@jonathanschilling
jonathanschilling / test_fortran_init.f90
Created June 9, 2021 12:55
Initialization of a variable in Fortran at declaration vs. at runtime
program test_fortran_init
implicit none
print *, "test with init at declaration"
call test_routine
call test_routine
print *, "test with init at subroutine start"
call test_routine_2
call test_routine_2
@jonathanschilling
jonathanschilling / my_nag.f90
Created June 21, 2021 17:35
stand-alone implementations of NAG DFTs C06FPF and C06FRF
module my_nag
use stel_kinds, only: dp
implicit none
real(dp), parameter :: twopi = 6.283185307179586_dp
contains
@jonathanschilling
jonathanschilling / PKGBUILD
Created July 26, 2021 10:32
protobuf Arch Linux package using cmake
# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: Aleksey Filippov <sarum9in@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Thomas S Hatch <thatch45@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy@archlinux.org>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
pkgbase='protobuf'
#include <stdio.h>
// Write a program that prints the numbers from 1 to 100.
// But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
// For numbers which are multiples of both three and five print "FizzBuzz".
int main(int argc, char** argv) {
int fb = 0;
for (int i=1; i<=100; ++i) {
fb = 0;
@jonathanschilling
jonathanschilling / gen_video.sh
Created November 1, 2021 17:53
Generate a mp4 movie from a series of png images
#!/bin/bash
#ffmpeg -r 1/5 -start_number 1900 -i ../Inference_volInt_20180906.40_20180906.40_%dms.png -c:v libx264 -vf "fps=25,format=yuv420p" Inference_volInt_20180906.40.mp4
ffmpeg -r 4 -f image2 -pattern_type glob -i '../*.png' -c:v libx264 -vf "fps=25,format=yuv420p,pad=ceil(iw/2)*2:ceil(ih/2)*2" Inference_volInt_20180906.40.mp4

Figure out which USB IDs the scanner has

dmesg --follow

then plug in the scanner:

[ 1703.081249] usb 1-4: new high-speed USB device number 6 using ehci-pci
@jonathanschilling
jonathanschilling / cpu_governor.sh
Created December 13, 2021 15:06
query and set CPU frequency governor
#!/bin/bash
cpupower frequency-info
sudo cpupower frequency-set -g powersave