Skip to content

Instantly share code, notes, and snippets.

View sigma67's full-sized avatar

sigma67 sigma67

View GitHub Profile
@sigma67
sigma67 / retry.py
Created February 21, 2024 07:49
typed version of PythonDecoratorLibrary
"""generic exponential backoff retry decorator"""
import time
from collections.abc import Callable
from typing import Any
# from http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
# Retry decorator with exponential backoff
def retry(
exception: type[BaseException] | tuple[type[BaseException], ...],
@sigma67
sigma67 / ytapi_ytmusicapi_credentials.py
Last active March 24, 2024 04:57
obtaining an oauth.json using client_secret.json
import json
import google_auth_oauthlib.flow
from urllib.parse import urlparse, parse_qs
SCOPE = 'https://www.googleapis.com/auth/youtube'
# Use the client_secret.json file to identify the application requesting
# authorization. The client ID (from that file) and access scopes are required.
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
'client_secret.json',
@sigma67
sigma67 / fix_outlook_com_export_for_nextcloud.py
Created July 25, 2021 19:09
Fixes repeating events for Nextcloud imports from Outlook.com ics exports. Use calendar.ics for the original file and the fixed file will be calendar2.ics (both in the same folder as the script)
import os
from icalendar import Calendar
import datetime
directory = os.path.dirname(__file__)
with open(os.path.join(directory, 'calendar.ics'), 'rb') as fp:
data = fp.read()
cal = Calendar.from_ical(data)
for event in cal.walk('vevent'):
@sigma67
sigma67 / script.bat
Last active September 4, 2021 20:16
Integrate sylvainhalle/textidote with TeXStudio
REM Create a user command (Options > Configure TeXStudio > Build) and add the following
cmd /C "java -jar "path_to_textidote.jar" --output html --check en "?c:am.tex" > report.html" | cmd /C "report.html"
REM now pressing Alt-Shift-F1 will run a spellcheck, create a file report.html in your project folder and open the result in your favorite browser