Skip to content

Instantly share code, notes, and snippets.

View jim80net's full-sized avatar

Jim Park jim80net

  • Scribd
  • San Francisco, CA
  • 20:16 (UTC -07:00)
  • X @jim80net
View GitHub Profile
@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 = {
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 / add_remove_terraform_quotes
Last active October 25, 2023 00:23
Terrible No Good OneLiner to Add / Remove Quotation marks from terraform files
# It should go without saying, but make sure your terraform file is checked into version control before running this.
# If you find a bug, please let me know =)
# Add quotation marks
elixir -e 'Enum.each(Path.wildcard("**/*.tf"), fn filename -> File.read!(filename) |> String.split("\n") |> Enum.map(fn line -> arraylist = line |> String.trim() |> String.split(" ") |> Enum.map(fn s -> to_charlist(s) end); case arraylist do; [a, b, c, [123]] when a in [[114,101,115,111,117,114,99,101], [100,97,116,97], [112,114,111,118,105,100,101,114], [98,97,99,107,101,110,100]] -> [a,32,34,b,34,32,34,c,34,32,123,10]; _ -> line <> "\n"; end; end) |> to_string() |> String.trim() |> (&(File.write!(filename, &1))).() end)'
# Remove quotation marks from "resource", "data", "provider", and "backend" lines
elixir -e 'Enum.each(Path.wildcard("**/*.tf"), fn filename -> File.read!(filename) |> String.split("\n") |> Enum.map(fn line -> arraylist = line |> String.trim() |> String.split(" ") |> Enum.map(fn s -> to_charlist(s) end); cas
@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 / blobstore_cleanup.rb
Created July 5, 2017 19:20
Cleanup cloudfoundry blobstore-packages
#!/usr/bin/env ruby
require 'date'
require 'pp'
from_bucket = 'example-cc-blobstore-packages'
guid_regexp = Regexp.new(/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/)
DAYS = 7
today = Time.now.to_date
# apps.txt contains a list of app guids, exported from ccdb
@jim80net
jim80net / howdy.md
Last active June 26, 2017 16:39
EHLO I AM CLOUDOOPS

Howdy

Nice meeting you! I'm Jim, a Product Manager for the Cloud Operations team that operates Pivotal Web Services. This email is a work in progress but, here are some things we do as a Cloud Operations team that might be useful patterns for you as a customer, or as a new CloudOps member.

About Pivotal Web Services

Pivotal Web Services is the reference deployment of Cloud Foundry. The Cloud Operations team is based out of San Francisco, colocated with a number of Pivotal's Cloud Foundry Research and Development teams.

Charter

@jim80net
jim80net / apps_using_service.rb
Created March 20, 2017 22:28
A script to return a list of apps that use a CF service
#!/usr/bin/env ruby
require 'json'
require 'pry'
def cf_curl(resource, parameter='')
response = JSON.parse `cf curl /v2/#{resource}?#{parameter}`
raise "pagination" if response["total_pages"] && response["total_pages"] > 1
return response
end
@jim80net
jim80net / datadog.yml.erb
Created January 27, 2017 20:34
A concourse pipeline to push datadog config to various datadog accounts.
---
<%- environments = %W[
staging
prod
gap-cfsandbox-openstack
gap-cfdev-openstack
gap-cfprod-openstack
tracker-aws
] -%>
groups:
@jim80net
jim80net / datadog-firehose-nozzle.yml
Created January 27, 2017 20:33
An example manifest to deploy a datadog firehose nozzle
---
name: datadog-firehose-nozzle
director_uuid: REPLACEME
stemcells:
- alias: bosh-openstack-kvm-ubuntu-trusty-go_agent-raw
os: ubuntu-trusty
version: '3263.15'
instance_groups:
- name: datadog-firehose-nozzle
azs: [nova]