Skip to content

Instantly share code, notes, and snippets.

@bamarch
bamarch / swap-env-secrets.sh
Last active April 12, 2024 12:24
Entrypoint: swap envs for secrets (POSIX)
#!/bin/sh
# What:
# A POSIX compliant entrypoint script that replaces environment variable values with the content of files
# e.g. secrets mounted into the container using the Kubernetes Secrets Store CSI Driver
# Why:
# - You run applications in Kubernetes and use the Kubernetes Secrets Store CSI Driver.
# - A POSIX compatible container requires secrets to be passed in as environment variables
# - You cannot modify the application
@bamarch
bamarch / lambda_logging.py
Last active April 12, 2024 12:23
Python: Log to Datadog from AWS Lambda
"""Logger for use in Lambda functions.
Replaces the default AWS provided logger with our own.
Provides a structure format that can be easily parsed i.e. by datadog.
"""
import json
import logging
import sys
import time
import traceback
from functools import wraps
@bamarch
bamarch / resize-droplet.bash
Created October 14, 2018 15:42
bash wrapper around doctl digital ocean cli, can be used to backup & resize a droplet
#!/usr/bin/env bash
# Note if you try to resize to the same size, it just takes a backup.
# One use is to setup as a crontab configured to auto scale down your
# servers at 3am (in-case you forget, saving you money).
# Dependencies:
# doctl (DO cli)
# jq (a great json manipulating cli tool)
@bamarch
bamarch / keybase.md
Created July 18, 2018 11:28
keybase.md

Keybase proof

I hereby claim:

  • I am bamarch on github.
  • I am bamarch (https://keybase.io/bamarch) on keybase.
  • I have a public key ASCgTmGPNa-BCKuXLKAGGs9EIGQlnFbFii9loy9ic1H6Qwo

To claim this, I am signing this object:

@bamarch
bamarch / GradleDaemon_threadDump.out
Last active April 6, 2018 09:42
Gradle 4.6 sometimes hangs for hours during build
2018-04-05 12:18:57
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode):
"Attach Listener" #733 daemon prio=9 os_prio=0 tid=0x00007faec8001000 nid=0x2102 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"/0:0:0:0:0:0:0:1:36148 to /0:0:0:0:0:0:0:1:43732 workers Thread 4" #682 prio=5 os_prio=0 tid=0x00007fac18064800 nid=0x152c runnable [0x00007fad1ccbf000]
@bamarch
bamarch / WhatsAppCleaner.py
Created January 14, 2017 14:13 — forked from keskarnitish/WhatsAppCleaner.py
Clean WhatsApp Generated Text File for Image Cloud Scripts
#Extremely simple script to cleanup the conversation data that WhatsApp generates
#You can email yourself the conversation from your WhatsApp mobile application, run this script and use any popular word cloud generator like http://www.wordle.net/create.
#TO DO: Include code to create wordcloud as well. Possibly https://github.com/atizo/PyTagCloud or https://github.com/amueller/word_cloud
#Usage: python WhatsAppCleaner.py Foo.txt
from sys import argv
script, filename = argv
f = open(filename,'r')
for line in f:
try: