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 / 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
@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
# [email protected] 2013-12/2014-09
set -o errexit -o nounset -o pipefail
## References
# Percona repositories:
@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 / 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 / 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 / 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 / WhatsApp Web Send Sad Emoji
Last active November 8, 2016 15:18 — forked from rootux/WhatsApp Web Send Random Heart
Just a simple WhatsApp Web Heart Sender
/*
Simple WhatsApp Web Spam Bot Originally written by Pablode. Modified by Gal Bracha.
Use with love <3. Do not act reckless.
====================================================================================
DISCLAIMER: I do not take any responsibility for any damage caused with this script.
WhatsApp might be able identify script users if this becomes a problem. Do only use
this if you are aware of the consquences.
====================================================================================
Usage: Copy all of this script (Ctrl+A, Ctrl+C). Add a new Bookmark. In the URL section,
write "javascript:" and paste (Ctrl+V) this script. Visit WhatsApp Web, select your
@cauethenorio
cauethenorio / clean-php.sh
Created January 29, 2016 11:10
recusively remove back door malicious code from infected php files
# Remove linha com codigo malicioso de arquivos php hackeados (sed para linux)
find . -name "*.php" -exec sed -i '1s/^<?php if(!isset(\$GLOBALS\["\\x61\\156\\x75\\156\\x61.*-1; ?>//' {} \;
# Remove linha com codigo malicioso de arquivos php hackeados (sed para mac)
find . -name "*.php" -exec sed -i '1s/^<\?php if(!isset(\$GLOBALS\["\\\x61\\\156\\\x75\\\156\\\x61.*-1; \?>//' {} \;
@cauethenorio
cauethenorio / django_admin_dynamic_lookup_mixin.py
Created January 12, 2016 03:35
A mixin to add support to related attributes like 'book_author' in django ModelAdmin list_display field
class DynamicLookupMixin(object):
'''
A mixin to add support to related attributes like
'book_author' in django ModelAdmin list_display field
creating callables on the fly
'''
def __getattr__(self, attr):
if ('__' in attr
and not attr.startswith('_')
@cauethenorio
cauethenorio / php-array-to-dict.py
Last active August 29, 2015 14:21
converter inputs de array (PHP) para um dict python
# coding: utf8
import re
from functools import reduce
def merge_dicts(*dicts):
# http://stackoverflow.com/questions/7204805/dictionaries-of-dictionaries-merge
if not reduce(lambda x, y: isinstance(y, dict) and x, dicts, True):
raise TypeError("Object in *dicts not of type dict")