Skip to content

Instantly share code, notes, and snippets.

View davidfraser's full-sized avatar

David Fraser davidfraser

View GitHub Profile
@davidfraser
davidfraser / README.md
Created January 6, 2025 18:26
paint-by-number-svg-output-separator

SVG Processor for Paint by Numbers

This is designed to post-process the SVG output from the brilliant free Paint by Number Generator at paint-by-number.com

Given the SVG file, it separates the different kinds of shapes (number labels, region outlines, and colours for regions) into different layers It also produces an output that doesn't contain the region colours, so is more suitable for printing. It outputs in SVG and PNG, with the names having a suffix of Layers or Outlines accordingly.

@davidfraser
davidfraser / fediverse-clients.md
Created October 3, 2024 18:53
List of free & open source Fediverse clients supporting iOS

Free and Open Source iOS Apps that are Fediverse clients

I haven't included paid-for, non-open source applications. These are ones that seem to be alive as of October 2024 Each one shows links to source code if available, the source code license, and the technology used.

Note that very few Fediverse servers support the ActivityPub Client to Server (C2S) spec; the defacto standard is actually the Mastodon client API, which is why these are mostly described as Mastodon apps. But many of the alternative ActivityPub servers support that API for posting.

iOS-Only Fediverse Apps

@davidfraser
davidfraser / polar_sun_plot.py
Last active September 17, 2024 11:23
polar-sun-plot
#!/usr/bin/env python
"""This plots a sun-like design with alternating curves
The intention is for the curves to alternate being over and under as in Celtic knots
"""
import matplotlib.pyplot as plt
from matplotlib import colors
import numpy as np
import argparse
@davidfraser
davidfraser / patch-aw-web-watcher-profile-names.py
Created August 16, 2024 13:36
Patch ActivityWatch Web Watcher extensions to include profile names in the bucket they submit events to
#!/usr/bin/env python
"""Searches all Chrome profiles for a Windows user for the ActivityWatch Web Watcher extension
and then patches them to include their profile name in the bucket they submit events to
See https://github.com/ActivityWatch/aw-watcher-web/issues/82
"""
import os
from os.path import abspath, exists, expanduser, isdir, join
@davidfraser
davidfraser / setup-wsl-clock-sync.cmd
Last active October 30, 2023 07:23
Set up WSL2 clock sync
@echo off
rem this is a programmatic reminder of how to set up wsl clock sync
rem to prevent clock drift after sleep etc
rem see https://stackoverflow.com/a/65086857/120398 and https://github.com/microsoft/WSL/issues/5324
set WSL_UTF8=1
setlocal EnableDelayedExpansion
for /F "tokens=* delims=" %%D in ('wsl --list --quiet') DO (
set hwclock_count=0
for /f "tokens=* delims=" %%C in ('wsl -d %%D bash -c "grep -c hwclock /usr/local/sbin/hwclock-sync 2>/dev/null"') DO set hwclock_count=%%C
@davidfraser
davidfraser / MaliciousServer3.py
Last active April 5, 2020 00:02
Speed tests for CVE-2020-8492
from http.server import BaseHTTPRequestHandler, HTTPServer
def make_basic_auth(n_commas):
commas = "," * n_commas
return f"basic {commas}A"
comma_tests = [100, 250, 500, 750, 1000, 1250, 1500, 65509]
i = 0
class Handler(BaseHTTPRequestHandler):
@davidfraser
davidfraser / README.md
Created February 17, 2020 15:51
Speed tests for CVE-2020-8492

= CVE-2020-8492 Speed Tests

CVE-2020-8492 describes a DOS opportunity for malicious servers responding to requests from the Python built-in urllib library.

A malicious server can send up to 65,509 additional commas in the WWW-Authenticate header, which triggers an O(2**n) evaluation of a regular expression.

This folder contains a sample malicious server (in Python 3), and sample vulnerable clients (in Python 2 and 3)

@davidfraser
davidfraser / win_encoding_check
Last active January 24, 2020 13:18
Testing Python 2/3 environment variable handling on Windows, including calling subprocesses
This is some notes and sample code on interacting with Windows environment variable encodings etc. See README.md for more info.
@davidfraser
davidfraser / python_weakset_2.7_add_TypeError_fix.patch
Created December 12, 2019 20:54
Patches CPython's _weakrefset.py to prevent a spurious TypeError when adding an item to a WeakSet
This patches WeakSet.add to prevent it having a spurious error if a weak ref goes away between calling this function and adding it
This is done analogously to the patch in https://github.com/python/cpython/commit/f8de3fea1280d55377d40c6e04b64114f9da2fa6:
"#10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does."
See https://bugs.python.org/issue10360 for infomration on that
@@ -83,7 +83,11 @@
def add(self, item):
if self._pending_removals:
self._commit_removals()
- self.data.add(ref(item, self._remove))
@davidfraser
davidfraser / Daily-Standup-JIRA
Last active September 19, 2018 10:43
Some TamperMonkey scripts and bash scripting to make our daily standup report from JIRA
Daily Standup Report for JIRA
=============================
This project contains two tampermonkey scripts (for installation in Chrome),
and a bash script that makes it easier for us to quickly make the report we use at our daily standup meeting