Skip to content

Instantly share code, notes, and snippets.

Avatar

Brandon Stafford pingswept

View GitHub Profile
View fabfile.py
from fabric import task
# Usage
#
# fab -H pi@192.168.1.217 --prompt-for-login-password deploy
@task
def deploy(c):
hostname = c.run('hostname', hide=True).stdout
print('\033[32;1mLogged into {0}\033[0m'.format(hostname))
@pingswept
pingswept / profiling-example.py
Last active Mar 9, 2021
profiling-example.py
View profiling-example.py
import cProfile
import pstats
from pysolar.solar import *
import datetime
import random
latitudes = random.sample(range(-90, 90), 100)
longitudes = random.sample(range(-180, 180), 100)
@pingswept
pingswept / memoize-demo.py
Created Mar 4, 2021
Demo of how to memoize a function in Python
View memoize-demo.py
import functools
import timeit
import time
@functools.lru_cache(maxsize=None)
def fib(n):
if n < 2:
return n
return fib(n-1) + fib(n-2)
View whatever.ino
/*
WiFi Web Server LED Blink
A simple web server that lets you blink an LED via the web.
This sketch will print the IP address of your WiFi module (once connected)
to the Serial monitor. From there, you can open that address in a web browser
View Whatever.html
https://us-school.pk12ls.com/school/fe1b3ad5-8762-4e0f-8e3d-56440bfbe441/D0680545/player.html
@pingswept
pingswept / drivestrength.ino
Created Oct 26, 2020
Fixing the drive strength mode on the Arduino MKR Wifi 1010
View drivestrength.ino
void setup() {
pinMode(4, OUTPUT);
setHighStrengthOutputPinMode(4);
}
void loop() {
digitalWrite(4, HIGH);
}
bool setHighStrengthOutputPinMode( uint32_t ulPin)
@pingswept
pingswept / ventilate.py
Last active Jul 1, 2018
Python script to turn a fan on and off based on SHT31 temperature and temperature from the internet
View ventilate.py
from Adafruit_IO import *
import json
import requests
import RPi.GPIO as GPIO
import smbus
import time
aio = Client('XXXXXXXXXXXXXXXXX_ADAFRUIT_API_KEY_GOES_HERE_XXXXXXXXXXXXXXXXX')
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD
@pingswept
pingswept / replify.py
Created Aug 8, 2017
Script for Chris to manipulate his G-code
View replify.py
infile = "infile.txt" # the file to open
copies = 3 # how many copies to make
marker = "STARTHERE\n"
with open(infile, 'r') as infile:
lines = infile.readlines()
#print(lines)
startline = lines.index(marker)
result = ''.join(lines + (lines[startline + 1:] * copies))
View sneakers.csv
Brand Model Size Width Good/bad
New Balance Fresh Foam Gobi 14 EE Ill-fitting and stiff, but low arch is good. VL-6 last. Might be okay. Should try v2, will drop in July 2017.
New Balance Fresh Foam Hierro v2 14 4E Almost good but arch too high. Same PL-4 last as favorite MO69v1's. Disappointing.
New Balance Minimus 10v1 14 EE Almost good but arch too high. NL-1 last. Very comfy other than arch.
Montrail Fluid Flex FKT 14 -- WINNER! 8 pairs, 6 left. Update: not on Zappos any more. One color on columbia.com, May 2017.
Brooks Puregrit 4 14 -- Trevor recommended but haven't tried yet because of previous Brooks being too short in 14.
Topo MT-2 14 -- Kept. Might be serviceable.
Montrail Fluid Flex ST 14 -- WINNER! 3 pairs. Update: no longer available.
Nike Air Zoom Wildhorse 3 14 -- kept. Insole is a little stiff but could be a winner.
Montrail Fluid Flex II 14 ? Good. 1 pair. Blisters on long runs. Update: no longer available.
@pingswept
pingswept / winterize.md
Last active Sep 3, 2015
Winterizing the house
View winterize.md

Closing

  • Cut power to well pump
  • Cut power to hot water heater with circuit breaker
  • Close main water valve
  • Open all faucets, and leave them open
    • kitchen sink, including blowing out spray hose
    • bathroom #1, including shower
    • bathroom #2, including shower
  • Drain water heater through garden hose