Skip to content

Instantly share code, notes, and snippets.

@chazcheadle
chazcheadle / ee.py
Created July 28, 2020 17:58
Write csv of lat/lon from directory of images
#!/usr/bin/env python3
import csv
import os
import exifread
# Prompt for directory to read from.
dir_name = input("Enter the directory to search [./]: ")
csv_file = input("Enter name for output file [output.csv]: ")
if dir_name == '':
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303",
SYMLINK+="serialgps", DRIVERS=="pl2303" TAG+="systemd", MODE="0666", ENV{SYSTEMD_WANTS}="serialgps.service"
@chazcheadle
chazcheadle / Multiple Queries
Last active November 5, 2019 06:58
Python Database Snippets
import concurrent.futures
import time
import psycopg2
import getpass
password = getpass.getpass(prompt='Password')
start = time.perf_counter()
def do_something(letter):
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y git
RUN apt-get update -y
@chazcheadle
chazcheadle / esp8266-mqtt-bme280-MCP9808.ino
Created March 16, 2018 05:42
Adafruit Feather Huzzah, MQTT, BME280/MCP9808, Wifimanager
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <Wire.h>
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
// MQTT Library
#include <PubSubClient.h>
@chazcheadle
chazcheadle / power-use-aggregrator.py
Last active August 31, 2017 04:42
Electric Power Meter Service written in Python with Adafruit.io logging
#!/usr/bin/env python3
## Download your adafruit.io json data and load it.
## UTC_HOURS_OFFSET - Set to match your local offset.
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_json(ADAFRUITIO_JSON_DATAFILE)
# Change index to be usable by TimeGrouper().
@chazcheadle
chazcheadle / config.go
Created June 7, 2017 04:32
Golang Viper config read into struct
package main
import (
"fmt"
"github.com/spf13/viper"
)
// Create private data struct to hold config options.
type config struct {
@chazcheadle
chazcheadle / workdir.sh
Created October 5, 2016 14:23
Bash: Get final path element in working directory
#!/bin/bash
# ex> '/home/on/the/range' will return 'range'
WORKDIR=${PWD##*/}
echo $WORKDIR
@chazcheadle
chazcheadle / Dockerfile_node-v4.4.4
Created October 5, 2016 04:24
Build a Node 4.4.4 factory for Docker
# Create a factory container that can run a specific version of NodeJS/npm/grunt/bower/gulp
FROM centos:7
# Install any required system programs. In this case, 'wget' is is required for fetching the binaries.
RUN yum install -y wget
# Download specific version of NodeJS and install it on the system..
RUN cd /opt; mkdir node-4.4.4; wget http://nodejs.org/dist/v4.4.4/node-v4.4.4-linux-x64.tar.gz; \
tar zxvf node-v4.4.4-linux-x64.tar.gz --strip-components=1 -C ./node-4.4.4; rm -f node-v4.4.4-linux-x64.tar.gz; \
ln -s /opt/node-4.4.4/bin/node /usr/local/bin/node; \
@chazcheadle
chazcheadle / jenkins.vcl
Created October 3, 2016 19:24
Jenkins redirect in Varnish 4
# Jenkins
# This will allow you to run Jenkins as <HOST>/jenkins.
# Varnish 4 declaration
vcl 4.0;
# Backend is using the default Jenkins port.
backend jenkins {
.host = "127.0.0.1";
.port = "8080";