Skip to content

Instantly share code, notes, and snippets.

View bauergeorg's full-sized avatar

Georg Bauer bauergeorg

View GitHub Profile
@bauergeorg
bauergeorg / logging_progress_bar.py
Created January 26, 2024 15:56
Logging with progress bar
import logging
import time
from tqdm import tqdm
class TqdmHandler(logging.StreamHandler):
def __init__(self):
logging.StreamHandler.__init__(self)
def emit(self, record):
msg = self.format(record)
@bauergeorg
bauergeorg / downloadGitLfsFiles.md
Created April 7, 2022 15:03 — forked from fkraeutli/downloadGitLfsFiles.md
How to download GIT LFS files

How to retrieve GIT LFS files from GitHub

Retrieving non-LFS files

Through the GitHub API it is possible to retrieve individual files from a Git repository via, e.g. curl. To do so, first retrieve the content information for the relevant file (or folder):

curl https://api.github.com/repos/{organisation}/{repository}/contents/{file or folder path}

For private repositories, authenticate using your username and a personal access token

@bauergeorg
bauergeorg / I2C_LTC1760.py
Created March 18, 2022 16:41
Python Script to communicate with LTC1760 via I2C on Raspberry Pi
#!/usr/bin/python
import smbus
# i2cdetect -y 1
# Address
charger_address = 0x0A
battery_address = 0x0B
# Charger Functions
CHARGER_SPEC_INFO = 0x11
@bauergeorg
bauergeorg / export_workflow_runs_to_md.py
Last active July 9, 2022 04:41
Print a Markdown-Page for more details of your workflow_dispatched Workflow Runs
from github import Github
import tomark
import datetime
from dateutil import tz
class pipeline_mngt_adv():
''' Class for pipeline management '''
def __init__(self, token, org):
''' Init function
@bauergeorg
bauergeorg / find_string_in_list.py
Last active May 26, 2021 07:02
parse a string in a list of strings
# init
test_list = ['one', 'two', 'three', 'four']
keyword = 'ree'
# one-liner
any(keyword in s for s in test_list)
@bauergeorg
bauergeorg / list_of_class_variables.py
Created March 23, 2021 11:01
return list of class variables
class obj_list():
element = 'one'
lamb = 'two'
def show():
""" returns a list of class variables """
return [attr for attr in dir(obj_list) if not callable(getattr(obj_list, attr)) and not attr.startswith("__")]
print(obj_list.show())
@bauergeorg
bauergeorg / thread_with_queue.py
Created March 9, 2021 11:13
Pyhton: thread with queue
import threading
import queue
import time
q = queue.Queue()
def do_it_in_a_thread(arg):
t = threading.currentThread()
i = 0
while getattr(t, "do_run", True):
@bauergeorg
bauergeorg / process_with_queue.py
Created March 9, 2021 11:10
Python: process with a queue
import multiprocessing
import time
def to_it_in_a_process(q):
i = 0
while(1):
time.sleep(1)
q.put(i)
print('Put item on queue')
i += 1