Instantly share code, notes, and snippets.
Senior Developer at@turtlesec-no.Former Research Fellow at CERN. PhD in Accelerator Physics from the University of Oslo and CERN.
- TurtleSec AS
- Oslo, Norway
- http://berglyd.net
- @veronica@mastodon.online
- in/veronicakbolsen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
fromtypingimportTypeVar | |
T_=TypeVar("T_",bound=object) | |
defmyDataClass(cls:T_)->T_: | |
"""A simple data class decorator that generates slots automatically | |
and creates an init function to match. | |
""" |
vkbo /upscaleVOY.py
Last activeOctober 29, 2023 11:05
Script used to upscale ST:VOY from PAL DVD to HD using Topaz Video AI and Iris V1 model This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
""" | |
Upscale: Star Trek Voyager | |
Source: PAL DVD (2017 Release) | |
AI Model: Topaz Video AI 4.0, Iris V1 | |
""" | |
importsys | |
importsubprocess | |
frompathlibimportPath |
vkbo /upscaleDS9.py
Last activeMay 2, 2024 17:48
Script used to upscale ST:DS9 from PAL DVD to HD using Topaz Video AI and Iris V1 model This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
""" | |
Upscale: Star Trek Deep Space Nine | |
Source: PAL DVD | |
AI Model: Topaz Video AI 3.4, Iris V1 | |
""" | |
importsys | |
importsubprocess | |
frompathlibimportPath |
vkbo /jsonEncode.py
Last activeJuly 31, 2021 17:04
Encode a Python dictionary to JSON with indentation up to a given level only This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
importjson | |
defjsonEncode(data,n=0,nmax=0): | |
"""Encode a dictionary, list or tuple as a json object or array, and | |
indent from level n up to a max level nmax if nmax is larger than 0. | |
""" | |
ifnotisinstance(data, (dict,list,tuple)): | |
return"[]" | |
buffer= [] |
vkbo /roman_number.py
CreatedOctober 24, 2020 10:29
Simple Python function to convert an integer to a Roman number. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
defnumberToRoman(numVal,isLower=False): | |
"""Convert an integer to a roman number. | |
""" | |
ifnotisinstance(numVal,int): | |
return"NAN" | |
ifnumVal<1ornumVal>4999: | |
return"OOR" | |
theValues= [ | |
(1000,"M"), (900,"CM"), (500,"D"), (400,"CD"), (100,"C"), (90,"XC"), |
vkbo /format_time.py
CreatedOctober 24, 2020 10:22
A simple and fast Python 3.6+ function for formatting an integer representing time in seconds to HH:MM:SS or d-HH:MM:SS format. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
defformatTime(tS): | |
"""Format a time in seconds in HH:MM:SS format or d-HH:MM:SS format | |
if a full day or longer. | |
""" | |
ifisinstance(tS,int): | |
iftS>=86400: | |
returnf"{tS//86400:d}-{tS%86400//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}" | |
else: | |
returnf"{tS//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}" | |
return"ERROR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
program main | |
use,intrinsic:: iso_fortran_env | |
implicit none | |
real(kind=real32),parameter:: pi32=3.1415925_real32 | |
real(kind=real64),parameter:: pi64=3.141592653589793238462643383279502884197169399375105820974_real64 | |
real(kind=real128),parameter:: pi128=3.141592653589793238462643383279502884197169399375105820974_real128 |