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
Last active May 10, 2021 10:47
Bitstrings converter

Bitstrings converter

Probably many people have written something like this, for converting those joke images purporting to contain L3E7 h4xx0R c0deZ.

Data examples:

  • ascii-bits.txt: taken from a random pic of a mini typewriter with a 1 and 0 keyboard.
  • message.txt: taken from a music video ad with an AI-type character

Script:

@taikedz
taikedz / README.md
Created August 28, 2020 07:53
Run Linux X apps on Windows

Run X apps on Windows

Two methods - either through WSL, or through SSH with cygwin/git bash/mingw.

Both require an X server

Easiest so far to install is VcXsrv through chocolatey

  1. Install chocolatey https://chocolatey.org/install
  2. Install vcxsrv: choco install vcxsrv -y
@taikedz
taikedz / README.md
Created August 28, 2020 08:09
Windows things to install

Windows things to install

New workflow for setting up a new Windows machine:

  1. Set up chocolatey https://chocolatey.org/install
  2. Use choco install for everything

Package list:

@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
@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 / README.md
Last active December 9, 2020 09:36
ShellPipe.py - use shell-like piping mechanisms.
@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 / 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 / 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 / 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