Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View NaelsonDouglas's full-sized avatar
🤔

Naelson Douglas C. Oliveira NaelsonDouglas

🤔
View GitHub Profile
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
options = webdriver.FirefoxOptions()
options.set_capability('browserName', 'firefox')
options.set_capability('browserVersion', '117.0') #
#options.set_capability('selenoid:options', {'enableVideo': True}) # Faz com que a execução seja gravada em ~/.aerokube/selenoid/video
options.set_capability('selenoid:options', {'enableVNC': True}) # Permite ver o webdriver em tempo real pela web-ui
@NaelsonDouglas
NaelsonDouglas / selenium.py
Created June 17, 2023 06:46
Here is a boilerplate of a Python Selenium web scrapper able to download the HTML source code of any page.
import ssl
from time import sleep
from selenium import webdriver
from selenium.webdriver import firefox
ssl._create_default_https_context = ssl._create_unverified_context
class SeleniumConnector():
driver = None
# i3 config file (v4)
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $mod Mod4
# set default desktop layout (default is tiling)
# workspace_layout tabbed <stacking|tabbed>
# Configure border style <normal|1pixel|pixel xx|none|pixel>
format values
single ['true']
single ['1']
single ['500']
single ['4']
single ['18']
single ['true']
ranged ['(30,)']
ranged ['(87,)']
ranged ['(64,)']
@NaelsonDouglas
NaelsonDouglas / bulk_string_replace.py
Last active April 10, 2022 07:55
This function replaces severall patterns in a single iteration. Just pass the text to be replaced and the mappings dictionary to it. Longer words are replaced first.
import re
def bulk_replace(text:str, mappings:str) -> str:
regex = re.compile('|'.join(mappings.keys()))
return re.sub(regex, lambda x: mappings[x.group()], text)
if __name__ == '__main__':
mappings = {
'quick':'slow',
'fox':'dog',
pair open_time high gain
DOGEBRL 2021-10-22T00:30:00Z 1.391 0.0
DOGEBRL 2021-10-22T01:00:00Z 1.399 0.01
DOGEBRL 2021-10-22T01:30:00Z 1.397 -0.0
DOGEBRL 2021-10-22T02:00:00Z 1.397 0.0
DOGEBRL 2021-10-22T02:30:00Z 1.395 -0.0
DOGEBRL 2021-10-22T03:00:00Z 1.393 -0.0
DOGEBRL 2021-10-22T03:30:00Z 1.395 0.0
DOGEBRL 2021-10-22T04:00:00Z 1.394 -0.0
DOGEBRL 2021-10-22T04:30:00Z 1.4 0.0
@NaelsonDouglas
NaelsonDouglas / get_current_commit.py
Created July 1, 2021 19:04
Function to programmatically get the current commit of a git repository via Python.
from pathlib import Path
def get_commit(repo_path):
git_folder = Path(repo_path,'.git')
head_name = Path(git_folder, 'HEAD').read_text().split('\n')[0].split(' ')[-1]
head_ref = Path(git_folder,head_name)
commit = head_ref.read_text().replace('\n','')
return commit
if __name__ == '__main__':
repo categ flag
0 donnemartin/system-design-primer education
1 TheAlgorithms/Python education
2 jackfrued/Python-100-Days education
3 ytdl-org/youtube-dl web
4 nvbn/thefuck shell
5 django/django development
6 keras-team/keras ML
7 httpie/httpie development
8 ansible/ansible development

Smells comuns em Python

usar range(len(a)) ao invés de enumerate
Com smell Sem smell
0.0
0.847
0.901
0.113
0.781
0.944
0.225
0.705
0.976
0.333