Skip to content

Instantly share code, notes, and snippets.

import datetime as dt
import numpy as np
def kfz_steuer_oesterreich(zulassung,**kw):
"""
Motorbezogene Versicherungssteuer Österreich < 3.5 Tonnen ohne Versicherungsentgelt.
https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10004742
- zulassung format "YYYYMMDD", z.B. "20201001"
- CO2=xyz => ab 1.10.2020
- kW=xyz => Auto
- ccm=xyz => Motorrad
@rpuntaie
rpuntaie / iwyu.py
Created January 9, 2023 19:38
Call include-what-you-use on C/C++ files with flags from compile_commands.json
#!/usr/bin/env python3
"""
! CHECK IN BEFORE EXPERIMENTING !
cd cmake_project/build
python iwyu.py
@rpuntaie
rpuntaie / reactweb3.sh
Created June 17, 2022 19:56
setup react with ethers (web3 alternative) using hardhat
#!/usr/bin/env bash
npx create-react-app reactweb3
cd reactweb3
yarn add ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers
mkdir contract
cd contract
npx hardhat # simple project
npx hardhat compile
npx hardhat test
@rpuntaie
rpuntaie / pygameprocessing.md
Last active December 2, 2020 12:05
Loop pygame in separate thread to play with graphics REPL style (similar to processing.js)

It is a great idea to use graphics and multimedia to introduce students to programming. In the JVM world there is Processing. There is also a Javascript version p5js.

To me Python seems easier as a first contact language. It does not need compilation and no large virtual machine (like JVM in Processing). There are good REPL's (IPython, Jupyter) and a vast selection of libraries. Read-Eval-Print-Loop's allow a fast feedback when adjusting a specific detail. In combination with an editor that forwards lines to the interpreter in a terminal (vim,vscode), this is interactive coding.

@rpuntaie
rpuntaie / python_oauth_libraries.rst
Last active February 23, 2021 01:24
OAuth2 social login. First file: attempt to use just the data from django-allauth. Second file: social-core based solution actually adopted.

Python OAuth Libraries

Googling for OAuth for python returns many results, but not immediately the relevant ones, i.e. up-to-date, independent, authoritative implementations. So it took me more than necessary to adopt the right library. Here is my conclusion about the current state, to possibly abbreviate the search time for OAuth new-comers.

@rpuntaie
rpuntaie / gist:caa77f718c6e5109cdd584029f0db43f
Created February 22, 2018 10:23
python function to convert the xml file generated by CppCheck into a text table
def cppcheck2tbl(filename):
"""
Takes the xml file generated by CppCheck
and converts it to a text table.
"""
import xml.etree.ElementTree as ET
import csv
import html
tree = ET.parse(filename)
root = tree.getroot()
@rpuntaie
rpuntaie / resortmp3.py
Created February 3, 2018 21:50
resort badly organized mp3s with a python script that generates a .bat or .sh that does the actual resorting
#!/usr/bin/env python
# encoding: utf-8
#py.test --doctest-modules resortmp3.py
import sys
import re
import os
from collections import defaultdict
from numpy import base_repr
@rpuntaie
rpuntaie / waf_variants.py
Last active October 11, 2017 15:38
variants for the waf-project build tool
#!/usr/bin/env python
# encoding: utf-8
# Roland Puntaier, 2017
"""If there is a *variants* variable in the main wscript
- x_variant commandline arguments are created
for x in {configure, build, clean, install, uninstall}
- an x command line argument is expanded to all x_variant's
- the associated x function context contains :py:const:`variant`
@rpuntaie
rpuntaie / gist:37a380a84f9843b5dd17
Created March 8, 2015 20:33
python implementation FCA AddIntent and an FCA Lattice drawing algorithm
class lattice_node:
'''used int fca_lattice'''
def __init__(self,i,u,d,a,o,oi):
self.intent = a
self.object = o
self.object_index = oi
self.up = u
self.down = d
self.index = i
self.weight = 1
@rpuntaie
rpuntaie / gist:8510218
Last active January 7, 2022 16:17
Build VIM on MinGW/MSYS with support for all interpreters

I recently had to make myself comfortable on a Windows box, which meant installing VIM and python. And being at compiling VIM I compiled it with support for other interpreters as well.

I made a gvim74.exe installation file, like the one you get from http://www.vim.org/download.php, but with the newest batches and the interpreter versions of my choice.

Preparations