Skip to content

Instantly share code, notes, and snippets.

@kwoods
kwoods / aws_dockerfile
Created March 15, 2021 16:24
Testing out Monolithic AWS Dockerfile
FROM python:3.9-buster
ENV AWSCLI_VERSION=2.1.30
RUN apt-get update && \
apt-get install jq make zip git groff -y
RUN cd /tmp && \
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
@kwoods
kwoods / aws_env_helper.zsh
Last active November 6, 2020 17:00
ZSH Shell Function for populating ENV with AWS Keys from ~/.aws/credentials profiles
# Usage: aws_env_helper <profile-name-in-aws-credentials>
# add this to your ~/.zshrc
aws_env_helper () {
readonly profile=${1:?"The aws profile must be specified."}
export AWS_ACCESS_KEY_ID="$(aws configure get aws_access_key_id --profile $profile)"
export AWS_SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key --profile $profile)"
export AWS_SESSION_TOKEN="$(aws configure get aws_session_token --profile $profile)"
export AWS_PROFILE=$profile
export AWS_RETRY_MODE=adaptive
export AWS_MAX_ATTEMPTS=10
@kwoods
kwoods / Example usage
Created August 10, 2020 02:35 — forked from pdarragh/Example usage
A simple script to extract colors from iTerm color profiles as hexadecimal values.
$ ./iterm2hex.py "Solarized Dark Higher Contrast.itermcolors"
#002731 // Ansi 0 Color
#D01B24 // Ansi 1 Color
#50EE84 // Ansi 10 Color
#B17E28 // Ansi 11 Color
#178DC7 // Ansi 12 Color
#E14D8E // Ansi 13 Color
#00B29E // Ansi 14 Color
#FCF4DC // Ansi 15 Color
#6BBE6C // Ansi 2 Color
@kwoods
kwoods / pixelbook_go_setup.md
Last active March 18, 2022 19:30
Pixelbook Go Setup

Swap Alt and Control keys

One of the first things a MacBook user might do on a Chromebook is mistakenly hit the Alt key instead of the Control key because on a MacBook keyboard, you use the Command key for many keyboard shortcuts such as cut, copy and paste. And a MacBook's Command key is directly to the left of the spacebar, just as the Alt key is on a Chromebook. Thankfully, you can reassign the Alt and Control keys on a Chromebook. Just click your account profile picture in the bottom-right corner and then click the gear icon. From the Settings window, scroll down to the Device section and click Keyboard and then assign the Ctrl key as Alt and the Alt key as Ctrl.

Set up Linux (Beta) on your Pixelbook

  • Select the time in the bottom right to open your status area.
  • Select Settings (gear icon)
  • Under "Linux (Beta)," select Turn On

Once the Linux (Beta) is enabled, the Terminal app will appear in the launcher.

@kwoods
kwoods / parse_json.sh
Created May 5, 2020 12:13 — forked from elliptic-shiho/parse_json.sh
JSON Parser for POSIX Shell Script
#!/bin/sh
cat -| awk '
{
gsub(/&lt;/, "<")
gsub(/&gt;/, ">")
gsub(/&amp;/, "&")
gsub(/&quot;/, "\"")
gsub(/\{/, "{\n")
gsub(/\}/, "\n}")
import os
import time
from typing import List, Dict
import requests
def get_python_jobs() -> List[Dict]:
jobs = []
page = 0
more_data = True
@kwoods
kwoods / get-stack-name.sh
Last active October 15, 2019 10:49
Get EC2 Instance's Stack Name
#!/bin/bash
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}')
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 describe-instances \
--instance-id $INSTANCE_ID \
--query 'Reservations[*].Instances[*].Tags[?Key==`aws:cloudformation:stack-name`].Value' \
--region $REGION \
--output text
@kwoods
kwoods / client_throttle.py
Created November 8, 2016 03:17 — forked from bblincoe/client_throttle.py
Amazon AWS Client Throttle in Python (boto3)
import boto3
import botocore
from random import randint
from time import sleep
def client_throttle(action, **kwargs):
while True:
try:
return action(**kwargs)
except botocore.exceptions.ClientError as e:
@kwoods
kwoods / boto3_hands_on.md
Created November 7, 2016 15:31 — forked from iMilnb/boto3_hands_on.md
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
@kwoods
kwoods / jenkins_jobs.py
Created August 5, 2016 02:11
Jenkins API Access for Querying Job Times
>>> c.connect()
>>> c.request('GET', '/job/test-dsl/17/api/json', headers={'Accept': 'text/json'})
>>> resp = c.getresponse()
>>> jsondata = resp.read()
>>> data = json.loads(jsondata.decode())
>>> print(data['duration'])