Skip to content

Instantly share code, notes, and snippets.

View waveform80's full-sized avatar

Dave Jones waveform80

View GitHub Profile
@waveform80
waveform80 / README.md
Created March 2, 2018 18:13
A quick hack to see if it's feasible to detect shadowed modules on import

Shadow.py

This is a rough'n'ready experiment to see if it's feasible to detect shadowed modules on import. A shadowed module is one where a user has inadvertently named a module the same as a module on the standard search path (a common example in education is "turtle.py" and my own unfortunately named "picamera.py" :).

If this module is imported, it tweaks the standard import machinery to check for such shadowing the first time a module is imported. If it finds any, it raises ShadowWarning (which descends from ImportWarning) giving the path of the imported module, and the path of the first module

@wastrachan
wastrachan / openvpn-in-lxd.txt
Last active March 21, 2023 13:07
OpenVPN in LXD Container
# On the host
=============
lxc config set openvpn raw.lxc 'lxc.cgroup.devices.allow = c 10:200 rwm'
lxc config device add openvpn tun unix-char path=/dev/net/tun
# In the container
==================
1. mknod /dev/net/tun c 10 200
@waveform80
waveform80 / README.md
Last active August 3, 2020 21:39
Extract thumbnails from images captured by picamera.

Relies upon PIL to parse the initial JPEG structure and then does its own TIFF/Exif parsing because PIL's isn't up to dealing with the "full" Exif structure; looks like it gives up after IFD0.

Only tested with the V1 camera module, but I expect it'll work with either model. There's lots of stuff in here which isn't as efficient as it could be and a fair bit of cruft, but it's only a demo :)

@bradfitz
bradfitz / diskchecker.pl
Created July 24, 2012 21:05
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]