Skip to content

Instantly share code, notes, and snippets.

View Ze1598's full-sized avatar

José Fernando Costa Ze1598

  • Porto, Portugal
View GitHub Profile
@Ze1598
Ze1598 / close_sticky_add.py
Last active July 28, 2021 18:36
Arknights - scrape operator level up stats
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
# Dynamically install a Chrome web driver and instantiate it
driver = webdriver.Chrome(ChromeDriverManager().install())
# Make the driver wait 7 seconds for the page to load
driver.implicitly_wait(7)
# Go the Phantom's character page
driver.get("https://gamepress.gg/arknights/operator/phantom")
# Element to scroll to
@Ze1598
Ze1598 / idx_min_max.py
Created May 6, 2021 11:26
Find column with max/min value for each row in dataframe
import pandas as pd
# Working data
data = [
{
"Symbol": "KLAC",
"Company": "KLA Corporation",
"Sector": "Information Technology",
"Date": "2018-02-02",
"Price": 99.11979699999999,
@Ze1598
Ze1598 / transcribe_video_audio.py
Created January 28, 2021 11:01
Transcribe video audio using Azure Cognitive Services
import azure.cognitiveservices.speech as speechsdk
import time
import pickle
subscription_key = "your_key"
speech_region = "your_region"
file_name = "your_audio.wav"
# Authenticate
speech_config = speechsdk.SpeechConfig(subscription_key, speech_region)
# Set up the file as the audio source
@Ze1598
Ze1598 / cogn_serv_auth.py
Created January 28, 2021 10:58
Authenticate into Azure Cognitive Services through the Python SDK
import azure.cognitiveservices.speech as speechsdk
subscription_key = "your_key"
speech_region = "your_region"
speech_config = speechsdk.SpeechConfig(subscription_key, speech_region)
@Ze1598
Ze1598 / extract_audio.py
Last active January 28, 2021 11:25
Extract audio from video
from moviepy.editor import VideoFileClip
video = VideoFileClip("your_video.mp4")
audio = video.audio
audio.write_audiofile("audio_only.wav")
@Ze1598
Ze1598 / prog_languages.py
Last active January 24, 2021 21:19
Python Data Analysis Part 4: Programming Languages
import pandas as pd
from os import getcwd, path
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
path_to_data = path.join(getcwd(), "data", "survey_results_public.csv")
data = pd.read_csv(path_to_data)
data = data[["LanguageWorkedWith"]]
@Ze1598
Ze1598 / education.py
Last active January 24, 2021 18:59
Python Data Analysis Part 3: Education of Respondents
import pandas as pd
from os import getcwd, path
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
path_to_data = path.join(getcwd(), "data", "survey_results_public.csv")
data = pd.read_csv(path_to_data)
data = data[["EdLevel"]]
@Ze1598
Ze1598 / compensation.py
Last active January 24, 2021 17:39
Python Data Analysis Part 2: Annual Compensation
import pandas as pd
from os import getcwd, path
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
path_to_data = path.join(getcwd(), "data", "survey_results_public.csv")
data = pd.read_csv(path_to_data)
data = data[["ConvertedComp"]]
@Ze1598
Ze1598 / age.py
Created January 24, 2021 15:26
Python Data Analysis Part 1: Age of Respondents
import pandas as pd
from os import getcwd, path
import plotly.express as px
import plotly.offline as pyo
pyo.init_notebook_mode()
path_to_data = path.join(getcwd(), "data", "survey_results_public.csv")
data = pd.read_csv(path_to_data)
data = data[["Age"]]
@Ze1598
Ze1598 / custom_mask.py
Created December 6, 2020 16:54
Create a custom shape mask with Python & Pillow
from PIL import Image
# Create a blank grey image
wip_img = Image.new("RGBA", (550, 450), "#f2f2f2")
# Load the santa hat
santa_hat = Image.open("santa_hat.png")
# At first this is just a black rectangle of the same size as the hat
shadow = Image.new("RGBA", santa_hat.size, color="black")
# Coordinates at which to draw the hat and shadow