Skip to content

Instantly share code, notes, and snippets.

@mamrehn
mamrehn / WekaSaveClassifier.java
Last active April 28, 2023 14:53
Simple example for a persistent classifier model in Weka (http://www.cs.waikato.ac.nz/ml/weka/). The Decision Tree (J48) can be exchanged with an arbitrary classifier.
//package ...;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import weka.classifiers.Classifier;
import weka.classifiers.trees.J48;
import weka.core.DenseInstance;
@mamrehn
mamrehn / pin_mouse.py
Created November 18, 2022 13:13
Pin mouse cursor to top-right corner
import time
from datetime import datetime
import pyautogui as autogui
autogui.FAILSAFE = False
# autogui.FAILSAFE = True # DEV mode: move mouse to upper left corner to exit
def has_point_moved(p1, p2, threshold = 5):
x_diff = abs(p1.x - p2.x)
y_diff = abs(p1.y - p2.y)
@mamrehn
mamrehn / Mandelbot_set.ipynb
Last active July 7, 2021 08:09
Python Mandelbrot Set
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mamrehn
mamrehn / install_textlive_ubuntu1804.sh
Created November 30, 2018 15:20
Install TeXLive on Ubuntu 18.04 LTS
sudo apt-get install texlive texlive-lang-german texlive-latex-extra texlive-science texlive-font-utils
@mamrehn
mamrehn / install_latest_CUDA_driver_and_toolkit.sh
Created October 19, 2018 12:35
Install latest CUDA driver and toolkit
# Source: https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" >> /etc/apt/sources.list.d/cuda.list'
sudo apt update
# sudo apt install nvidia-driver-410
# sudo apt install cuda-10-0
@mamrehn
mamrehn / build_and_install_fslint.sh
Created October 19, 2018 12:08
Generate .deb pacake yourself and install it
# Source: http://www.pixelbeat.org/fslint/
# https://www.vdr-portal.de/forum/index.php?thread/124755-gel%C3%B6st-dpkg-buildpackage-signiert-das-dsc-file-nicht/
git clone https://github.com/pixelb/fslint.git
cd fslint
# Note: "-us -uc" skips signing the package and is definitely not recommended (but works for self-built packages)
dpkg-buildpackage -I.git -rfakeroot -tc -us -uc
sudo dpkg -i ../fslint_2.47-1_all.deb
@mamrehn
mamrehn / compress_git_repository.sh
Created April 9, 2018 12:01
Compress git repository
git repack -a -d --depth=250 --window=250
git gc
git prune
@mamrehn
mamrehn / remove_unused_kernels.sh
Created October 6, 2014 17:55
Frequent Linux (kernel) updates clutter the free disc space left on your hard drive. If everything works with the new version, delete the old ones with this small script.
#!/bin/sh
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
@mamrehn
mamrehn / combine_images.py
Created December 31, 2017 01:55
Extract all images from a pdf file and enhance text in those images.
import sys
from pathlib import Path
import numpy as np
from skimage.io import imread, imsave
from skimage.color import gray2rgb
def to_rgba(img_):
if 3 == img_.ndim:
if 4 == img_.shape[2]:
return img_
@mamrehn
mamrehn / gpu_stat.py
Last active September 15, 2017 13:18 — forked from matpalm/gpu_stat.py
json formatting of nvidia-settings
#!/usr/bin/env python
# gpu_stat.py [DELAY [COUNT]]
# dump gpu stats as a json and plot in file
# {"cpu":5.9,"gpu":{"used_mem":7959,"util":{"graphics":91,"memory":56,"video":0,"PCIe":2}},"time":1505480296.0436406}
import sys
import time
import json
from pathlib import Path
# import socket