Skip to content

Instantly share code, notes, and snippets.

View hopkinsth's full-sized avatar

Thomas Hopkins hopkinsth

View GitHub Profile
@hopkinsth
hopkinsth / test.tf
Created August 19, 2021 20:15
terraform intersection test
locals {
one = [
{
name = "thomas",
age = 32
}
]
two = [
{
@hopkinsth
hopkinsth / read-plan-json.py
Created April 25, 2020 13:03
finding changes, tf plan json
import json
with open("test-plan.json", 'r') as f:
j = json.loads(f.read())
for rc in j['resource_changes']:
if 'no-op' not in rc['change']['actions']:
if 'update' in rc['change']['actions'] and 'content' in rc['change']['before']:
old = json.loads(rc['change']['before']['content'])
new = json.loads(rc['change']['after']['content'])
import os
import pathlib
import subprocess
base = '/Users/user/Library/Mobile Documents/com~apple~CloudDocs/Music'
d = os.fsencode(base)
def findwmas(dir):
cur = os.fsdecode(dir)
for file in os.listdir(dir):
@hopkinsth
hopkinsth / convert-to-mp3.sh
Created April 18, 2020 17:03
convert something to mp3 in a subfolder
find . -type f -name '*.wma' -print0 | xargs -0 -I 'FILE' /bin/bash -c 'export CUR="FILE"; export DIREC=$(dirname "${CUR}"); export BASE=$(basename "${CUR}"); avconv -y -i "${CUR}" -acodec libmp3lame -ab 192k "${DIREC}/MP3/${BASE/.wma/.mp3}"'
@hopkinsth
hopkinsth / connection-tester.py
Created March 16, 2020 14:45
TGW connection tester
import socket
def lambda_handler(event, context):
s = socket.create_connection(('hostname', 3306))
s.shutdown(socket.SHUT_RDWR)
return 'good'
color getafe
set number " show line numbers
set ruler " show line and column number
syntax enable
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set shiftwidth=2 " an autoindent (with <<) is two spaces
set expandtab " use spaces, not tabs
@hopkinsth
hopkinsth / workflow.yml
Created August 26, 2019 18:52
github action test
name: Lambda Releaser
on: [release, push]
jobs:
build:
name: Builder
runs-on: ubuntu-18.04
steps:
- run: mkdir -p go/src/github.com/redventures
- uses: actions/checkout@v1
@hopkinsth
hopkinsth / something.go
Created February 22, 2019 19:19
some http testing stuff, idk maybe I'll want this
package whatever
type captureRTR struct {
urls map[string]map[string]*http.Response
}
func newCaptureRTR() *captureRTR {
var g captureRTR
g.urls = map[string]map[string]*http.Response{}
return &g
@hopkinsth
hopkinsth / main.go
Created February 1, 2019 19:16
http server base
package main
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
"time"
@hopkinsth
hopkinsth / feedback.md
Last active March 4, 2018 21:03
notes on spieglt/flying-carpet

Overall Feedback

this app is cool

objective-c looks just as frightening as the last times I have read any of it

I mean I know enough objective-c to be dangerous but it still looks wacky! (sorry, not really feedback for you but!)

Consider using some data serialization format for sending informational data to and fro

Consider an instance of the app waiting to receive a file, which will wait for data to appear in order across the TCP link: first the filename length, then the filename, then the chunk size, and finally data chunks from the sender. It may be better, especially for future expansion of the metadata you need to send, to define structures for each of these steps and transmit them across the link. I am sure it will have some impact on performance, but it should be relatively negligible.