Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
jaysonsantos / downloadAppletAsJnlp.js
Created May 14, 2022 09:38
Enable the download of simple applets to jnlp format
// ==UserScript==
// @name Convert applet to downloadable jnlp
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://192.168.1.23/kvms.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=1.23
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.js
#!/usr/bin/env python
"""
Generate colored entries for the extension AWS Extend Switch Roles [1].
[1] https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl
"""
from pathlib import Path
from configparser import ConfigParser
CONFIG = Path("~/.aws/config").expanduser()
# based on https://github.com/junegunn/fzf/wiki/Examples#autojump
function _fzf_autojump() {
fzf --height 40% --reverse --inline-info
}
function _fzf_cleanup() {
awk '$1 ~ /[0-9]:/ && $2 ~ /^\// { for (i=2; i<=NF; i++) { print $(i) } }'
}
@jaysonsantos
jaysonsantos / setup-kubectl-eks-aws-vault.py
Created April 13, 2021 16:43
Setup kubeconfig with eks and aws-vault
#!/usr/bin/env python3
import json
import os
import shlex
from configparser import ConfigParser
from copy import deepcopy
from pathlib import Path
from subprocess import check_call, check_output
from ruamel import yaml
function gclone() {
local organization
local repositories
organization="$1"
repositories="$(gh repo list -L 1000 "$organization" | fzf --multi --cycle | awk '{print $1}')"
for repository in $repositories; do
echo "Cloning $repository"
gh repo clone "$repository"
done
}
@jaysonsantos
jaysonsantos / vpn-nat.ps1
Last active March 12, 2021 14:52
Use openvpn inside WSL2 and be able to route traffic from windows through linux
# On linux side you need iptables
# On windows side you need sudo which can be installed with scoop
$CidrBlocks = "10.0.0.0/16", "10.1.0.0/16", "10.70.0.0/16", "10.3.0.0/16"
$WslIP = "$(wsl -- ip addr show dev eth0 | Select-String -Pattern 'inet ')"
$WslIP = $WslIP.Split(' ').Where{ $_.Length }[1].Split('/')[0]
function BuildIptablesRoute {
param (
[Parameter(Mandatory = $true)]
import re
from dataclasses import dataclass, fields
from typing import Dict
CAMEL_CASE_RE = re.compile(r'([a-z])([A-Z])')
@dataclass(frozen=True)
class ApiGatewayRequest:
headers: Dict[str, str]
-- Logs begin at Sat 2019-10-19 17:13:06 CEST, end at Tue 2019-12-03 16:16:09 CET. --
Oct 22 22:00:17 jayson-lg systemd[1]: Started ZeroTier One.
Oct 23 09:59:20 jayson-lg zerotier-one[17481]: connect: Network is unreachable
Oct 23 09:59:20 jayson-lg zerotier-one[17481]: connect: Network is unreachable
Oct 23 21:42:00 jayson-lg zerotier-one[17481]: connect: Connection timed out
Oct 31 21:08:29 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:08:29 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
Oct 31 21:14:06 jayson-lg zerotier-one[17481]: connect: Connection refused
@jaysonsantos
jaysonsantos / Dockerfile
Last active December 28, 2019 20:07
killbill api with fargate/ecs/kubernetes systems
FROM killbill/killbill:0.20.0
ADD kpm.yml /var/lib/killbill/kpm.yml
# Patch to respect X-Fowarded-Proto and others when running with ELB
ADD server.xml.patch ./
RUN patch -p1 < server.xml.patch
# Script that setup traps to respect docker stop commands and stop catalina
ADD fargate-killbill.sh ./
find_kafka_device() {
for device in $(nvme list | grep ^/dev | awk '{print $1}')
do
local found_device="$(nvme id-ctrl -v $device | grep -Po '/dev/[a-z0-9]+' || true)"
if [[ -n "$found_device" ]]; then
echo "$device"
return 0
fi
done