Skip to content

Instantly share code, notes, and snippets.

@rjw57
rjw57 / Dockerfile
Last active February 6, 2024 14:22
Installing pypy3 and numpy from scratch on Debian 10
# This Dockefile demonstrates how to install upstream pypy3 on a bare Debian 10
# box from scratch.
#
# To test:
# docker run --rm rjw57/pypy3 \
# pypy3 -c 'import numpy as np; M=np.array(range(16)).reshape((4,-1)); Q, R = np.linalg.qr(M); [print(x) for x in (M, Q, R, np.dot(Q,R))]'
FROM debian:10
# Install any system-wide dependencies we need including essential packages
# required to compile C-based Python modules.
@rjw57
rjw57 / pmdown.py
Last active October 23, 2023 02:00
#!/usr/bin/env python3
#
# THIS SCRIPT REQUIRES PYTHON 3
#
# Install requirements via:
# pip3 install docopt pillow reportlab
#
# Dedicated to the public domain where possible.
# See: https://creativecommons.org/publicdomain/zero/1.0/
"""
@rjw57
rjw57 / CGSPrivate.h
Last active December 2, 2022 06:36
CGSPrivate.h - undocumented APIs for OSX. Re-licensed under MIT licence.
/* CGSPrivate.h -- Header file for undocumented CoreGraphics stuff. */
/* This file is a relicensed portion of DesktopManager and was originally released under
* the terms of the GNU General Public Licence. Original licence text follows the new terms.
* The contents of this file has been re-released by the original author under the following terms:
*
* Copyright (C) 2003, 2004, 2013 Richard J Wareham <richwareham@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
/* extractall.c - an example of extracting all files from a zip file in C. */
/* This file should be considered an example, and *not* an exemplar, on how to
* use libzip to extract an archive. */
/* Note: this file goto which is famously considered harmful. We use it only to
* provide poor-man's state cleanup on error and, in this example, it is safe.
* There are other ways to do this which you should consider in your
* application. We use it here because our program is entirely contained within
* one function and the amount of state we're manipulating is small. YMMV. */
@rjw57
rjw57 / england-basemap-osgrid.tiff
Last active September 22, 2018 20:00
A Python script to plot the current delay times on England's major road links.
@rjw57
rjw57 / friendly_hostname.py
Last active September 13, 2018 11:08
Ansible filter plugin to generate deterministic docker-style "friendly hostnames" for a server
# coding=utf8
"""
A plugin which contains a custom Ansible filter named "friendly_hostname"
which takes a string and generates a deterministic human-readable hostname
with a low chance of collision.
The generated hostname has around 24 bits of entropy which is probably OK up to
a few hundred hosts. See: https://en.wikipedia.org/wiki/Birthday_attack
This module may be run via "python -m friendly_hostname" to test the generator.

Compiling OpenCV 3 with Python bindings and pyenv

Dependencies

Luckily Ubuntu has support for getting the build dependencies for a package directly via apt-get:

sudo apt-get build-dep opencv
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// Inputs:
// D4 (T0) - Char clock
// Outputs
// D3 (OC2B) - VSYNC
// D5 (OC0B) - HSYNC
// D10 (OC1B) - Visible
//
// All outputs should be synchronised to the rising edge of char clock