Skip to content

Instantly share code, notes, and snippets.

View jranson's full-sized avatar

James Ranson jranson

View GitHub Profile
@jranson
jranson / context.ts
Created March 3, 2023 17:27 — forked from bodokaiser/context.ts
React Hook integration for AWS Amplify Auth
import React from "react"
import { CognitoUser } from "@aws-amplify/auth"
import { useAuth } from "./hooks"
import { SignInInput } from "./types"
interface AuthState {
user: CognitoUser | null
signIn(input : SignInInput): Promise<void>
signOut(): Promise<void>
@jranson
jranson / main.tf
Created February 8, 2022 21:37
Terraform - Create S3 Bucket + Certs + DNS + CloudFront
variable "app_domain" {
type = string
}
variable "app_hostname" {
type = string
}
variable "app_bucket" {
type = string
@jranson
jranson / csv_to_dynamodb.py
Created February 6, 2022 01:22
Load to DynamoDB from a CSV
import sys
import csv
import boto3
dynamodb = boto3.resource('dynamodb')
def main():
if len(sys.argv) != 3:
print("Usage: csv_to_dynamodb.py tableName filename")
@jranson
jranson / deepgrep.sh
Last active January 29, 2021 04:29
deepgrep (recursive grep with globs)
# add this function to your .bash_profile or .zshrc
#
# usage (all files): deepgrep 'my[Expression]'
# usage (filtered files): deepgrep '*.go' MyString
#
# if your file filter uses a glob wildcard, enclose it in quotes
#
deepgrep() {
if [[ $# -eq 0 || $# -gt 2 ]]
@jranson
jranson / packet.swift
Created December 21, 2020 19:17
set MIDIPacket data from an array
//
// packet.swift
//
// As CoreMIDI/MIDIPacket exposes the 'data' member as a Tuple in Swift, this
// solution accepts a varying size [UInt8] and returns the corresponding tuple.
// Usage is as follows:
//
// packet.data = packetDataFromBytes(data: myArray)
//
// Created by James Ranson on 12/19/20.
@jranson
jranson / TextView.swift
Created December 21, 2020 19:12
TextView control for SwiftUI
//
// TextView.swift
// TextView provides a scrollable, read-only, clipboard-copyable text field
// for use with SwiftUI macOS apps. Because it uses NS* classes, it is
// not compatible with iOS, tvOS, etc.
//
// Created by James Ranson on 12/19/20.
//
import Foundation
@jranson
jranson / lapse.sh
Last active January 29, 2021 04:28
PiCam Time Lapse Maker w/ ffmpeg
#!/bin/bash
# PREREQUISITES
#
# fswebcam (sudo apt-get install fswebcam)
# imagemagick (sudo apt-get install fswebcam)
# lighttpd (sudo apt-get install lighttpd)
# ffmpeg (wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-armhf-static.tar.xz)
#