Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲
¯\_(ツ)_/¯

Stefan stefan2904

🚲
¯\_(ツ)_/¯
  • @IAIK, Graz University of Technology
  • Graz, Vienna & Koroška, Europe, Earth
  • Twitter @stefan2904
View GitHub Profile
@stefan2904
stefan2904 / chaintest.py
Last active Apr 14, 2022
Python Requests Demo: How to handle a web server which serves a misconfigured TLS chain
View chaintest.py
import requests
# via https://whatsmychaincert.com/?webportal.stromnetz-graz.at
# "Generate the Correct Chain" + "Include Root Certificate"
# --> https://whatsmychaincert.com/generate?include_leaf=1&host=webportal.stromnetz-graz.at&submit_btn=Generate+Chain&include_root=1
CUSTOMSTORE='/tmp/webportal.stromnetz-graz.at.chained+root.crt'
print('without chain:')
try:
requests.get('https://webportal.stromnetz-graz.at/login')
@stefan2904
stefan2904 / generate.js
Last active Mar 31, 2022
Generate Ed25519 did:key in JSONWebKey format for usage in Hyperledger Aries
View generate.js
// using https://github.com/transmute-industries/did-key.js
// via https://www.npmjs.com/package/@transmute/did-key-ed25519
const main = async function() {
const k = await require('@transmute/did-key-ed25519').Ed25519KeyPair.generate({
secureRandom: () => {
return Buffer.from(
require('crypto').randomBytes(32),
'hex'
View pinboard.py
import json
import sys
import requests
import codecs
from requests.utils import get_netrc_auth
TMP_FILE = '/tmp/pinboard.json' # May not exist in all platforms
default_params = {'format': 'json'}
@stefan2904
stefan2904 / dir2org.sh
Created Oct 7, 2021
Convert directory of markdown files into orgmode heading
View dir2org.sh
#!/bin/bash
# if [[ -d $PASSED ]]; then
# echo "$PASSED is a directory. Let's convert it."
# elif [[ -f $PASSED ]]; then
# echo "$PASSED is a file. Try md2org instead?"
# exit 2
# else
# echo "$PASSED is not valid?"
# exit 1
@stefan2904
stefan2904 / demo.php
Created Jun 23, 2021
PHP: Check if property exists in decoded JSON (using strict types)
View demo.php
<?php declare(strict_types=1);
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
$j = json_decode($json);
var_dump($j);
var_dump($j->a == NULL);
@stefan2904
stefan2904 / courses.csv
Last active Jun 1, 2021
TU Graz courses (study year 2020/21)
View courses.csv
We can't make this file beautiful and searchable because it's too large.
id,title,other_uni
BEA.01001PH,"Ästhetik, Kunst und visuelle Kultur (STEOP)",PH_Stmk
BEA.02001PI,Introduction to the subject specific professional field of ARTS Education,PPH_Graz
BEA.03001PH,Grundlagen bildnerischen Gestaltens I,PH_Stmk
BEA.04001PH,Wahrnehmungspsychologie,PH_Stmk
BEA.05001PH,Grundlagen der Fachdidaktik,PH_Stmk
BEA.06001PH,Grundlagen bildnerischen Gestaltens II,PH_Stmk
BEA.07115UB,Introduction to Iconography,Uni Graz
BEB.01001PH,Grafik I,PH_Stmk
BEB.02001PI,Painting I,PPH_Graz
@stefan2904
stefan2904 / studies.csv
Last active May 20, 2021
TU Graz Study Programme
View studies.csv
study programme number study programme name study programme type
221 Geodesy Bachelor programme
211 Information and Computer Engineering Bachelor programme
243 Architecture Bachelor programme
253 Biomedical Engineering Bachelor programme
273 Chemical and Process Engineering Bachelor programme
662 Chemistry Bachelor programme
264 Civil Engineering Sciences and Construction Management Bachelor programme
521 Computer Science Bachelor programme
235 Electrical Engineering Bachelor programme
@stefan2904
stefan2904 / u2f_demo.py
Created Jan 18, 2021
U2F Host Demo (in Python)
View u2f_demo.py
from u2flib_host import u2f, exc
from u2flib_host.utils import websafe_encode, websafe_decode
from u2flib_host.register import register
from u2flib_host.authenticate import authenticate
import json
import struct
import base64
# Using https://github.com/Yubico/python-u2flib-host
# See also: https://webauthn.guide/#webauthn-api
@stefan2904
stefan2904 / export.sh
Last active Oct 23, 2020
draw.io / diagrams.net batch exporter
View export.sh
#!/bin/bash
# Get desktop-app (which includes CLI) from http://get.diagrams.net
NUM_PAGES=4
DRAWIO_FILE="cdn-setup1"
#set -o xtrace
for ((page=0; page<NUM_PAGES; page++))