Skip to content

Instantly share code, notes, and snippets.

View idcesares's full-sized avatar
:octocat:
Keep on hacking!

Isaac D'Césares idcesares

:octocat:
Keep on hacking!
View GitHub Profile
@idcesares
idcesares / tts.py
Created April 26, 2020 17:40
Usando a biblioteca pyttsx3 para text-to-speech no Python
# Instalar o pyttsx3 com o comando abaixo:
# pip install pyttsx3
import pyttsx3
# Iniciando a biblioteca na variável engine
engine = pyttsx3.init()
# Função pronta para uso
def speak(speech):
@idcesares
idcesares / join_csv_powershell.ps1
Last active April 23, 2021 19:53
Combine multiple CSV files into one using Powershell
Get-ChildItem -Filter *.csv | Select-Object -ExpandProperty FullName | Import-Csv | Export-Csv .\combinedcsvs.csv -NoTypeInformation -Encoding UTF8 -Append
@idcesares
idcesares / consume_public_api.py
Last active April 23, 2021 19:51
How to easily consume an Public API in Python and convert the result into a Pandas Dataframe
# Basic libraries
import requests
import pandas as pd
import json
# Define API URL
url = 'API_link'
# Consume API
response = requests.get(url).json()
@idcesares
idcesares / sentiment_analysis_textblob.py
Created April 26, 2021 22:51
Simple Sentiment Analysis using TextBlob Python Library. Only available in english.
from textblob import TextBlob
def sentiment(text):
base_text = TextBlob(text)
sentiment_score = base_text.sentiment.polarity
if sentiment_score < 0:
return 'Negative'
elif sentiment_score == 0:
return 'Neutral'
return 'Positive'
@idcesares
idcesares / day_of_year.py
Created May 5, 2021 22:31
Shows how many days have passed since the beginning of the year
from datetime import datetime
day_of_year = datetime.now().timetuple().tm_yday
print(f"What's the Current Day Number? {day_of_year} days have passed since the beginning of the year.")
@idcesares
idcesares / tensorflow_simple_neural_network.py
Created May 29, 2021 15:06
Simple Neural Network using Tensorflow
# Imports
import tensorflow as tf
import numpy as np
from tensorflow import keras
# Define and compile the Neural Network (NN)
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) # Only 1 neuron
# Compile the NN
model.compile(optimizer='sgd', loss='mean_squared_error')
@idcesares
idcesares / cidades_ibge.py
Created July 5, 2021 15:15
Exportar cidades brasileiras da api do IBGE para csv
import pandas as pd
import requests
response = requests.get('https://servicodados.ibge.gov.br/api/v1/localidades/municipios')
df = pd.read_json(response.text)
cidades = df['nome']
cidades.to_csv("cidades.csv", index=False)
@idcesares
idcesares / pdf-to-image.py
Created August 11, 2021 16:26
Convert a PDF file to image using poppler and pdf2image
# Install poppler using chocolatey
# choco install poppler
# Imports
import pdf2image
import os
# Function to convert PDF to image (JPEG)
def to_image(path):
images = convert_from_path(path)
for i in range(len(images)):
@idcesares
idcesares / whats_my_ip.py
Created January 6, 2022 17:58
fund out what's your IP Address using Python and ipinfo.io
from urllib.request import urlopen
import json
import pprint
url = 'https://ipinfo.io/json'
result = urlopen(url)
data = json.load(result)
pprint.pprint(data)
@idcesares
idcesares / download_pdf_google_drive.py
Created July 4, 2023 20:45
Script to download multiple files on Google Drive with Colab and save
# Mount Google Drive
from google.colab import drive
drive.mount('/gdrive')
# Script to download multiple files on Google Drive with Colab
import requests
import os
def download_file_from_google_drive(id, destination):
URL = "https://docs.google.com/uc?export=download"