Skip to content

Instantly share code, notes, and snippets.


Ching-Hwa Yu chinghwayu

View GitHub Profile
View jenkins-trigger.vbs
' Perforce Jenkins Trigger Script
' This script is meant to be called from a Perforce trigger.
' It should be placed on the Perforce Server machine.
' See usage information below for more details.
' Adapted from swarm-trigger.vbs
' Prerequisites:
chinghwayu /
Last active Jan 15, 2019
Simple python REPL command line application with objects, list comprehension, zip, and f-strings
class ConvertFunctions():
def f2c(self, ftemps):
return [(ftemp-32) * 5/9 for ftemp in ftemps]
def m2cm(self, lmeters):
return [meters*100 for meters in lmeters]
def main():
convert = ConvertFunctions()
while True:
chinghwayu /
Created Jan 21, 2019
Simple python REPL command line application with objects, list comprehension, zip, f-strings, and exceptions
class ConvertFunctions():
def f2c(self):
strtemps = input("Please enter your fahrenheit temperature(s): ")
ftemps = [float(ftemp) for ftemp in strtemps.split()]
ctemps = [(ftemp-32) * 5/9 for ftemp in ftemps]
for (ftemp, ctemp) in zip(ftemps, ctemps):
print(f"F:{ftemp:.2f} = C:{ctemp:.2f}")
def m2cm(self):
strm = input("Please enter the meters: ")
chinghwayu /
Last active Nov 14, 2019
Generating data from INI configuration files
from configparser import ConfigParser
def generate_data(filename, name):
"""This function read parameters from an ini file and generates data depending on the 'dtype' option."""
config = ConfigParser()
mode = config.get(name, "mode", fallback="discrete")
dtype = config.get(name, "dtype", fallback="string")
if mode == "discrete":
if dtype == "int":
chinghwayu /
Created Nov 23, 2021
Registers a stevedore plugin dynamically without needing to install as a package
# For python 3.8 and later
import importlib.metadata as importlib_metadata
except ImportError:
# For everyone else
import importlib_metadata
from stevedore import ExtensionManager