Skip to content

Instantly share code, notes, and snippets.

@sportebois
sportebois / docker_registry_cleaner.py
Last active September 25, 2021 10:02
Clean untagged images from AWS ECR registry
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import argparse
import boto3
parser = argparse.ArgumentParser(description='Cleanup Docker images form ECR.')
parser.add_argument('--repository-name', metavar='repo', dest='repository_name', required=True, help='Repository name')
parser.add_argument('--registry-id', metavar='registry', dest='registry_id', required=False, help='Registry ID.If you do not specify a registry, the default registry is assumed.')
parser.add_argument('--delete', dest='delete', required=False, default=False, action='store_true', help='If set to true, delete the untagged images. Otherwise (default), only list them')
@sportebois
sportebois / nginx-simple-rate-limits.conf
Created March 21, 2017 20:24
Simple NGINX config to compare base rate limiting, burst, and burst with nodelay
limit_req_zone $request_uri zone=by_uri:10m rate=30r/m;
server {
listen 80;
location /by-uri/burst0 {
limit_req zone=by_uri;
try_files $uri /index.html;
}
@sportebois
sportebois / keybase.md
Created April 18, 2017 20:27
Keybase identity proof

Keybase proof

I hereby claim:

  • I am sportebois on github.
  • I am sportebois (https://keybase.io/sportebois) on keybase.
  • I have a public key whose fingerprint is FBCA E30C BFC4 D896 DA6F EFDC 372F 643B EB94 3C61

To claim this, I am signing this object:

@sportebois
sportebois / load-yaml-dump-json.bash
Created April 24, 2017 10:56 — forked from ingydotnet/load-yaml-dump-json.bash
load-yaml-dump-json A script to test YAML load against many implementations
#!/bin/bash
# Usage:
#
# cat file.yml | load-yaml-dump-json
# ./load-yaml-dump-json # enter data and ctl-d when finished
yaml=`cat`
echo == Perl
@sportebois
sportebois / python_sslerror_pem_lib.md
Last active January 24, 2018 16:33
Python: Troubleshoot `ssl.SSLError: [SSL] PEM lib (_ssl.c:2964)` errors

Python: Troubleshoot ssl.SSLError: [SSL] PEM lib (_ssl.c:2964) errors

This error is reasied when the key cannot be parsed. Since the error code and message are totally helpless, this gist is here to help you verify your certificate and key are correct, which have been the root cause when such error was raised in our Python code.

Sample use case:

ssl_context.load_cert_chain(certfile=certfile, keyfile=keyfile, password='secret')
# Raise SSLError
@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 / markdown_in_shell.sh
Created February 10, 2018 18:38
Read markdown file in the command line
# Markdown utilities (requires `brew install pandoc`)
function mdless () {
local mdfile=$1
if [ -z ${mdfile:+x} ]; then mdfile="README.md"; fi
case $mdfile in
-h | --help)
print "mdless usage: 'mdless myfile.md' or 'mdless' (defaults to README.md)"
;;
*)
mdcat $mdfile | less
@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 / 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 / firacode_in_gitlab.css
Last active February 18, 2018 20:52
FiraCode in Gitlab (Stylish rule)
/* Gitlab */
@import url(https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css);
.file-content.code pre code,
.wiki code,
.diff-file .diff-content table {
font-family: 'Fira Code';
}