Skip to content

Instantly share code, notes, and snippets.

View glennklockwood's full-sized avatar

Glenn K. Lockwood glennklockwood

View GitHub Profile
@glennklockwood
glennklockwood / basic_cd4017be.py
Created October 9, 2016 22:23
Basic CD4017BE implementation for Raspberry Pi
#!/usr/bin/env python
import RPi.GPIO as GPIO
input_pin = 14
output_pins = [22, 17, 5, 6, 13, 12, 25, 24, 27, 23]
GPIO.setmode(GPIO.BCM)
GPIO.setup(input_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
for pin in output_pins:
GPIO.setup(pin, GPIO.OUT)
i = 0
@glennklockwood
glennklockwood / max7219-column2.py
Last active October 15, 2016 21:44
Turn on/off individual LEDs on a 8x8 matrix driven by MAX7219
#!/usr/bin/env python
import spi
### Initialize an SPI connection using BCM-mode pins 21, 20, and 16
max7219 = spi.SPI(clk=21, cs=20, mosi=16, miso=None, verbose=True)
### Zero out all registers
for cmd in range(16):
packet = cmd << 8
@glennklockwood
glennklockwood / terrible.md
Last active May 29, 2020 13:13
Why Python is terrible
@glennklockwood
glennklockwood / simple_transistor_exp.py
Last active October 30, 2016 01:05
MCP3008 and MCP41010 Transistor Experimentation
#!/usr/bin/env python
"""Vary resistance on a digital potentiometer and measure the effect using
an analog-digital converter"""
import spi # from https://github.com/glennklockwood/raspberrypi
import time
### use two independent SPI buses, but daisy chaining then is also valid
adc = spi.SPI(clk=18, cs=25, mosi=24, miso=23, verbose=False)
digipot = spi.SPI(clk=19, cs=13, mosi=26, miso=None, verbose=False)
@glennklockwood
glennklockwood / omp_binding.c
Created January 4, 2017 06:12
Test to display how OpenMP threads are bound
#include <stdio.h>
#include <sched.h>
int main( int argc, char**argv )
{
#pragma omp parallel
{
printf( "Hello world from thread %d of %d running on cpu %2d!\n",
omp_get_thread_num()+1,
omp_get_num_threads(),
@glennklockwood
glennklockwood / dmidecode.txt
Last active December 17, 2019 11:23
iMac 2017 Hardware
ubuntu@ubuntu:~$ sudo dmidecode
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.
Table at 0x8AF1D000.
Handle 0x0000, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
@glennklockwood
glennklockwood / poke_esnet_graphql.sh
Last active October 21, 2021 23:27
Demonstrate accessing ESnet's SNMP GraphQL service
#!/usr/bin/env bash
CSRF_TOK=$(curl --verbose -D - https://my.es.net/ 2>/dev/null | grep -o 'csrftoken=[^;]*' | cut -d= -f2)
echo "CSRF token = [$CSRF_TOK]"
curl \
--referer https://my.es.net/nersc-400g \
-X POST \
-b "csrftoken=$CSRF_TOK" \
-H "X-CSRFToken: $CSRF_TOK" \
@glennklockwood
glennklockwood / ior-summary.md
Created June 3, 2020 00:38
NERSC Cori IOR Acceptance

Acceptance Test Options

The Cori acceptance test for both the Lustre file system (cscratch) and the burst buffer used IOR to obtain the peak numbers that were advertised.

DataWarp Phase I

DataWarp Phase I used 4480 processes (ppn=4) with the following IOR command-line options:

  • ./IOR -a MPIIO -g -t 512k -b 8g -o $DW_JOB_STRIPED/IOR_file -v
  • ./IOR -a POSIX -F -e -g -t 512k -b 8g -o $DW_JOB_STRIPED/IOR_file -v
@glennklockwood
glennklockwood / restamp-notability-exports.sh
Created September 20, 2020 22:34
restamp-notability-exports.sh
#!/usr/bin/env bash
#
# Update the created/modified dates of PDF files to match the Notability .note
# native format's metadata. Used to preserve date ordering of notes exported
# from Notability.
#
# Step 1. Back up notability to a shared drive in the native "Note" format
# Step 2. Change the backup format to PDF and create PDF versions
# Step 3. Run this script against each .note file
#