Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import requests
import json
api_url = "https://tcgbusfs.blob.core.windows.net/dotapp/youbike/v2/youbike_immediate.json"
api_filename = "youbike_immediate.json"
# Fields:
@JohnAZoidberg
JohnAZoidberg / split.sh
Created April 17, 2020 21:45
Split a scanned PDF at a separator page with a QR code
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p zbar poppler_utils
# Separate PDF
pdfseparate scanned.pdf 'page-%02d.pdf'
# Combine
pdfs=""
combined=0
@JohnAZoidberg
JohnAZoidberg / reformat_pln.py
Last active November 13, 2019 10:03
Convert BaSyTec PLN files to CSV
#! /usr/bin/env python3
import collections
import re
import codecs
import sys
pln_matrix = collections.defaultdict(dict)
with codecs.open(sys.argv[1], 'r', encoding='iso-8859-1') as f:
for line in f:
(col, row, val) = re.findall("([0-9]+) ([0-9.]+) (.*)", line)[0]
@JohnAZoidberg
JohnAZoidberg / output.md
Last active June 5, 2019 09:00
CoreFreq 1.54.4 output on Intel i5-8250U [KabyLake]

Output on ThinkPad T480

System Information

corefreq-cli -s

Processor                             [Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz]
|- Architecture                                                   [Kaby Lake/UY]
|- Vendor ID                                                      [GenuineIntel]
@JohnAZoidberg
JohnAZoidberg / Main.java
Last active September 20, 2017 15:35
Thread performance demonstration using matrix multiplication
import java.lang.Math;
import java.util.concurrent.ThreadLocalRandom;
public class Main {
static int[][] a_b;
static int[][] c;
static int thread_count = -1;
static boolean print_matrices = false;
@JohnAZoidberg
JohnAZoidberg / diff.sh
Last active September 7, 2017 05:22
Dualis Grades Webscraper
#!/usr/bin/env bash
python3 dualis.py it11111@lehre.dhbw-stuttgart.de 'pa$$w0rd' > new || exit 1
if [ ! -f old ]; then
cp new old
fi
diff new old
cp new old
@JohnAZoidberg
JohnAZoidberg / avltree.ex
Last active July 3, 2017 22:17
AVL Tree Implementation in Elixir
defmodule AvlTree do
@moduledoc """
A simple implementation of the AVL tree.
Inspired by https://gist.github.com/gerard/109729
Well okay, its pretty much translated literally.
## Examples
iex> AvlTree.load(AvlTree.empty(), [1, 2, 3, 4])
%AvlTree{left: %AvlTree{left: %AvlTree{left: nil, right: nil, value: 1},
@JohnAZoidberg
JohnAZoidberg / chat.html
Last active April 23, 2019 17:58
A very simple RESTful chat client for the backend at Lhdang88/cloud_computing_ws
<!DOCTYPE html>
<html>
<head>
<title>DHBW Webengineering Chatclient</title>
<style>
.emoji {
width: 25px;
height: 25px;
}
</style>
@JohnAZoidberg
JohnAZoidberg / log-html.sh
Created June 29, 2017 15:16
Log shell output to colored html
BUFFER="log.txt"
LOGGER=$1
OUTPUT=$2
while inotifywait -e modify log.txt; do $(cat $BUFFER | aha --black > $OUTPUT); done &
echo "---------------------------Restart---------------------------" >> $BUFFER
unbuffer $LOGGER >> $BUFFER
@JohnAZoidberg
JohnAZoidberg / convert.sh
Last active June 19, 2017 09:57
Insert hex color from a color picker
# Example
STDIN=$(zenity --title "Pick a color" --color-selection 2> /dev/null) # rgb(255, 15, 0)
SEQUENCE=${STDIN//[rgb( )]} # 255,15,0
NUMBERS=${SEQUENCE//,/ } # 255 15 0
printf "#%02X%02X%02X" $NUMBERS # #FF0F00
# Install zenity with your favourite package manager
# Put this in your .vimrc
# inoremap <F8> ,<ESC>:exe 'norm i' . system('~/convert.sh')<CR>a<DEL>
# nnoremap <F8> ciw<BS>,<ESC>x:exe 'norm i' . system('~/convert.sh')<CR>
# In insert mode you can insert a hex color with F8