Skip to content

Instantly share code, notes, and snippets.

View dublado's full-sized avatar
📭
Send me a Telegram

Thiago Machado dublado

📭
Send me a Telegram
View GitHub Profile
@dublado
dublado / python-timeit-measure.sh
Created October 11, 2023 00:26
timeit module
# The "timeit" module lets you measure the execution
# time of small bits of Python code
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))',
number=10000)
0.3412662749997253
>>> timeit.timeit('"-".join([str(n) for n in range(100)])',
@dublado
dublado / python-named-tuple.sh
Last active October 11, 2023 00:26
python named tuple as shorter class
# Why Python is Great: Namedtuples
# Using namedtuple is way shorter than
# defining a class manually:
>>> from collections import namedtuple
>>> Car = namedtuple('Car', 'color mileage')
# Our new "Car" class works as expected:
>>> my_car = Car('red', 3812.4)
>>> my_car.color
'red'
@dublado
dublado / special_variable.py
Created October 10, 2023 19:23
What Does `if __name__ == "__main__"` Mean in Python?
'''
In Python, the special variable `__name__` is used to determine if a Python script is being run as the main program
or if it is being imported as a module into another script.
'''
### Example
Consider the following Python script named `my_module.py`:
```python
# DataFlair background removal
# import necessary packages
import os
import cv2
import numpy as np
import mediapipe as mp
# initialize mediapipe
@dublado
dublado / python-logging-color.py
Created September 4, 2023 19:01
logging colors
import logging
FMT= "[{levelname: ^9}] {name}: {message}"
FORMATS = {
logging.DEBUG: FMT,
logging.INFO: f"\33[36m{ FMT}\33[0m",
logging.WARNING: f"\33[33m{ FMT}\33[0m",
logging.ERROR: f"\33[31m{ FMT}\33[0m",
logging.CRITICAL: f"\33[1m\33[31m{FMT}\33[0m",
}
@dublado
dublado / cover-en.md
Created August 24, 2023 13:06
Sugestão de carta de apresentação

Dear 'Hiring Manager' at 'Google',

I am writing to apply for the 'Arquiteto de Software' position, as advertised. With over '5' years of experience as a Software Engineer, I have honed my skills in a stack including PHP and Go. During my time at 'Company A', I served as a Software Architect, achieving 'result A' that led to significant improvements. Likewise, my role at 'Company B' allowed me to implement solutions that resulted in 'result B'.

My background in web knowledge and extensive experience with AWS uniquely qualify me for this role. I look forward to the opportunity to contribute to 'Google', employing my skills and expertise. I am enthusiastic about the chance to bring my unique talents to a forward-thinking company like yours.

Please find my resume attached for further details about my experience and qualifications. I look forward to the opportunity to discuss how I can contribute to the success of your team.

Thank you for considering my application.

@dublado
dublado / mermaid-diagram-pip.md
Created August 24, 2023 13:02
Mermaid diagram sequencia pip

#https://mermaid.live/

sequenceDiagram participant Usuário participant Ambiente Virtual participant Terminal participant Wheel participant Repositório

Usuário->>Ambiente Virtual: Ativar ambiente virtual

# original code in: https://www.youtube.com/watch?v=KSQ4KxCtsf8
# thanks @parafoxia
import logging
FMT= "[{levelname: ^9}] {name}: {message}"
FORMATS = {
logging.DEBUG: FMT,
logging.INFO: f"\33[36m{ FMT}\33[0m",
logging.WARNING: f"\33[33m{ FMT}\33[0m",
@dublado
dublado / count-pixel.py
Created July 23, 2023 18:39
count pixel
import imageio
def count_pixels(filename):
image = imageio.imread(filename)
return image.shape[0] * image.shape[1]
number_of_pixels = count_pixels("pixel.gif")
print(number_of_pixels)
@dublado
dublado / brew-dnsmasq.md
Created July 18, 2023 02:54 — forked from davebarnwell/brew-dnsmasq.md
install dnsmasq with brew

Install dnsmasq and configure for *.dev.local domains

$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf

Reload configuration and clear cache

# Copy the daemon configuration file into place.
$ sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/

$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist