Skip to content

Instantly share code, notes, and snippets.

View cauethenorio's full-sized avatar
🎯
Focusing

Cauê Thenório cauethenorio

🎯
Focusing
View GitHub Profile
@cauethenorio
cauethenorio / utils.ts
Created January 15, 2019 00:40
Simple Typescript debounce and throttle
export function debounce(func: (args: IArguments) => any, wait: number, immediate: boolean) {
let timeout: number | undefined;
return function executedFunction(this: any) {
const context: any = this;
const args = arguments;
const later = () => {
timeout = undefined;
if (!immediate) {
@cauethenorio
cauethenorio / python-cli.py
Created February 6, 2019 01:30
Python script template with debugger
#!/usr/bin/env python
# https://news.ycombinator.com/item?id=19078825
import traceback
import pdb
import sys
def main():
# some WIP code that maybe raises an exception
@cauethenorio
cauethenorio / install-automount.sh
Last active June 21, 2019 03:03
Automount USB for SystemD OS
#! /bin/bash
# Source
# https://www.raspberrypi.org/forums/viewtopic.php?t=192291
# https://raspberrypi.stackexchange.com/questions/66169/auto-mount-usb-stick-on-plug-in-without-uuid
set -e
if [[ $EUID -ne 0 ]]; then
@cauethenorio
cauethenorio / create-docker-user.sh
Last active March 11, 2020 03:30
Script to create system users to run docker apps
#!/usr/bin/env bash
set -e
# create system users to be run docker apps
# put this file in your /sbin dir and chmod +x it
# this script:
# - create users without pass
# - and them to the docker group
@cauethenorio
cauethenorio / mariadb-replication.sh
Created June 25, 2020 21:37
Script to setup/resync two MariaDB nodes (main/seconday)
#!/bin/bash
# MariaDB/MySQL Replication Configuration Script for Ubuntu/Debian
# cauelt@gmail.com 2013-12/2014-09
set -o errexit -o nounset -o pipefail
## References
# Percona repositories:
@cauethenorio
cauethenorio / standalone_html.py
Created August 17, 2021 17:27 — forked from pansapiens/standalone_html.py
Convert HTML to a self contained file with inline Base64 encoded PNG images
#!/usr/bin/env python
# A simple script to suck up HTML, convert any images to inline Base64
# encoded format and write out the converted file.
#
# Usage: python standalone_html.py <input_file.html> <output_file.html>
#
# TODO: Consider MHTML format: https://en.wikipedia.org/wiki/MHTML
import os
from bs4 import BeautifulSoup