Skip to content

Instantly share code, notes, and snippets.

View git-crypt-rm-gpg-user.sh
#!/usr/bin/env bash -x
#
# Script to remove GPG user (recipient) with git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@alexsavio
alexsavio / ssm_transfer.py
Created Oct 26, 2021
SSM Secrets Repository
View ssm_transfer.py
"""
pip install boto3 'boto3-stubs[ssm]'
"""
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_ssm.client import SSMClient
@alexsavio
alexsavio / recapitalize.py
Last active Jun 10, 2021
Recapitalize names
View recapitalize.py
"""
Recapitalize a string of words that has passed a pre-processing, word-cuttind and case lowering process.
"""
import re
import difflib
from typing import Iterator, List, Tuple
def recapitalize_name(original: str, result: str) -> str:
"""Return the `result` with the words capitalized as they appear in `original`."""
@alexsavio
alexsavio / pubsub.py
Created Apr 19, 2021
GCP PubSub publisher
View pubsub.py
import time
from flask import Request
from google.cloud import pubsub_v1
from lib.logger import get_logger
logger = get_logger(__name__)
@alexsavio
alexsavio / switch_cloudwatch_rules.py
Created Dec 1, 2020
Switch on/off AWS CloudWatch Rules
View switch_cloudwatch_rules.py
import os
import logging
from typing import Dict, List
import boto3
from botocore.exceptions import ClientError
class CloudWatchRules:
@alexsavio
alexsavio / gnupg_scdaemon.md
Created Feb 11, 2020 — forked from artizirk/gnupg_scdaemon.md
OpenPGP SSH access with Yubikey and GnuPG
View gnupg_scdaemon.md

OpenPGP SSH access with Yubikey and GnuPG

Yubikey, Smart Cards, OpenSC and GnuPG are pain in the ass to get working. Those snippets here sould help alleviate pain.

Yubikey Config under Ubuntu

To reset and disable not used modes on Yubikey you need the ykman program

You can install it using those commands

View test_timed_cache.py
from time import sleep
from timed_cache import Memoize
def test_memoize():
"""
Test if the cached function results expires in the expected time.
"""
View .gitconfig
[alias]
co = checkout
br = branch
ci = commit
st = status
unstage = reset HEAD --
undo = reset --soft HEAD~1
last = log -1 HEAD
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%C
reset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches
@alexsavio
alexsavio / tmux.md
Created Oct 29, 2019 — forked from andreyvit/tmux.md
tmux cheatsheet
View tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@alexsavio
alexsavio / script.js
Last active Aug 12, 2019
Google Drive autofill template script
View script.js
// create a menu
function onOpen() {
var menuEntries = [ {name: "Create invoice", functionName: "CreateInv"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("Invoice Generator", menuEntries);
}
function CreateInv() {
// specify doc template and get values from spread