Skip to content

Instantly share code, notes, and snippets.

View todgru's full-sized avatar

todgru

  • Portland, OR
View GitHub Profile
@todgru
todgru / mac-keyboard-symols.md
Created August 11, 2023 22:02
special symbols on mac osx mu/micro µ degree °

Mac Keyboard Symbols

  • µ mu Option + M Example: 27 µs
  • ° degree Shift + Option + 8 Example: 32°C
@todgru
todgru / terraform-move.md
Last active June 6, 2023 21:35
Terraform, move/rename resource to module, AWS

Moving/Renaming Terraform Resources

We have several resources manually created using the AWS Console. I want to manage these resources with Terraform. Originally, I had imported these resources into the Terraform state using individual files. Instead, I should have used modules. I tried moving my files into modules and then using the module to refer to the resource, but the namespace was incorrect. Applying changes at this point would have destroyed and recreated the resources, which is unnecessary.

This is how I moved the resources within the state. This should work for any resource listed in the Terraform state.

Setup the modules

Copy over any resouces declarations to the module format. I didn't rename anything, but I think it is possible at this point.

@todgru
todgru / ssh-tunnel.md
Last active May 6, 2023 15:32
How to set-up a SSH tunnel for AWS RDS

SSH Tunnel

Our db is hosted on Amazon. Our web server can connect to the db. Connections to the db are not allowed outside of the web server.

Run ssh tunnel locally:

This creates a tunnel from my local machine to the web server:

ssh -N -L 3307:my-rds-db.us-east-1.rds.amazonaws.com:3306 ec2-my-web-server.compute-1.amazonaws.com
@todgru
todgru / gh-share-string.md
Created April 20, 2023 19:25
Github Actions - sharing string files between jobs, base64

Github Actions - sharing string files between jobs

Store multiline string as base64 -w 0 job output, and consume in subsequent job.

jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
 envFile: ${{ steps.tempEnvFile.outputs.envFile }}
@todgru
todgru / launchd.md
Last active April 20, 2023 17:54
Launchd and plist, replace cron in Mac OS X

#launchd Usage

I have a bash script called foo.sh that takes one command line argument, bar. I want it to run every 60 seconds and load at startup.

  • an XML plist is Apple Property List
  • com.mydomain.foo.plist Name of launchd plist file should be a reverse fqdn, like (this may not be required, but convention)
  • com.mydomain.foo.plist lives in $HOME/Library/LaunchAgents and is ran as that user.
  • com.mydomain.foo.plist can also live /Library/LaunchDaemons or /Library/LaunchAgents, have requirements, ran as root
  • Load plist with launchctl load com.mydomain.foo.plist
  • Unload plist with lauchctl unload com.mydomain.foo.plist
@todgru
todgru / hey-gpt
Created March 29, 2023 22:18 — forked from senko/hey-gpt
Small bash script to use ChatGPT from command line
#!/bin/bash
if test -z "$1"; then
echo "Usage: $0 <prompt>"
exit 1
fi
if test -z "$OPENAI_API_KEY"; then
echo "OpenAI key is missing - \$OPENAI_API_KEY must be set"
exit 1
@todgru
todgru / regex-find-all-empty-lines.md
Created March 24, 2023 17:34
regex: find all empty lines
^$\n
@todgru
todgru / regex-do-not-contain.md
Created March 24, 2023 17:33
regex: find all line that do not contain word
^((?!foo).)*$
@todgru
todgru / find-missing-packages.md
Last active March 22, 2023 19:26
recursively find package.json files that are missing a "test" script, exclude "node_modules" from the search
find . -type d -name "node_modules" -prune -o -name "package.json" -type f -exec grep -L '"test"' {} \;
@todgru
todgru / npm-list.md
Created March 20, 2023 20:28
list all the node modules and dependency tree - looks great when using NPM workspaces

npm list