Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
jaysonsantos / main.rs
Last active September 23, 2023 18:44
rust ring example
extern crate ring;
use ring::aead::*;
use ring::pbkdf2::*;
use ring::rand::SystemRandom;
fn main() {
// The password will be used to generate a key
let password = b"nice password";
@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
@jaysonsantos
jaysonsantos / buergerbot.py
Created June 11, 2015 13:34
bürgeramt bot
import subprocess
import time
import bs4
import requests
url = 'http://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister%5B%5D=122210&dienstleister%5B%5D=122217&dienstleister%5B%5D=122219&dienstleister%5B%5D=122227&dienstleister%5B%5D=122231&dienstleister%5B%5D=122238&dienstleister%5B%5D=122243&dienstleister%5B%5D=122252&dienstleister%5B%5D=122260&dienstleister%5B%5D=122262&dienstleister%5B%5D=122254&dienstleister%5B%5D=122271&dienstleister%5B%5D=122273&dienstleister%5B%5D=122277&dienstleister%5B%5D=122280&dienstleister%5B%5D=122282&dienstleister%5B%5D=122284&dienstleister%5B%5D=122291&dienstleister%5B%5D=122285&dienstleister%5B%5D=122286&dienstleister%5B%5D=122296&dienstleister%5B%5D=150230&dienstleister%5B%5D=122301&dienstleister%5B%5D=122297&dienstleister%5B%5D=122294&dienstleister%5B%5D=122312&dienstleister%5B%5D=122314&dienstleister%5B%5D=122304&dienstleister%5B%5D=122311&dienstleister%5B%5D=122309&dienstleister%5B%5D=317869&dienstleister%5B%5D=324433&dienstleister%5B%5D=325341
#!/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) } }'
}
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 / 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
@jaysonsantos
jaysonsantos / caseinsensitivedict.py
Last active March 17, 2021 19:00
Yet another CaseInsensitiveDict implementation
class CaseInsensitiveDict(dict):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__map = {}
mapping = args[0] if len(args) else {}
keys = set()
if isinstance(mapping, dict):
keys |= mapping.keys()
elif isinstance(mapping, (list, tuple)):
@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]