Skip to content

Instantly share code, notes, and snippets.

@mayjs
mayjs / add_debug_output.py
Created August 5, 2023 18:24
Intermediate result inspection in ONNX models
from pathlib import Path
import onnx
model_path = Path("my_model.onnx")
extra_output = "/up1/Concat_3_output_0" # One good way to get this identifier for your node is to use https://netron.app/
extra_output_shape = [1, 1024, 55, 55]
new_model_path = model_path.with_stem(model_path.stem + "-" + extra_output.replace("/", "_").replace(".", "_").strip("_"))
model = onnx.load(model_path)
@mayjs
mayjs / docker-compose.yml
Created December 3, 2020 18:38
Adguard docker compose
version: "3.5"
services:
adguard:
container_name: adguard
image: adguard/adguardhome:latest
volumes:
- "./adguard-work/:/opt/adguardhome/work"
- "./adguard-conf/:/opt/adguardhome/conf"
ports:
- "53:53/tcp"
@mayjs
mayjs / autoscan.sh
Last active March 7, 2021 16:07
This script can be used to convert a series of document pictures to a pdf, automatically applying edge detection at dewarping the images.
#!/usr/bin/env bash
# Given an output PDF filename and a list of images, adjust and OCR the images and create a PDF
OUT_NAME=$1
shift
mogrify -auto-orient $@
TMPDIR=`mktemp -d`
scantailor-cli -l=1 --dewarping=auto --start-filter=1 --end-filter=6 $@ "$TMPDIR"
for IN in $@
do
FILENAME=`basename -s .jpg "$IN"`
@mayjs
mayjs / ayu-dark.kak
Created July 22, 2020 13:40
Kakoune Ayu Dark modded
evaluate-commands %sh{
common_accent="rgb:e6b450"
common_bg="rgb:0a0e14"
common_fg="rgb:b3b1ad"
common_ui="rgb:3d424d"
syntax_tag="rgb:39bae6"
syntax_func="rgb:ffb454"
syntax_entity="rgb:59c2ff"
syntax_string="rgb:c2d94c"
syntax_regexp="rgb:95e6cb"
@mayjs
mayjs / tronxy_x5s_ramps_printer.cfg
Created November 13, 2018 21:59
This is a klipper config for the Tronxy X5S using RAMPS/MKS Gen L as the controller.
[stepper_x]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
step_distance: .0125
endstop_pin: ^!ar3
#endstop_pin: ^ar2
position_endstop: 0
position_max: 330
homing_speed: 50
@mayjs
mayjs / findTexRoot.sh
Created February 8, 2018 11:33
This simple shell script will find the closest tex root file upwards from a given location.
#!/bin/bash
# Usage example:
# if roottex=$(~/findroot.sh .); then; echo $roottex; else; echo No root found;fi
# This constant determines how many directories will be searched.
# A value of 0 will result in no searching at all, 1 will search the directory of the given file or the given directory
SEARCHDEPTH=3
## This part is only parameter validation
@mayjs
mayjs / convert_xoj.sh
Created December 21, 2017 18:08
Recursively convert all recently changed *.xoj files in a directory to pdf (requires a patched version of xournal)
#!/bin/bash
# This script converts all xournal xoj files in subdirectories of the current working directories to pdf files
# It also checks if the file was recently changed.
# To do this, it compares modification timestamps of these files with the modification timestamp of the script files itself.
# The script will also update its own modification timestamp afterwards.
SCRIPT="$(realpath "$0")"
# Converts a single xoj file to pdf.
function convertXoj {
#!/bin/bash
bottoken=<INSERT TOKEN>
chatid=<INSERT CHAT>
matrikel=<INSERT MATRIKEL>
# USE curl https://api.telegram.org/bot$bottoken/getUpdates to get the chatID!
telegrambase=https://api.telegram.org/bot$bottoken/sendMessage?chat_id=$chatid
if [[ $(curl -vs -F "matrikel=$matrikel" http://dekanat.cs.uni-dortmund.de/web/de/cgi-bin/zqueryBA.cgi 2>&1 | grep Zeugnis_Nicht_Vorhanden) ]]; then
@mayjs
mayjs / Readme.md
Created July 12, 2017 10:50
Wekan Systemd unit file

Place wekan.service in /etc/systemd/system, then use sudo systemctl start wekan to start the service.

@mayjs
mayjs / convert.py
Created January 3, 2017 18:55
Generate ASCII art from bitmaps in python
from PIL import Image
"""Credit: https://www.hackerearth.com/notes/beautiful-python-a-simple-ascii-art-generator-from-images/
One change: the scaled images width is doubled to create better ASCII art.
"""
ASCII_CHARS = [ '#', '?', '%', '.', 'S', '+', '.', '*', ':', ',', '@']
def scale_image(image, new_width):
"""Resizes an image preserving the aspect ratio.