Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Sign in Sign up

Instantly share code, notes, and snippets.

View vkbo's full-sized avatar

Veronica Berglyd Olsen vkbo

Senior Developer at@turtlesec-no.Former Research Fellow at CERN. PhD in Accelerator Physics from the University of Oslo and CERN.
View GitHub Profile
@vkbo
vkbo /dataclass.py
CreatedJanuary 12, 2025 21:17
Simple dataclass that auto-implements slots
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
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
"""
Upscale: Star Trek Voyager
Source: PAL DVD (2017 Release)
AI Model: Topaz Video AI 4.0, Iris V1
"""
importsys
importsubprocess
frompathlibimportPath
@vkbo
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
"""
Upscale: Star Trek Deep Space Nine
Source: PAL DVD
AI Model: Topaz Video AI 3.4, Iris V1
"""
importsys
importsubprocess
frompathlibimportPath
@vkbo
vkbo /jsonEncode.py
Last activeJuly 31, 2021 17:04
Encode a Python dictionary to JSON with indentation up to a given level only
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
vkbo /roman_number.py
CreatedOctober 24, 2020 10:29
Simple Python function to convert an integer to a Roman number.
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
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.
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"
@vkbo
vkbo /pi.f90
CreatedApril 17, 2019 11:41
Single, Double and Quad Precision PI in Fortran
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

[8]ページ先頭

©2009-2025 Movatter.jp