Skip to content

Instantly share code, notes, and snippets.

View evindunn's full-sized avatar

Evin Dunn evindunn

  • Zoom Video Communications
  • Flagstaff, AZ
View GitHub Profile
@evindunn
evindunn / Dockerfile
Created April 28, 2020 15:28
Sending emails from PHP container
FROM php:7-fpm
RUN apt-get update && \
apt-get install -y \
msmtp-mta \
&& \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN printf 'host my.smtp.server\n' > /etc/msmtprc
@evindunn
evindunn / logger.js
Last active June 7, 2020 08:25
NodeJS Winston Logger
const winston = require("winston");
const winstonFmt = winston.format;
const TIMESTAMP_FMT = "YYYY-MM-DD HH:mm:ss";
const NANOS_IN_MILLI = BigInt(1e6);
const LOG_LEVEL = process.env.LOG_LEVEL || "warn";
const LOG_LEVELS = {
levels: {
error: 0,
@evindunn
evindunn / rate-limit-test.py
Last active June 25, 2021 16:15
rate-limit-test.py
#!/usr/bin/env python3
import requests
import time
from sys import argv
from threading import Thread
URL = argv[-1]
def worker(i, url):
#!/usr/bin/env python3
from urllib.request import urlretrieve
from tempfile import NamedTemporaryFile, TemporaryDirectory
from zipfile import ZipFile
from glob import iglob
from os.path import join as path_join
from xml.etree import ElementTree
from json import dumps as json_stringify
from re import sub as regex_sub
@evindunn
evindunn / json2yaml.py
Last active June 25, 2021 22:35
json2yaml.py
#!/usr/bin/env python3
# Uses PyYAML>=0.2.5
from yaml import dump as yaml_dump
from json import load as json_load, JSONDecodeError
from argparse import ArgumentParser
from os.path import exists as path_exists
from sys import exit, stderr
@evindunn
evindunn / lcd_server.py
Last active September 28, 2021 21:33
Raspberry Pi i2C LCD Server
#!/usr/bin/env python3
from RPLCD.i2c import CharLCD
from argparse import ArgumentParser
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from json import dumps as json_dumps
from sys import stderr
from threading import Lock
from board import I2C
@evindunn
evindunn / temp_server.py
Last active September 28, 2021 20:38
DHT11 Temperature Sensor as HTTP Service
#!/usr/bin/env python3
from argparse import ArgumentParser
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from json import dumps as json_dumps
from threading import Thread, RLock
from time import sleep
import Adafruit_DHT
@evindunn
evindunn / cockroach.docker-compose.yml
Last active December 6, 2021 20:18
CockroachDB cluster in docker-compose
# See https://www.cockroachlabs.com/docs/v21.2/start-a-local-cluster-in-docker-mac.html
version: "3.9"
services:
roach1:
image: "cockroachdb/cockroach:v21.2.2"
container_name: taxonTree-roach1
hostname: roach1
networks: [ roachnet ]
volumes: [ "roach1-data:/cockroach/cockroach-data" ]
command:
#!/bin/bash
if [ $# -lt 1 ]; then
echo Provide a date to convert
exit 1
fi
# Provide 'Fri 18 Feb 2022 05:30:00 PM PST'
DATE=$1
@evindunn
evindunn / clock.py
Last active May 12, 2022 06:50
RPLCD World Clock
#!/usr/bin/env python3
from RPLCD.i2c import CharLCD
from pytz import timezone, utc
from datetime import datetime
from time import sleep, time as get_ts
from concurrent.futures import ThreadPoolExecutor
I2C_EXPANDER = "PCF8574"