Skip to content

Instantly share code, notes, and snippets.

View pogross's full-sized avatar
๐Ÿ

Patrick-Oliver GroรŸ pogross

๐Ÿ
View GitHub Profile
@pogross
pogross / Get-FuelPrices.ps1
Last active December 7, 2022 17:26
Download historic fuel prices from Tankerkoenig
$outputPath = "D:\dev\fuelprices\history\"
# by default get all prices for all days of the year up until yesterday
$startDate = Get-Date "2022-01-01"
$endDate = (Get-Date).AddDays(-1)
for ( $currentDate = $startDate; $currentDate -lt $endDate; $currentDate = $currentDate.AddDays(1) ) {
$year = $currentDate.Year
$month = $currentDate.Month.ToString("00")
# Based on https://stackoverflow.com/a/62859169/562769
import argparse
from pathlib import Path
from typing import List, Tuple
import fitz # install with 'pip install pymupdf'
def _parse_highlight(
@pogross
pogross / exchangerate_bulk.py
Created March 5, 2021 11:57
Generates exchange rates for every day between start date and today
import collections
import csv
from datetime import datetime, timedelta
import requests
from dateutil.parser import parse
start_date: str = "2009-01-01"
end_date: str = datetime.now().strftime("%Y-%m-%d")
currencies: str = "USD,RON"
@pogross
pogross / bump-the-version.py
Created July 1, 2020 19:28
Pre-commit version bumping
!/usr/bin/env python3
import configparser
import subprocess
def main() -> int:
cfg = configparser.RawConfigParser()
cfg.read('setup.cfg')
current_version = cfg['metadata']['version']
prev = subprocess.check_output(('git', 'show', 'HEAD:setup.cfg')).decode()
cfg.read_string(prev)
@pogross
pogross / tox.ini
Created June 29, 2020 17:08
Global tox
[tox]
envlist = py37,py38
skipsdist = True
[testenv]
deps =
-r requirements.txt
commands =
pytest
@pogross
pogross / gnu-linux.txt
Created June 25, 2020 18:20
GNU/Linux
I'd just like to interject for a moment. What youโ€™re referring to as Linux, is in fact, GNU/Linux, or as Iโ€™ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it.
@pogross
pogross / swiss_army_knife.md
Last active July 4, 2020 16:07
Python Utility Collection

Function runtime

import time
import functools

def timer(func):
    """Print the runtime of the decorated function"""
    @functools.wraps(func)
    def wrapper_timer(*args, **kwargs):
import time
import psutil
from datetime import datetime
import os.path
import csv
FILE_NAME = "cpu_temps.csv"
FILE_EXISTS = os.path.isfile(FILE_NAME)
HEADER = ["DATE", "SENSOR1", "SENSOR2", "SENSOR3", "SENSOR4"]
MINUTES_INTERVAL = 2
@pogross
pogross / tmux-multilaunch-simple.sh
Last active August 2, 2019 14:05
Launches a tmux session and starts every command in a new window
#!/usr/bin/env bash
DIR=/home/pgross/workspace_java/ITTRouting/
SESSION_NAME='itt'
BASECMD='java -Xmx42G -jar ITTRouting.jar'
# SCRIPT-START
cd ${DIR}
# create the session and window 0
@pogross
pogross / digitransit_fi.py
Last active June 14, 2019 11:43
Logger for digitransit.fi vehicle position real-time api
# -*- coding: utf-8 -*-
"""
MQTT part based on: http://www.steves-internet-guide.com/into-mqtt-python-client/
API docs for HSL high-frequency positioning: https://digitransit.fi/en/developers/apis/4-realtime-api/vehicle-positions/
@adapted from https://gist.github.com/tjukanovt/ce8f84026db01582fbc23bfd67d56f8b
@requirements pip install pytz paho-mqtt
"""
import csv
import datetime