Skip to content

Instantly share code, notes, and snippets.

View luizomf's full-sized avatar
🙃
Segue programando =)

Luiz Otávio luizomf

🙃
Segue programando =)
View GitHub Profile
@luizomf
luizomf / ambiente-dev-ubuntu-curso-python.sh
Created October 31, 2022 01:23
Instalação ambiente dev Ubuntu 22 do curso de Python
#!/bin/bash
# Executar comandos a seguir para atualizar os pacotes
sudo apt update -y
sudo apt upgrade -y
# Só o Python
sudo apt install python3.10-full python3.10-dev -y
# Instalar pacotes a seguir
@luizomf
luizomf / settings.json
Created October 24, 2022 13:01
Configuração inicial do VS Code
{
"window.zoomLevel": 2,
"workbench.startupEditor": "none",
"explorer.compactFolders": false,
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 18,
"workbench.colorTheme": "OM Theme (Default Dracula Italic)",
"code-runner.executorMap": {
"python": "clear ; python -u",
},
@luizomf
luizomf / commands.sh
Last active April 30, 2024 17:39
Instalação Python 3.10 Ubuntu 22.04
sudo apt update -y
sudo apt upgrade -y
sudo apt install git curl build-essential -y
sudo apt install gcc make default-libmysqlclient-dev libssl-dev -y
sudo apt install python3.10-full python3.10-dev -y
@luizomf
luizomf / structural_pattern_matching.py
Created September 4, 2022 16:12
Structural Pattern Matching - Python Examples
from dataclasses import dataclass
def execute_command(command):
if command == 'ls':
print('$ listing files')
elif command == 'cd':
print('$ changing directory')
else:
print('$ command not implemented')
@luizomf
luizomf / settings.json
Last active May 1, 2024 17:46
VS Code Python and Code Runner Settings for Windows
{
"window.zoomLevel": 5,
"editor.formatOnSave": true,
"code-runner.executorMap": {
"python": "clear ; .\\venv\\Scripts\\python.exe"
},
"code-runner.runInTerminal": true,
"code-runner.clearPreviousOutput": true,
// Python
"[python]": {
@luizomf
luizomf / upscale_1080p_to_4k_using_ffmpeg.md
Last active May 5, 2024 14:40
Upscale 1080p to 4k using ffmpeg

Upscale 1080p to 4k using ffmpeg

Just use the command below:

ffmpeg -i INPUT_FILE \
  -vf scale=3840x2160:flags=lanczos \
  -c:v libx264 \
  -crf 13 \
 -c:a aac -b:a 512k \
@luizomf
luizomf / point.py
Created August 9, 2022 10:59
Implementação dos métodos mágicos para matemática em Python.
class Point:
"""
>>> p1 = Point(8, 6)
>>> p2 = Point(2, 3)
>>> p1 + p2
Point(10, 9)
>>> p1 - p2
Point(6, 3)
>>> p1 / p2
Point(4.0, 2.0)
@luizomf
luizomf / simple_metaclass.py
Last active August 7, 2022 07:54
Metaclass example in Python.
class Meta(type):
def __new__(mcs, name, bases, namespace):
namespace['adicionei'] = 'um valor'
cls = super().__new__(mcs, name, bases, namespace)
for base in bases:
for key, value in base.__dict__.items():
if getattr(value, '__is_abstract__', False):
if key not in cls.__dict__.keys():
@luizomf
luizomf / README.md
Created July 25, 2022 11:23
Python Type Annotations Examples

Type annotations em Python

Observação: estou usando o Python 3.10.

O que é Type Annotation? São partes do código usadas para indicar tipos de dados em locais como: variáveis, parâmetros e retornos de funções e métodos. Em Python isso é usado para documentação e ajuda com auto completar dos editores, visto que a linguagem não impede a execução do código mesmo se as anotações estiverem incorretas.

@luizomf
luizomf / python-iterable-iterator.py
Last active July 14, 2022 14:25
python-iterable-iterator.py
class MinhaLista:
def __init__(self):
self.__data = {}
self.__index = 0
self.__next_index = 0
def add(self, *values):
for value in values:
self.__data[self.__index] = value
self.__index += 1