Skip to content

Instantly share code, notes, and snippets.

View tmountjr's full-sized avatar

Tom Mount tmountjr

  • Philadelphia, PA
View GitHub Profile
import network
import uasyncio
from time import sleep
class NetworkManager:
def __init__(self, ssid, password):
self.ssid = ssid
self.password = password
self.station = network.WLAN(STA_IF)
self.last_known_ip = None
@tmountjr
tmountjr / response.html
Created October 20, 2023 17:45
Edge Function Lab Files
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather</title>
</head>
<body>
<h1>Weather</h1>
<p>Your location: [lat/lng]</p>
@tmountjr
tmountjr / colorpicker.py
Last active June 12, 2023 16:47
CircuitPython Color Picker
import wifi
print(f'IP address: {wifi.radio.ipv4_address}')
import time
import board
import neopixel
import socketpool
import microcontroller
from adafruit_httpserver import Server, Request, Response, POST
@tmountjr
tmountjr / code.py
Created June 12, 2023 04:11
CircuitPython AQI Meter
import os
import ssl
import time
import wifi
import board
from neopixel import NeoPixel
from socketpool import SocketPool
from adafruit_requests import Session
print(f'IP address: {wifi.radio.ipv4_address}')
const { min, max, round } = Math
// Conversion functions. See https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative.
const a = (S, L) => S * min(L, 1 - L)
const k = (n, H) => (n + (H / 30)) % 12
const f = (n, H, S, L) => L - a(S, L) * max(-1, min(k(n, H) - 3, 9 - k(n, H), 1))
// Calculate individual red, green, and blue values.
const red = (H, S, L) => round(255 * f(0, H, S, L))
const green = (H, S, L) => round(255 * f(8, H, S, L))
@tmountjr
tmountjr / get-fastly-ip.js
Last active June 1, 2020 18:20
Get the most recent list of Fastly IP ranges and save the output in a format that can be used with the Fastly API's bulk update commands.
#!/usr/bin/env node
const fs = require('fs');
const https = require('https');
const url = 'https://api.fastly.com/public-ip-list';
https.get(url, res => {
let body = '';
res
.setEncoding('utf8')
@tmountjr
tmountjr / genesis_public_key
Created February 20, 2018 14:51
genesis_public_key
04e1110a48b0d9051cde9d247eb76a515f90f966435e82055cc66ab80fe713ec25c5dba646332d5647f5126e6a9cc7fdc337f93ff5229b25d16c5ce9a554592047

Keybase proof

I hereby claim:

  • I am tmountjr on github.
  • I am tmountjr (https://keybase.io/tmountjr) on keybase.
  • I have a public key whose fingerprint is E15E 25EC 5004 E2A9 D4FB 2E4D 2DEA 3733 3294 7821

To claim this, I am signing this object:

@tmountjr
tmountjr / convert.js
Last active December 9, 2015 16:41
Quick and dirty way to convert a CSV file to JSON on the command line via node.
#!/usr/bin/env node
var fs = require('fs'),
path = require('path'),
infile = process.argv[2] || '',
outfile = process.argv[3] || '',
saveToDisk = false;
if (infile == '') {
console.error('Please supply a filename.');
@tmountjr
tmountjr / HtmlSelectOutputTrait.php
Created June 26, 2015 15:44
Laravel 4.x trait to generate an HTML select box directly from the eloquent model. Allows the use of a callback to generate the list of option IDs and values.
<?php
/**
* This trait defines functionality used to generate an HTML select box directly from the eloquent model.
* Three static values are accessed by this trait and should be defined by the model:
* static $valueField
* static $formControlId
* static $valueFieldClosure (optional)
*/