Skip to content

Instantly share code, notes, and snippets.

@emersonmx
emersonmx / Dockerfile
Last active August 8, 2024 16:05
Setup a game with Pygame CE for Android
FROM python:3.11-slim
ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}/hostcwd" \
SRC_DIR="${HOME_DIR}/src" \
PATH="${HOME_DIR}/.local/bin:${PATH}"
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"
@emersonmx
emersonmx / nvim.cmd
Created July 2, 2022 19:20
Open file into nvim of wsl2
@echo off
for /f %%i in ('wsl.exe wslpath "%1"') do set filepath=%%i
wsl.exe -- zsh -l -c 'source $ASDF_DIR/asdf.sh; nvim_open %filepath% %2 %3'
@emersonmx
emersonmx / fix-cuda-lib
Created June 26, 2022 01:37
Fix /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
C:
cd \Windows\System32\lxss\lib
del libcuda.so
del libcuda.so.1
mklink libcuda.so libcuda.so.1.1
mklink libcuda.so.1 libcuda.so.1.1
@emersonmx
emersonmx / cookiecutter.md
Last active June 6, 2022 18:58
Cookiecutter

Cookiecutter

Git setup

git init example
cd example/
echo "# Example" > README.md
git add .
git commit -m "Start project"
@emersonmx
emersonmx / hello_wnck.py
Created February 11, 2021 12:18
Wnck example
#!/usr/bin/env python
import gi
gi.require_version("Wnck", "3.0")
from gi.repository import Wnck, Gdk, GLib
def on_window_destroy(screen, window):
print(screen, window)
#!/bin/bash
MANAGERS=${MANAGERS:-"arch flatpak rust cargo golang pip yarn misc"}
FORCE_INSTALL=${FORCE_INSTALL:-}
echo "Managers enabled: $MANAGERS"
function download_from_and_install_to() {
curl -L -o $2 $1 && chmod +x $2
}
@emersonmx
emersonmx / python.md
Last active August 11, 2021 12:41
Python tips

Python Tips

Poetry

Setup dev tools

poetry add -D flake8 mypy black isort pytest coverage invoke ipdb jedi rope

Dicas e Boas práticas

Esse documento busca apresentar boas práticas ou sugestões para deixar a implementação de um projeto mais agradável.

Banco de dados

Um banco de dados guarda dados e não regras de negócio.

Expressões regulares

Expressões regulares que normalmente uso.

Preço

^(\d{1,3}(\.\d{3})*,\d{2}|\d{1,2})$

Essa expressão captura o formato dos campos de preços. Ex.: 1.000.000,00

#!/bin/bash
# 1GB swap
dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576
chown root:root /swapfile1
chmod 0600 /swapfile1
mkswap /swapfile1
swapon /swapfile1
# add to /etc/fstab