Skip to content

Instantly share code, notes, and snippets.

View alexlopes's full-sized avatar
🏠
Working from home

Alex Lopes alexlopes

🏠
Working from home
View GitHub Profile
@alexlopes
alexlopes / openssl.md
Created August 3, 2023 12:58
OpenSSL tricks

Check match cert and private key

openssl s_server -cert my_cert.crt -key my_pvt_key.key -debug

Check secured connection

openssl s_client -connect google.com:443
@alexlopes
alexlopes / tmux.conf
Created July 7, 2023 13:48 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/opt/firefox/firefox-bin %u
Name=Firefox
Comment=Definição personalizada para Firefox
@alexlopes
alexlopes / terraform_tricks.md
Created June 30, 2021 21:14
Terraform Tricks

Returns a JSON result for External Data Sourcce

data "external" "generate_secret" {
  program = ["bash", "${path.module}/get-name.sh"]

 query = {
@alexlopes
alexlopes / kafka_python_sasl_scram.py
Last active January 18, 2024 18:01
Kafka Python with SASL/SCRAM Authentication Example
import os
from kafka import KafkaProducer, KafkaConsumer
BOOTSTRAP_SERVERS=os.gentenv("KAFKA_BOOTSTRAP_SERVERS").split(",")
TOPIC_NAME="the-topic"
SASL_USERNAME=os.gentenv("KAFKA_SASL_USERNAME")
SASL_PASSWORD=os.gentenv("KAFKA_SASL_PASSWORD")
def consume():
consumer = KafkaConsumer(TOPIC_NAME, security_protocol="SASL_SSL", sasl_mechanism="SCRAM-SHA-512", sasl_plain_username=SASL_USERNAME, sasl_plain_password=SASL_PASSWORD, bootstrap_servers=BOOTSTRAP_SERVERS)
@alexlopes
alexlopes / k8s_tricks.md
Created June 10, 2021 12:20
K8s Tricks

Get Pods by Owner name

kubectl get pods -o jsonpath='{range .items[?(@.metadata.ownerReferences[0].name == "owner name")]}{.metadata.name}{"\n"}{end}'
@alexlopes
alexlopes / read-access.sql
Created December 3, 2020 19:17 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@alexlopes
alexlopes / lowvol_mac.sh
Created June 16, 2020 12:56
Mac Os Low Volume - Keep Input Volume Mic under 50 %
# thanks to https://apple.stackexchange.com/a/236425/379437
#!/bin/bash
while true ; do
while (( `osascript -e "input volume of (get volume settings)"` > 50 )); do
osascript -e "set volume input volume (input volume of (get volume settings) - 2)";
sleep 0.01;
done;
sleep 1;
done;
@alexlopes
alexlopes / autoupdate_ff.sh
Last active September 14, 2020 16:12
Autoupdate Firefox -
#!/bin/sh
echo "Downloading latest version for linux 32bits in pt-BR"
wget -v --content-disposition "https://download.mozilla.org/?product=firefox-latest&os=linux&lang=pt-BR" -O - | tar -xvj
echo "Removing"
rm -Rf /usr/lib/firefox
@alexlopes
alexlopes / github_gpg_config.md
Created March 25, 2020 15:05
Github + GPG + Custom gitconfig

Github + GPG + Custom gitconfig

Add includeIf directive into original .gitconfig

In the end of your original .gitconfig add includeIf with the directory where your .gitconfig-B will be applied:

# ref https://dzone.com/articles/how-to-use-gitconfigs-includeif
# when gitdir matchs, then use .gitconfig-B