Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vkbo's full-sized avatar

Veronica Berglyd Olsen vkbo

View GitHub Profile
@vkbo
vkbo / upscaleVOY.py
Last active October 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
"""
import sys
import subprocess
from pathlib import Path
@vkbo
vkbo / upscaleDS9.py
Last active October 29, 2023 11:10
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
"""
import sys
import subprocess
from pathlib import Path
@vkbo
vkbo / jsonEncode.py
Last active July 31, 2021 17:04
Encode a Python dictionary to JSON with indentation up to a given level only
import json
def jsonEncode(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.
"""
if not isinstance(data, (dict, list, tuple)):
return "[]"
buffer = []
@vkbo
vkbo / roman_number.py
Created October 24, 2020 10:29
Simple Python function to convert an integer to a Roman number.
def numberToRoman(numVal, isLower=False):
"""Convert an integer to a roman number.
"""
if not isinstance(numVal, int):
return "NAN"
if numVal < 1 or numVal > 4999:
return "OOR"
theValues = [
(1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"),
@vkbo
vkbo / format_time.py
Created October 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.
def formatTime(tS):
"""Format a time in seconds in HH:MM:SS format or d-HH:MM:SS format
if a full day or longer.
"""
if isinstance(tS, int):
if tS >= 86400:
return f"{tS//86400:d}-{tS%86400//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}"
else:
return f"{tS//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}"
return "ERROR"
@vkbo
vkbo / pi.f90
Created April 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
@vkbo
vkbo / exchangeRates.py
Last active June 28, 2017 22:44
Simple python cli script that pulls exchange rates for a given date and displays them in a table
#!/usr/bin/env python3
#
# Pull Exchange Rates from APIs for Given Date
# ==============================================
# By: Veronica Berglyd Olsen, 14.06.2017
#
# Usage: ./exhangeRate.py YYYY-MM-DD
# Date must be >= 2000-01-01
# If no date, uses today's date
#