Skip to content

Instantly share code, notes, and snippets.

@hovissimo
hovissimo / aws-creds.zsh
Last active February 5, 2024 19:33 — forked from ddgenome/aws-creds.bash
Fetch AWS STS keys and set environment variables
#!/bin/zsh
# Fetch 24-hour AWS STS session token and set appropriate environment variables.
# See http://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html .
# You must have jq installed and in your PATH https://stedolan.github.io/jq/ .
# Add this function to your .bashrc or save it to a file and source that file from .bashrc .
# Online: https://gist.github.com/hovissimo/c9119820a5a4f5a6081d93f87f1688b4
# Adapted from https://gist.github.com/ddgenome/f13f15dd01fb88538dd6fac8c7e73f8c
#
# usage: aws-creds AWS_PROFILE MFA_TOKEN [OTHER_AWS_STS_GET-SESSION-TOKEN_OPTIONS...]
# example: aws-creds staging 123456
def collatz():
global number
if number % 2 == 0:
number = number // 2
print(number)
return number
else:
number = number * 3 + 1
import re
import csv
re_degenerates = re.compile(r"[wsmkrybdhvn]")
def get_patterns(filename):
with open(filename) as f:
#lines = f.readlines()[2:] # the first two lines aren't data
lines = f.readlines()
for record in csv.reader(lines):
@hovissimo
hovissimo / node-red
Last active August 29, 2015 14:04 — forked from bigmonkeyboy/README.md
#! /bin/sh
# Starts and stops Node-RED
# /etc/init.d/node-red
### BEGIN INIT INFO
# Provides: node-red
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Node-RED initialisation