Skip to content

Instantly share code, notes, and snippets.

View taikedz's full-sized avatar

Tai Kedzierski taikedz

View GitHub Profile
@taikedz
taikedz / README.md
Created January 31, 2022 12:19
Kill unkillable Jenkins job

Kill unkillable Groovy job

If a job is running a system groovy script, it cannot be simply "aborted"

You need to go to $jenkins_url/script and run the contents of the attched script, replacing the original job_line content with the path (from URL) of your job

@taikedz
taikedz / decorator_example.py
Last active January 10, 2022 11:13
Python Decorator Example
"""
A Python decorator is a special function that can be added above a
callable definition (function, class, anything that implements the
`__call__()` method)
When a decorated function is called, it is in fact the decorator
itself that is called, and the wrapped callable is then normally
called by the implementing handler of the decorator.
A Python decorator is comprised of 3 parts:
@taikedz
taikedz / README.md
Created December 8, 2021 17:17
Download Love2d.org's principal wiki documentation pages.

Love2D.org/wiki downloader

The Love2D wiki is a great starting resource. Mostly I do small-time game development for fun, on long flights or train journeys, or out in remote places. Frankly, it's the only time when I am guaranteed time to not be disturbed for sufficiently long periods.

And so, I need the main wiki in local, offline, usable format.

This script is a considereate slurper which shouldn't DoS the server in the slightest.

@taikedz
taikedz / README.md
Last active November 18, 2021 15:40

Plot times examples

As a network behaviour demonstration, I did a repeated clone-out of a Git repository, writing its timestamp data with date '+%F %T' in columns one and two (start and end times) of a CSV

This Python script processes that CSV to produce a plot of the durations:

  • timedeltas calculated using datetime
  • plotting using matplotlib.pyplot
  • adding labels at spaced out intervals, and rotated
@taikedz
taikedz / rename-tracks.py
Created September 7, 2021 11:44
Tool to rename tracks
""" Rename files
rename-tracks.py TRACKFILE [apply]
TRACKFILE is a basic text file, each line containing a track name.
This script naively looks for the track name in each file name.
If found, the old file name and new file name are printed.
If a title matches multiple files, an error is raised.
@taikedz
taikedz / lizard_complexity.py
Last active September 3, 2021 09:04
Wrap lizard's CSV complexity output in a usable object, and give usage example
import sys
from collections import namedtuple
# A friendlier named object for working with each output line
Analysis = namedtuple("Analysis", [
"NLOC", # Count of number of active LOC (excl whitespace)
"CCN", # Cyclomatic Complexity Number
"token", # token count: how many syntactic tokens ("if", "[", "5", etc) are used in the functions
"PARAM", # number of parameters to the function
@taikedz
taikedz / README.md
Last active March 26, 2021 12:17
Get the sample frequency on a loop call to `time.time()`

Time Sampling

I was curious to know what level of precision I could get when using time.sleep(x), like, if it made any sense to try and sleep for say 0.0132 seconds.

It turns out, it does. On a Windows machine with a 1.6GHz processor, I get a sample rate such:

$ python3 time_sampling.py 6
Average step over 1000000 (100.0%) iterations: 2.77e-07
@taikedz
taikedz / README.md
Last active December 9, 2020 09:36
ShellPipe.py - use shell-like piping mechanisms.
@taikedz
taikedz / README.md
Created October 14, 2020 10:04
Convert YAML data to Python

Quick one-off script to convert a yaml file to native python.

python3 convert-yaml-to-python.py YAMLFILE > my_data.py

A little naive, but a quick tool otherwise.

@taikedz
taikedz / deepyaml.py
Last active September 10, 2020 16:49
Load a YAML file with references to other YAML files
import yaml
import os
class RecursiveYamlLoad(Exception):
pass
def mingw_path(path):
#TODO not yet finished
""" Running Python in MinGW (incl Git Bash) causes abspath() to mangle the path