Skip to content

Instantly share code, notes, and snippets.

@pawl
pawl / setup.md
Last active November 13, 2021 20:40
ubuntu 21.04 setup
View gist:e7344b177ce44861592348014589a085
ERROR: Exception:
Traceback (most recent call last):
File "/Users/blah/.pyenv/versions/2.7.18/envs/blah.com/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 224, in _main
status = self.run(options, args)
File "/Users/blah/.pyenv/versions/2.7.18/envs/blah.com/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/Users/blah/.pyenv/versions/2.7.18/envs/blah.com/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 403, in run
pycompile=options.compile,
File "/Users/blah/.pyenv/versions/2.7.18/envs/blah.com/lib/python2.7/site-packages/pip/_internal/req/__init__.py", line 90, in install_given_reqs
pycompile=pycompile,
@pawl
pawl / lcdthermocouple_oled.c
Last active December 19, 2020 05:49
lcd thermocouple with 128x64 Yellow Blue SSD1306 OLED
View lcdthermocouple_oled.c
// based on the lcdthermocouple example
// also:
// https://randomnerdtutorials.com/esp32-ssd1306-oled-display-arduino-ide/
// http://www.esp32learning.com/code/esp32-and-max6675-example.php
// 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
pawl / sd_card.txt
Created December 6, 2020 22:39
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
pawl / new_probe.ino
Last active March 16, 2023 18:52
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
pawl / sketch.ino
Created September 12, 2020 04:14
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
pawl / raspberry_pi_3b.txt
Last active March 17, 2022 19:13
pihole performance - raspberry pi 4b vs3b vs zero w
View raspberry_pi_3b.txt
$ go run dnstrace.go -c 10 -s 192.168.1.94 -n 100 www.googletagservices.com
Benchmarking 192.168.1.94:53 via udp with 10 conncurrent requests
Total requests: 1000 of 1000 (100.0%)
DNS success codes: 1000
DNS response codes
NOERROR: 1000
@pawl
pawl / readme.md
Created April 26, 2020 20:48
binding hotkey to change headset/speakers on windows
View readme.md
  1. download nircmd: https://www.nirsoft.net/utils/nircmd.html
  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
pawl / cups-orangepi.md
Last active June 8, 2022 12:56
installing CUPS on orangepi zero
View cups-orangepi.md
  1. download ubuntu image for orangepi zero LTS: http://www.orangepi.org/downloadresources/
  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: http://www.orangepi.org/downloadresources/
  9. flash with etcher
  10. armbian-config
@pawl
pawl / example.py
Created April 23, 2020 03:53
attempt at ModelChoiceField queryset caching
View example.py
# See full example: https://github.com/pawl/django_modelchoicefield_caching/blob/master/myapp/views.py#L31-L51
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