Skip to content

Instantly share code, notes, and snippets.

View sapslaj's full-sized avatar

Justin Roberson sapslaj

View GitHub Profile
@sapslaj
sapslaj / output
Created February 21, 2024 23:15
cdktf-aws-cdk idempotency issue
$ npx ts-node repro.ts
/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/node_modules/constructs/src/construct.ts:447
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
^
Error: There is already a Construct with name 'bucket43879C71' in TerraformHost [adapter]
at Node.addChild (/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/node_modules/constructs/src/construct.ts:447:13)
at new Node (/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/node_modules/constructs/src/construct.ts:71:17)
at new Construct (/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/node_modules/constructs/src/construct.ts:499:17)
at new TerraformElement (/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/node_modules/cdktf/lib/terraform-element.ts:36:5)
at new TerraformResource (/home/sapslaj/code/github.com/sapslaj/scratch/cdktf-adapter-repro/no
@sapslaj
sapslaj / disable_yt_subtitles.js
Last active November 1, 2023 08:13
Auto-disable subtitles with Enhancer for YouTube
// 1. copy/paste this into the Custom Script in Enhancer for YouTube
// 2. enable "Automatically execute the script when YouTube is loaded in a tab"
// 3. ???
// 4. profit
const ccbutton = document.querySelector('.ytp-subtitles-button');
if (ccbutton && ccbutton.attributes['aria-pressed'].value === 'true') {
// note: set the above to `=== 'false'` if you want subtitles to always enable
ccbutton.click();
}
@sapslaj
sapslaj / black_pprint.py
Last active February 13, 2024 20:48
Pretty print Python object with Black
import black
import black.mode
def pprint(o):
mode = black.mode.Mode(target_versions={black.mode.TargetVersion.PY311})
print(black.format_str(repr(o), mode=mode))

Write a Terraform module that creates an AWS Route53 record that does active-active failover to two backend servers with healthchecks.

Sure, I can help you with that! Here's an example Terraform module that creates an AWS Route53 record that does active-active failover to two backend servers with healthchecks.

First, create a variables.tf file to define the input variables for the module:

variable "zone_id" {
  type        = string
  description = "The ID of the Route53 hosted zone"
@sapslaj
sapslaj / INSTRUCTIONS.md
Last active July 21, 2022 02:26
Standalone script to help manage notes
  1. Create git repo mkdir notes && cd notes && git init
  2. Copy note.py (with or without the .py file extension) into git repo
  3. Run ./note --new My First Note to create a new note
  4. Run ./note --save to commit.

Optional steps:

  • Set EDITOR and do ./note --new --open ... to immediate open the new note in your editor
  • Create a private repo on git remote service (e.g. GitHub, GitLab, etc.) and set that as remote origin.
  • This means you can do ./note --save --push to immediately commit and push the new commit to the remote.
@sapslaj
sapslaj / automount-sshfs.service
Last active November 7, 2021 21:52
complicatedly automount sshfs mounts
# /home/sapslaj/.config/systemd/user/automount-server.service
# sudo systemctl daemon-reload && systemctl --user enable --now automount-server.service
[Unit]
Description=automount sshfs
StartLimitIntervalSec=60
StartLimitBurst=4
[Service]
ExecStart=/home/sapslaj/.local/bin/automount_sshfs
Restart=on-failure
@sapslaj
sapslaj / extract-to-folder.nemo_action
Last active November 21, 2023 01:59
Extract To Folder Nemo Action
[Nemo Action]
Active=true
Name=Extract to %f
Comment=Extract to new folder called "%f"
Exec=<extract-to-folder.py %F>
Icon-Name=gnome-mime-application-x-compress
Selection=any
Extensions=zip;7z;ar;cbz;cpio;exe;iso;jar;tar;tar;7z;tar.Z;tar.bz2;tar.gz;tar.lz;tar.lzma;tar.xz;apk;
Quote=double
@sapslaj
sapslaj / renew-atlassian-letsencrypt-cert.sh
Last active May 9, 2018 05:31
Script to renew Atlassian (Jira, Confluence, etc) applications that use a Let's Encrypt certificate
SITE=jira.example.com
PASS=muhpassword
KEYTOOL=/opt/atlassian/jira/jre/bin/keytool
KEYSTORE=/home/jira/.keystore
SERVICE=jira
# pull down nginx since it uses port 80
systemctl stop nginx
# Use port 80 to renew the cert
@sapslaj
sapslaj / csv_json.rb
Last active April 25, 2018 13:15
Convert JSON to CSV and vice-vera
require 'csv'
require 'json'
require 'active_support/all'
def json_to_csv(json_file, csv_file)
CSV.open(csv_file, "w") do |csv|
data = JSON.parse(File.read(json_file))
csv << data.inject([]) { |keys, d| [keys, d.keys].flatten.uniq }.map(&:titleize)
data.each { |d| csv << d.keys.map { |key| d[key] } }
end

Keybase proof

I hereby claim:

  • I am sapslaj on github.
  • I am sapslaj (https://keybase.io/sapslaj) on keybase.
  • I have a public key ASAZ09ZrNEjgy5xOO8CX0mLyi7UyzRAOW-_9mywLmou7Ggo

To claim this, I am signing this object: