Skip to content

Instantly share code, notes, and snippets.

View gabrielfalcao's full-sized avatar
👨‍💻
probably writing tests

Gabriel Falcão gabrielfalcao

👨‍💻
probably writing tests
View GitHub Profile
#######b. ### ### .d####b.########################b d##############
### Y##b### ###d##P Y##b ### ### ####b d#### ###
### ###### ###Y##b. ### ### #####b.d##### ###
### d##P### ### "Y###b. ### ####### ###Y#####P### ###
#######P" ### ### "Y##b. ### ### ### Y###P ### ###
### T##b ### ### "### ### ### ### Y#P ### ###
### T##b Y##b. .d##PY##b d##P ### ### ### " ### ###
### T##b "Y#####P" "Y####P" ### ### ### ### ###
# ignore = [] # Skip formatting the specified files and directories
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@gabrielfalcao
gabrielfalcao / get-free-tcp-port.py
Created October 31, 2015 18:30
Getting a random free tcp port in python using sockets
# Getting a random free tcp port in python using sockets
def get_free_tcp_port():
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp.bind(('', 0))
addr, port = tcp.getsockname()
tcp.close()
return port
@gabrielfalcao
gabrielfalcao / rsa_encryption.py
Created November 30, 2019 00:39
Using python cryptography module to generate an RSA keypair, serialize, deserialize the keys and perform encryption and decryption
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
def utf8(s: bytes):
return str(s, 'utf-8')
@gabrielfalcao
gabrielfalcao / hexspeak
Created July 28, 2016 04:23 — forked from dannyow/hexspeak
Hexspeak word list
00D1E5
0111E
0115
011ED
011F1E1D
011F1E1D5
015E
01AF
01D1E
@gabrielfalcao
gabrielfalcao / cryptography_ecdsa.py
Created November 30, 2019 00:38
Ed25519 signing in python
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
Ed25519PrivateKey,
Ed25519PublicKey,
)
from cryptography.hazmat.primitives import serialization
private_key = Ed25519PrivateKey.generate()
public_key = private_key.public_key()
@gabrielfalcao
gabrielfalcao / kubectl-forward-all-service-ports.sh
Created June 14, 2023 08:06
shell script to forward all the kubernetes service ports to localhost while automatically handling port numbers < 1024 (e.g.: 443 to 8443)
#!/usr/bin/env bash
for json in $(kubectl get svc -o json | jq -c '.items[] | select(.kind == "Service") | {name:.metadata.name, port:.spec.ports[0].port}'); do
service=$(echo "${json}" | jq .name | tr -d '"')
remote_port=$(echo "${json}" | jq .port | tr -d '"')
local_port=$((remote_port))
if [ $((local_port)) -lt 1024 ]; then
local_port=$((local_port + 8000))
fi
echo kubectl port-forward "service/${service}" "${local_port}:${remote_port}"
done
--ignore-dir=node_modules/
--ignore-dir=.venv/
--ignore-dir=.venv
--ignore-dir=*.egg-info
--ignore-dir=...
--ignore-dir=.caches
--ignore-dir=man
--color-colno=137
--type-add=rs=.rs
#!/usr/bin/env bash
set -exu