Skip to content

Instantly share code, notes, and snippets.

View iuriguilherme's full-sized avatar

Iuri Guilherme iuriguilherme

View GitHub Profile

Keybase proof

I hereby claim:

  • I am desci on github.
  • I am iuriguilherme (https://keybase.io/iuriguilherme) on keybase.
  • I have a public key whose fingerprint is BE63 A69B 71FA 985A 2384 24DD E23E 7EC0 76CB DC46

To claim this, I am signing this object:

@iuriguilherme
iuriguilherme / app.py
Last active January 17, 2024 16:40
FastAPI and Quart together
#!/usr/bin/env python
## FastAPI is a great tool for... fast APIs... but there are better
## solutions for web apps such as Django, Web2Py and Flask. Talking
## about Flask, there is the Quart project which aims to be the full
## async version of Flask that you can use today.
##
## I have read the following documentation to reach the result of this
## gist:
##
## * <https://fastapi.tiangolo.com/tutorial/middleware/>
@iuriguilherme
iuriguilherme / keybase.md
Last active December 22, 2020 23:45
Keybase proof

Keybase proof

I hereby claim:

  • I am iuriguilherme on github.
  • I am iuriguilherme (https://keybase.io/iuriguilherme) on keybase.
  • I have a public key ASAw1O4LqUQTcrv9RiIx5k5YhyzhlY0kp2-ay5M85dZ7Owo

To claim this, I am signing this object:

@iuriguilherme
iuriguilherme / backup.sh
Created January 5, 2021 21:00
Backup folders using tar
#!/bin/bash
if [ ! -z $2 ]
then
SOURCE_PATH="$(dirname $1)"
SOURCE_DIR="$(basename $1)"
DEST_PATH="$(dirname $2)"
DEST_FILE="$(basename $2).tar.xz"
XZ_OPT=-e9 ionice -c 2 -n 7 nice -n 19 tar -cJhvpnS -C "${SOURCE_PATH}" \
"${SOURCE_DIR}" -f "${DEST_PATH}/${DEST_FILE}"
@iuriguilherme
iuriguilherme / move.sh
Created January 5, 2021 21:06
Move files safely across filesystems
#!/bin/bash
## This script will move safely all files and folders in the arguments list to the last argument. It uses rsync so it can be sent to remote servers.
rsync -avvhSP --remove-source-files "$@"
for DIR in "${@}"
do
## like `rmdir` but recursively for every argument (only removes empty directories)
find "${DIR}" -type d -empty -delete
done
@iuriguilherme
iuriguilherme / git-dump.py
Created February 20, 2021 00:19
Dump all git repositories
## Dump all git repositories from selected users. In this example notabug.org and github.com are used
## Change the dictionary "repos" to your own data
## Needs https://gitpython.readthedocs.io/
## pip install GitPython
import git, logging, os
from git import Git, Repo, Remote, RemoteProgress
repos = {
'notabug': {
#!/bin/bash
## Backup incremental do banco de dados do wordpress
## Precisa de mysqldump e rdiff-backup
## Pronto pra rodar com crontab
## Mantém arquivos temporários com alta compressão em /tmp/backups
## Usa arquivo de configuração do wordpress para pegar os dados do mysql opcionalmente
NOW="$(date +%s)"
SITE="wordpress"
@iuriguilherme
iuriguilherme / filesystem_watch.py
Created March 22, 2022 14:51
Monitor files being accessed recursively
#!/bin/env python
import datetime, glob, os, sys
try:
## Default to pwd
root = './'
## For python files in the current folder (and subfolders recursively) this would be `filesystem_watch.py './' '/*.py'`
pattern = ''
@iuriguilherme
iuriguilherme / app.py
Created March 27, 2022 05:26
Web form with telegram bot
## This code makes a web form to send messages to telegram users
## pip install aiogram quart flask-wtf
## QUART_APP=app:app quart run
import logging
logger = logging.getLogger(__name__)
import asyncio, secrets
from aiogram import (
Bot,
@iuriguilherme
iuriguilherme / index.html
Last active June 9, 2022 02:11
Pyscript showcase
<!DOCTYPE html>
<html lang = "en">
<head>
<!--
This is mandatory for latin characters, because there's just no standard
in web browsers, and probably there'll never be
-->
<meta charset = "utf-8" />
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>