Skip to content

Instantly share code, notes, and snippets.

View gist:e7344b177ce44861592348014589a085
ERROR: Exception:
Traceback (most recent call last):
File "/Users/blah/.pyenv/versions/2.7.18/envs/", line 224, in _main
status =, args)
File "/Users/blah/.pyenv/versions/2.7.18/envs/", line 180, in wrapper
return func(self, options, args)
File "/Users/blah/.pyenv/versions/2.7.18/envs/", line 403, in run
File "/Users/blah/.pyenv/versions/2.7.18/envs/", line 90, in install_given_reqs
pawl / lcdthermocouple_oled.c
Last active Dec 19, 2020
lcd thermocouple with 128x64 Yellow Blue SSD1306 OLED
View lcdthermocouple_oled.c
// based on the lcdthermocouple example
// also:
// parts:
// * HiLetgo DC 3-5V MAX6675 Module + K Type Thermocouple Temperature Sensor
// * UCTRONICS 0.96 Inch OLED Module 12864 128x64 Yellow Blue SSD1306 Driver I2C
// * ESP32
#include <max6675.h>
pawl / sd_card.txt
Created Dec 6, 2020
samsung evo+ sd card vs samsung bar usb 3.1 flash drive write performance on raspberry pi 4
View sd_card.txt
# samsung evo+ sd card
pi@raspberrypi:~ $ dd if=/dev/zero of=/home/pi/test bs=8k count=50k conv=fsync; rm -f /home/pi/test
51200+0 records in
51200+0 records out
419430400 bytes (419 MB, 400 MiB) copied, 17.0585 s, 24.6 MB/s
pawl / new_probe.ino
Last active Dec 12, 2020
arduino modbus coffee roaster with 2 thermocouples for artisan software
View new_probe.ino
* This sketch programs Ardunio to communicate with Artisan using MODBUS protocol and
* an inexpensive thermocouple amplifier.
* Hardware:
* Arduino UNO
* Thermocouple amplifier (MAX6675)
* K-type thermocouple
* Libraries needed:
pawl / sketch.ino
Created Sep 12, 2020
modbus arduino max6675 artisan roasterscope
View sketch.ino
* This sketch programs Ardunio to communicate with Artisan using MODBUS protocol and
* an inexpensive thermocouple amplifier.
* Hardware:
* Arduino UNO
* Thermocouple amplifier (MAX6675 or MAX31855)
* K-type thermocouple
* Libraries needed:
pawl / raspberry_pi_3b.txt
Last active Dec 6, 2020
pihole performance - raspberry pi 4b vs3b vs zero w
View raspberry_pi_3b.txt
$ go run dnstrace.go -c 10 -s -n 100
Benchmarking via udp with 10 conncurrent requests
Total requests: 1000 of 1000 (100.0%)
DNS success codes: 1000
DNS response codes
pawl /
Created Apr 26, 2020
binding hotkey to change headset/speakers on windows
  1. download nircmd:
  2. unzip to C:\
  3. go to sound devices and rename to simpler names without spaces (headphones/speakers)
  4. Open logitech gaming software and change 2 buttons to "shortcut" with these commands:
  • "C:/nircmd/nircmd/exe setdefaultsounddevice Speakers"
  • "C:/nircmd/nircmd/exe setdefaultsounddevice Headphones"
pawl /
Last active Dec 14, 2020
installing CUPS on orangepi zero
  1. download ubuntu image for orangepi zero LTS:
  2. flash with etcher
  3. fiddle with USB to TTL, gave up on trying to get that to work
  4. plug ethernet into switch
  5. ssh orangepi@
  6. password orangepi
  7. couldn't successfully apt-get update upgrade, getting E: Unable to acquire the dpkg frontend lock
  8. download armbian image for orangepi zero LTS:
  9. flash with etcher
  10. armbian-config
pawl /
Created Apr 23, 2020
attempt at ModelChoiceField queryset caching
# See full example:
for song in playlist:
form_data = {'title': song["title"], 'artist': song["artist"]}
song_form = forms.SongFormWithModelChoiceField(data=form_data)
song_form.is_valid() # runs a query to get the ModelChoiceField queryset each time
print('ModelChoiceField - query count AFTER validating all songs:',
len(connection.queries)) # 5 queries
# query for choices outside of the loop to prevent unnecessary queries
pawl /
Last active Feb 14, 2020
Django's biggest gotcha?

In my opinion, one of django's biggest gotchas is using RelatedManager.set with models that have non-nullable ForeignKey fields.

Example (with a one-to-many relationship and a non-nullable ForeignKey):

class Reporter(models.Model):
    name = models.CharField(max_length=255)

class Article(models.Model):