Skip to content

Instantly share code, notes, and snippets.

View welmends's full-sized avatar
🎯
Focusing

Wellington Mendes welmends

🎯
Focusing
  • Indigo Ag
  • Fortaleza, CE
View GitHub Profile
@welmends
welmends / ws_client.py
Created April 16, 2020 23:35
WebSocket in Python - Example
# WS client example
import asyncio
import websockets
import time
async def receive():
uri = "ws://localhost:9999"
async with websockets.connect(uri) as websocket:
@welmends
welmends / .bash_profile
Last active May 18, 2022 20:55
Customised MacOS .bash_profile (activate: chsh -s /bin/bash)
# * Keyboad autocomplete *
set show-all-if-ambiguous on
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
# * Customizing PS1 - Add Battery Percentage *
# get_battery() {
# acpi | egrep -o '([0-9]+)%'
# }
@welmends
welmends / calc_invest.py
Last active August 24, 2022 20:36
Investment simulation on FIIs over years
# Investment simulation on FIIs over years
import math
import matplotlib.pyplot as plt
import locale
locale.setlocale(locale.LC_ALL, '')
# FII
price = 10
dividends = 0.08
@welmends
welmends / clicking.sh
Last active November 24, 2022 22:52
Periodically clicking with xdotool/cliclick
#!/bin/bash
# xdotool
#xdotool click --repeat 10000 --delay 10000 1
# cliclick
while true
do
cliclick c:0,0
sleep 10
@welmends
welmends / parallels_bypass.sh
Created November 30, 2021 11:44
How to bypass parallels by using free trial forever
#!/bin/bash
networksetup -setairportpower en0 off
sudo -S date 1015000021 # set available date MMddHHmmYY
read -p "Press any key to continue... " -n1 -s
networksetup -setairportpower en0 on
echo ""
@welmends
welmends / arch.tf
Last active August 24, 2022 20:35
Terraform Simpel Project with AWS - Apache Server
# Terraform v1.2.0
#
# Terraform Simple Project with AWS - Apache Server
#
# $ terraform init
# $ terraform plan
# $ terraform apply --auto-approve
# $ terraform output
# $ terraform refresh
# $ terraform destroy -target aws_route_table_association.a --auto-approve
@welmends
welmends / mkproj.sh
Last active August 20, 2022 18:50
Script used to create django project integrated with javascript/react frontend
#!/bin/bash
# Script used to create django project integrated with javascript/react frontend
# Execute these command to run:
# $ sh mkproj.sh
# $ python manage.py runserver
# $ yarn run dev
# set project name and frontend package name
PROJ_NAME='app'
@welmends
welmends / 3-way-signature.py
Last active August 24, 2022 20:35
Find Signature in Image (3 one above the other)
import cv2
import numpy as np
from collections import Counter
import matplotlib.pyplot as plt
def check_countour(shape, contour):
# Get array X:
arr = list(dict(sorted(Counter(contour[:, 0, 0]).items())).values()) # sort by key and get values (histogram)
arr = arr[int(len(arr)*0.1):len(arr)-int(len(arr)*0.1)] # crop 10% of the begin and end of array
# Rect conditions:
@welmends
welmends / py-pdf-swap-text.py
Last active August 24, 2022 20:35
Tool to swap text from pdf files using Python
'''
config.yml
path: /path/to/folder
text1:
old: "xxxxx"
new: "yyyyy"
'''
'''
@welmends
welmends / signature-background-removal.py
Created August 24, 2022 20:24
Signature Background Removal with OpenCV
import cv2 as cv
import numpy as np
class SignatureBackgroundRemoval:
def process_signature(self, img):
img = cv.GaussianBlur(img,(5,5),0)
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
ret, img = cv.threshold(img,0,255,cv.THRESH_BINARY+cv.THRESH_OTSU)
alpha = np.ones(img.shape, dtype=img.dtype)*255
out = cv.merge((img, img, img, alpha))