Skip to content

Instantly share code, notes, and snippets.

@sportebois
sportebois / akita-flask-article-snippet-03-new-fixtures.py
Created October 13, 2020 16:36
Automatically start/stop the exposer in a thread
@fixture(scope="session")
def exposer_thread(request):
start_exposer_thread()
def close():
stop_exposer_thread()
request.addfinalizer(close)
@sportebois
sportebois / api_helpers.py
Last active October 13, 2020 16:32
Akita SuperLearn - expose Flask requests/responses from pytests and Flask test client
# file: tests/api_helpers.py
import logging
import threading
from copy import deepcopy
from threading import Thread
from typing import Optional
from uuid import uuid4
import requests
@sportebois
sportebois / ec2-small-inventory.sh
Created December 11, 2019 13:15
Dumps a CSV of EC2 instances (no pagination, up to 200 per region)
#!/usr/bin/env bash
set -eu
dumpInstances() {
local readonly region="$1"
local readonly date_ts="$(date +%Y%m%d-%H%M)"
aws ec2 describe-instances \
--max-items 200 \
@sportebois
sportebois / ec2inventory.sh
Created July 22, 2019 18:18
List EC2 instances and create CSV files with the desired fields (AZ, Tag, ...)
#!/usr/bin/env bash
set -eu
dumpInstances() {
local readonly region="$1"
local readonly date_ts="$(date +%Y%m%d-%H%M)"
aws ec2 describe-instances \
--max-items 200 \
@sportebois
sportebois / fmtnomad.sh
Last active November 21, 2018 15:40
Nomad job formatter (chmox+x and symlink it in your $PATH)
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
#/ Description:
#/ Run Terraform fmt on nomad file to format HCL, and update the file in place.
#/
#/ Arguments:
#/ $1 the nomad flie
#/ --diff if set, then do not write the changes, but show the diff between current and cacnonical format
@sportebois
sportebois / firacode_in_github.css
Last active November 10, 2018 22:23
FiraCode on Github (Stylish rule)
/* Github */
@import url(https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css);
.blob-code-inner,
.markdown-body .highlight pre,
.markdown-body pre, tt, code {
font-family: "Fira Code","SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
font-feature-settings: "calt" 1;
font-variant-ligatures: contextual;
@sportebois
sportebois / bitbucket.css
Last active November 10, 2018 21:53
Stylish rules to use FiraCode for code diffs and snippets in Github, Gitlab, Bitbucket and stackoverflow
/* Bitbucket */
@import url(https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css);
/* Bitbucket code and diffs */
.refract-content-container .line-numbers,
.refract-content-container .source {
font-family: 'Fira Code';
}
@sportebois
sportebois / aws_mfa_auth.sh
Last active November 5, 2018 13:42
AWS CLI: Easy MFA auth
#!/usr/bin/env bash
set -e
# Note: this will overwite your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY if you use it
# (I usually prefer using ~/.aws/credentials profile and leave those unset)
# Use this script by sourcing the output directly, like:
# $(./aws_mfa_auth.sh)
# Or
# $(./aws_mfa_auth.sh arn:aws:iam::123456789012:mfa/bob)
@sportebois
sportebois / vernemq_prometheus_metrics_sorted.txt
Created October 10, 2018 11:52
VerneMQ Prometheuse metrics
# ---- BYTES
# HELP bytes_received The total number of bytes received.
# TYPE bytes_received counter
bytes_received{node="nodeName"} 8504294780
# HELP bytes_sent The total number of bytes sent.
# TYPE bytes_sent counter
bytes_sent{node="nodeName"} 7981953590
# ---- CLIENT
@sportebois
sportebois / NGINX-conf-snippet-dns-resolvers.conf
Created July 12, 2018 14:55
NGINX config snippets with various common DNS resolvers
# Potential resolvers:
# AWS VPC (should be the default): 169.254.169.253
# AWS EC2 classic (goes out of VPC): 172.16.0.23
# Google global DNS: 8.8.8.8
# Quad9 DNS: 9.9.9.9
# Cloudflare's 1⁴ : 1.1.1.1 / 1.0.0.1
resolver 169.254.169.253;