Skip to content

Instantly share code, notes, and snippets.

@nicksnell
nicksnell / discover_lambdas.py
Created July 13, 2023 09:02
Find all the lambda resources in a given cloudformation stack (AWS)
import argparse
import os
import boto3
boto3.setup_default_session(profile_name=os.environ.get("AWS_PROFILE", "default"))
def discover_lambdas(stack_name):
cf = boto3.client("cloudformation")
paginator = cf.get_paginator("list_stack_resources")
@nicksnell
nicksnell / decode_kms.py
Created April 6, 2023 17:14
Decode a KMS value using a specific key
import base64
import boto3
import os
encoded = os.environ.get("ENCODED")
key_arn = os.environ.get("KEY")
profile = os.environ.get("PROFILE")
if key_arn is None or encoded is None:
raise Exception("You must provide a key & encoded values!")
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKy8lId3nxcufvnAcBB3KxnIpwMctB7ODC5vxIvO8BuD
@nicksnell
nicksnell / Brewfile
Created October 6, 2019 19:44
Brewfile - OSX setup
# Install command-line tools using Homebrew
# Usage: `brew bundle Brewfile`
cask_args appdir: "/Applications"
tap "homebrew/cask"
tap "mas-cli/tap"
tap "dart-lang/dart"
tap "heroku/brew"
tap "d12frosted/emacs-plus"
tap "homebrew/cask-fonts"
Vue.component('example-element1', {
render: function (createElement) {
return createElement('h1', 'Example Element 1')
}
})
@nicksnell
nicksnell / delta_dict.py
Created May 29, 2019 15:48
Recursively work out deltas of numbers in dictionaries
def delta_dict(a, b):
result = {}
for key in a.keys():
if isinstance(a[key], dict):
result[key] = delta_dict(a[key], b.get(key, {}))
else:
result[key] = a[key] - b.get(key, 0)
return result
if __name__ == '__main__':
@nicksnell
nicksnell / clear_auth0_users.py
Created May 22, 2019 10:54
Remove a chunk of users (100) from auth0.
import os
import time
from auth0.v3.authentication import GetToken
from auth0.v3.management import Auth0
def main():
domain = os.environ.get('AUTH0_DOMAIN')
client_id = os.environ.get('AUTH0_CLIENT')
secret = os.environ.get('AUTH0_SECRET')
@nicksnell
nicksnell / breed_bands.py
Created May 2, 2019 16:34
Tool for updating breed bands
"""
Tool for creating breed band mappings & updating the Algolia Index
Install:
pip install --upgrade 'algoliasearch>=2.0,<3.0'
Usage:
ALGOLIA_APP_ID= ALGOLIA_API_KEY= ALGOLIA_INDEX= python breed_bands.py
"""
@nicksnell
nicksnell / algolia_export.py
Created July 25, 2018 15:48
Tool for exporting indexes from Algolia
"""
Export an Algolia Index to JSON.
Usage: ALGOLIA_KEY=<some key> ALGOLIA_SECRET=<some secret> ALGOLIA_INDEX=<some index> python algolia_export.py
"""
import os
import json
from algoliasearch import algoliasearch
@nicksnell
nicksnell / keybase.md
Last active November 12, 2018 22:45
Keybase proof

Keybase proof

I hereby claim:

  • I am nicksnell on github.
  • I am nicksnell (https://keybase.io/nicksnell) on keybase.
  • I have a public key ASAHL0bIpe-MKaXfia-d3HprdaEVVDnI8wZokKFuS46omwo

To claim this, I am signing this object: