Skip to content

Instantly share code, notes, and snippets.

View williamcanin's full-sized avatar
🐍
Simple is better than complex.

William C. Canin williamcanin

🐍
Simple is better than complex.
View GitHub Profile
@williamcanin
williamcanin / example_progressbar_tkinter.py
Last active October 1, 2022 04:53
Python Tkinter Progressbar Thread - List file from a given directory, print and show the process in a progressbar.
"""
Author: William C. Canin
Description: List file from a given directory, print and show the process in a Progressbar. Using Thread.
"""
from concurrent.futures import ThreadPoolExecutor
from tkinter import Tk, Button, W, messagebox
from tkinter.ttk import Progressbar
from threading import Thread
from os import walk
>>> loadkeys br-abnt2
>>> timedatectl set-timezone America/Sao_Paulo
>>> hwclock --systohc
>>> cfdisk /dev/sda
##### IMPORTANT #####
# Use partition GPT #
#####################
/boot - EFI System - 500M (sda1)
@williamcanin
williamcanin / convert_dv.py
Last active November 25, 2021 09:18
Converting video formats to MOV. Compatible with Davinci Resolve.
#!/usr/bin/env python3
import argparse
from os import listdir
from os.path import isdir, join, splitext
from pathlib import Path
from subprocess import call
from typing import Union
@williamcanin
williamcanin / file_main_in_python_package.md
Created May 9, 2020 13:56
A essência do arquivo __main__.py em estruturas de pacote Python.

Uma das formas de entender o arquivo __main__.py em pacote Python é fazendo isso de maneira prática, pra isso, vamos a um exemplo simples. Crie a estrutura:

mypackage
└── __main__.py

Dentro do dander main, coloque um print qualquer:

print('Oi')
@williamcanin
williamcanin / jankenpon_en.py
Created December 3, 2019 00:05
Python script to play Rock-Paper-Scissors
#!/usr/bin/env python
# by William C. Canin <https://williamcanin.github.io>
# Date: 02 dec, 2019
# Version: 1.0.1
# Description: Game Rock-Paper-Scissors.
from random import choice, random
from textwrap import dedent
@williamcanin
williamcanin / jankenpon_ptbr.py
Last active December 3, 2019 00:06
Python script para jogar Pedra Papel Tesoura (Rock-Paper-Scissors)
#!/usr/bin/env python
# por William C. Canin <https://williamcanin.github.io>
# Date: 02 dez, 2019
# Versão: 1.0.1
# Descrição: Jogo Pedra Papel Tesoura.
from random import choice, random
from textwrap import dedent
@williamcanin
williamcanin / rundev.sh
Last active February 4, 2020 17:08
Shell file for managing Python packages.
#!/usr/bin/env bash
# by: William C. Canin
# Version: 1.0.2
# Type: shellscript
# Executor: bash
# Description:
# This file is responsible for:
# * Create/Compile the Python package
# * Clear compilation/creation
# * Install the Python package
@williamcanin
williamcanin / VSCodeExtension.py
Created February 16, 2019 01:58 — forked from harry-cpp/VSCodeExtension.py
VSCode extension for Nautilus
# VSCode Nautilus Extension
#
# Place me in ~/.local/share/nautilus-python/extensions/,
# ensure you have python-nautilus package, restrart Nautilus, and enjoy :)
#
# Quick install command:
# mkdir -p ~/.local/share/nautilus-python/extensions && cp -f VSCodeExtension.py ~/.local/share/nautilus-python/extensions/VSCodeExtension.py && nautilus -q
#
# Quick download + install command:
# wget https://gist.githubusercontent.com/cra0zy/f8ec780e16201f81ccd5234856546414/raw/6e53c15ea4b18de077587e781dc95dc7f0582cc3/VSCodeExtension.py && mkdir -p ~/.local/share/nautilus-python/extensions && cp -f VSCodeExtension.py ~/.local/share/nautilus-python/extensions/VSCodeExtension.py && rm VSCodeExtension.py && nautilus -q
@williamcanin
williamcanin / create-ruby-gem.md
Created July 2, 2016 01:59 — forked from kelvinst/create-ruby-gem.md
Como criar uma gem ruby?

Como criar uma gem ruby?

Escolhi tratar sobre esse assunto hoje simplesmente porque foi uma das primeiras coisas que me perguntei "como eu faço isso?" no mundo ruby. Acredito que muita gente se pergunte a mesma coisa e espero que eu possa ajudar em algo para elas. 😀

O que é uma gem?

Bem, se você é um programador java, você chama sua gem de jar, se você é um programador C#, você chama de dll. Resumindo, é uma lib, uma biblioteca contendo códigos que você pode reaproveitar importando em outros projetos.

E usar gems no ruby é muito fácil, se você já deu uma brincada com rails por exemplo, é só você adicionar o código gem 'nome_da_gem' no arquivo Gemfile que está no root, depois executar o comando bundle install para baixar sua gem do repositório e pronto, só sair usando a biblioteca!

@williamcanin
williamcanin / catch_ip
Last active November 22, 2015 21:58
IP capture and public IP. (Script Shell) Linux terminal
#!/bin/bash
#
# Description: Simple script (shell) for view your IP and IP Public.
# By: William Canin <williamcanin.com> {william.costa.canin@gmail.com}
#
# Package dependencies:
# > net-tools
# > lynx
# Network interface card. Example: eth0, eth1, enp19s0, wlan0, wlan1, wlp7s0,... etc.