Skip to content

Instantly share code, notes, and snippets.

View brccabral's full-sized avatar
🐔
Vamos, Galo! Ganhar o Brasileiro!

Bruno Cabral brccabral

🐔
Vamos, Galo! Ganhar o Brasileiro!
View GitHub Profile
@brccabral
brccabral / 01_README.md
Last active August 30, 2025 22:05
C++ Print formatter

std::print - C++ Print formatter

  • To use std::print need g++-14 and compile with -std=c++23.
    sudo apt install g++-14
    sudo rm /usr/bin/g++
    sudo ln -s /usr/bin/g++-14 /usr/bin/g++

g++ -std=c++23 print_me.cpp -o print_me

@brccabral
brccabral / 01_README.md
Last active August 29, 2025 04:19
Emscripten

Emscripten

  • Clone and install SDK
    • save $EMSDK as environment var in your .profile/.zprofile/.bashrc/zshrc to make it easier later
    • install will run for a long time
git clone --depth=1 --recurse-submodules --shallow-submodules https://github.com/emscripten-core/emsdk.git
cd emsdk
export EMSDK=$(pwd) # save in you .profile or .bashrc/.zshrc
$EMSDK/emsdk install --shallow sdk-main-64bit # this takes a long time
@brccabral
brccabral / README.md
Created April 28, 2025 21:30
Let's Encrypt Certbot

Let's Encrypt Certbot

sudo apt update
sudo apt install python3 python3-venv libaugeas0
# remove if installed from package manager, use python version
# sudo apt-get remove certbot
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
@brccabral
brccabral / 01_README.md
Created March 3, 2025 20:11
Termux Config

Termux Config

Install Termux from F-Droid.

Update and install useful packages.

pkg update
pkg upgrade
pkg install openssh
pkg install iproute2
@brccabral
brccabral / 01_Readme.md
Last active March 12, 2025 07:08
Ollama OpenWebUI Raspberry Pi

Ollama OpenWebUI Raspberry Pi

  • Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
  • Install the models
ollama run deepseek-r1:1.5b
ollama stop deepseek-r1:1.5b
@brccabral
brccabral / 01_README.md
Created December 11, 2024 00:07
SQL Custom Script

SQL Custom Script

Set the environment variable DB_PASS. It will briefly create a temp file, execute it and load the password as PSSQL variable. The file is deleted.
Then, connect to the DB and run custom.sql.

set DB_PASS=secret
sqlplus /nolog @run_custom.sql
@brccabral
brccabral / README.md
Last active April 24, 2025 21:14
CMake helper functions

CMake print all variables matching pattern

Helper function that prints all variables matching pattern

function(print_cmake_variables_matching pattern)
    get_cmake_property(_variableNames VARIABLES)
    string(TOLOWER "${pattern}" pattern_lower)
    foreach (_variableName ${_variableNames})
        string(TOLOWER "${_variableName}" variable_lower)
@brccabral
brccabral / libemail.py
Last active August 22, 2024 00:46
Python Email
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
class Email:
def __init__(self, from_: str, to: list[str], subject: str):
self.from_ = from_
self.to = to

Git Tips

Hook: post-receive

I have a repo on my machine, MyApp, I have a Bare Git Repo on a remote server production at /home/userName/MyApp.
When pushing to remote production, I need to update the code in the actual location /var/www/MyApp, but it needs root/sudo permission.

In the bare repo, add file /home/userName/MyApp/hooks/post-receive. This file is always executed after a push.
The idea is to execute this:

#!/bin/bash
@brccabral
brccabral / 01_README.md
Last active April 16, 2024 21:35
Firefly III