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 / convert_mov2gif.sh
Created December 8, 2023 13:12
Convert .mov to .gif
#!/bin/bash
ffmpeg -ss 00:00:00.000 -i input.mov -pix_fmt rgb24 -r 10 -s 1920x1080 -t 00:00:10.000 output.gif
@welmends
welmends / Formatting problem while using tee.md
Created September 14, 2023 19:41
Solving a formatting problem while using tee

Problem

Sometimes when we use | tee output.txt to obtain the logs of a command, we obtain unformatted logs due to the colors used by libraries such as logger

Solution

In order to fix this, you can use the sed tool to remove color escape sequences from the output.txt output file. You can do this with the following command:
cat output.txt | sed "s/\x1B\[[0-9;]*[mK]//g" > formatted_output.tx
@welmends
welmends / chat.py
Created August 24, 2022 20:33
Simple example of chat using sockets implemented in Python 3
from sockets import SocketP2P
from threading import Thread
import sys
def receive(peer):
while(True):
packet = peer.receive()
print('Received: {}'.format(packet))
def chat(args):
@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))
@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 / 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 / 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 / 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 / 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 / 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