Skip to content

Instantly share code, notes, and snippets.

View jim80net's full-sized avatar

Jim Park jim80net

  • Scribd
  • San Francisco, CA
  • 18:20 (UTC -07:00)
  • X @jim80net
View GitHub Profile
@jim80net
jim80net / tf_move_state.sh
Last active February 25, 2022 10:21
Move terraform state between projects.
#!/usr/bin/env bash
##
# Usage: tf_move_state.sh source_directory target_directory source_resource_name <target_resource_name (uses source_resource_name if not provided)>
# Provide source and target directories using relative paths.
# WARNING: TEST ON AN INCONSPICUOUS AREA AS STAINING MAY OCCUR
# Credit to https://github.com/mcalhoun
set -e
@jim80net
jim80net / cleanup_many_terraform_locks.md
Last active January 20, 2022 14:13
Accidentally abort a large terragrunt run?

Oops, now you've got a bunch of locked modules. Here's a brute force method to remove every lock from dynamodb. Use this with caution.

Lets say your terraform is configured like this:

terraform {
  required_version = "= 1.0.8"

  required_providers {
    aws = {
@jim80net
jim80net / empty.sh
Created November 4, 2021 21:48
Empty a AWS Cloud Map Namespace
for i in $(aws servicediscovery list-services --filter Name=NAMESPACE_ID,Values=[ns-MYNAMESPACEIDHERE],Condition=EQ --query "Services[].Id" --output text) ; do aws servicediscovery delete-service --id $i; done
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main" | xargs git branch -D
@jim80net
jim80net / init.lua
Created April 30, 2021 19:09
My ~/.hammerspoon/init.lua
hs.window.animationDuration = 0
units = {
right30 = { x = 0.70, y = 0.00, w = 0.30, h = 1.00 },
right50 = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 },
right70 = { x = 0.30, y = 0.00, w = 0.70, h = 1.00 },
left70 = { x = 0.00, y = 0.00, w = 0.70, h = 1.00 },
left50 = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 },
left30 = { x = 0.00, y = 0.00, w = 0.30, h = 1.00 },
top50 = { x = 0.00, y = 0.00, w = 1.00, h = 0.50 },
bot50 = { x = 0.00, y = 0.50, w = 1.00, h = 0.50 },
@jim80net
jim80net / gist:0095d0c576713dfaf3d9
Created August 9, 2015 18:38
Make yosemite iso
From https://discussions.apple.com/thread/6619535
by tywebb13
If you prefer to make a bootable dvd, you can do it this way:
After downloading the full Yosemite installer app from the Mac App Store, run these 14 commands in Terminal to create a Yosemite.iso file and then burn it to a dual layer DVD with Disk Utility. You may then boot up from it by holding the option key down and then install Yosemite.
hdiutil attach /Applications/Install\ OS\ X\ Yosemite.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
@jim80net
jim80net / print_kbfs_update_history
Last active April 4, 2018 03:44
oneliner: Print KBFS update history for any given top level folder
ruby -rjson -e 'a = JSON.parse File.read(".kbfs_update_history"); a["Updates"].each {|v| ops = v["Ops"].map {|op| op["Op"]}.select {|op| op !~ /gc|sync|resolution/ }.join("\n".ljust(53)); printf("Op: %s by %s on %s: %s\n", v["Revision"].to_s.ljust(4), v["Writer"].ljust(15), (v["Date"][0,19]), ops ) if ops !~ /^$/ }'
@jim80net
jim80net / cipher_check.sh
Created June 25, 2014 21:54
Test SSL handshake against known handshake methods
#!/usr/bin/env bash
# http://superuser.com/questions/109213/is-there-a-tool-that-can-test-what-ssl-tls-cipher-suites-a-particular-website-of
# OpenSSL requires the port number.
SERVER=$1
DELAY=0
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
@jim80net
jim80net / install.sh
Created September 3, 2012 21:07
Install jenkins server on SmartOS
#!/bin/pseudo-bash
# Read through this and modify to taste.
# Tested on:
# dataset_uuid: c36a3d28-80c2-11e1-9ec6-df5bd8b43f76
# sdc:sdc:smartosplus:3.2.0
mkdir /data
useradd -d /data dev
groupadd dev
cd /data
@jim80net
jim80net / download_scripts_and_templates.rb
Created December 3, 2015 23:59
Download scripts and templates dir from a git repo. (useful for deploying OSS CF releases)
#!/usr/bin/env ruby
# Usage: ./download_scripts_and_templates <repo> <ref>
# Output: Directory of download
require 'bundler/setup'
require 'logger'
require 'octokit'
require 'base64'
def prereqs