Skip to content

Instantly share code, notes, and snippets.

View fcschmidt's full-sized avatar
🌐
working to generate impact!

Fábio Schmidt fcschmidt

🌐
working to generate impact!
View GitHub Profile
@fcschmidt
fcschmidt / matrix_sum-col.py
Created June 12, 2017 15:15
Question asked in the facebook python community
#!/usr/bin/env python3
"""
Uma matrix é formada por vetores
Ex:
m = [[1, 1234, 567, 890, 10],
[1, 1234, 567, 890, 10],
[1, 1234, 567, 890, 10]]
Ou, seja:
matrix 3x5 == 3 linha, 5 coluna
@fcschmidt
fcschmidt / input_file.txt
Last active July 3, 2017 00:32
Exemplo simples de como fazer operações com as diagonais (principal e secundária) de uma matrix.
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
@fcschmidt
fcschmidt / matrix_sun-diagonal.py
Last active November 24, 2018 19:01
Soma valores das duas diagonais principais.
#!/usr/bin/env python3
def diagonal_principal(m):
ac = 0
m1 = []
while ac <= len(m) - 1:
vet = m[ac]
vet[ac] += 1
ac += 1
@fcschmidt
fcschmidt / iris.txt
Last active November 13, 2017 23:32
Convert Iris Dataset text in CSV
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3.0 1.4 0.2 Iris-setosa
4.7 3.2 1.3 0.2 Iris-setosa
4.6 3.1 1.5 0.2 Iris-setosa
5.0 3.6 1.4 0.2 Iris-setosa
5.4 3.9 1.7 0.4 Iris-setosa
4.6 3.4 1.4 0.3 Iris-setosa
5.0 3.4 1.5 0.2 Iris-setosa
4.4 2.9 1.4 0.2 Iris-setosa
4.9 3.1 1.5 0.1 Iris-setosa
@fcschmidt
fcschmidt / dados_normalizados
Created December 6, 2017 14:07
Método utilizado para normalizar uma base de dados, afim de evitar discrepância entre valores dos diferentes atributos.
[0.4, 1.0, 1.0, 0.7, 0.875, 0.7]
[0.1, 0.16666666666666666, 0.16666666666666666, 1.0, 0.125, 0.1]
[1.0, 0.8333333333333334, 0.8333333333333334, 0.6, 0.875, 1.0]
[0.5, 0.16666666666666666, 0.3333333333333333, 0.4, 0.25, 0.1]
[0.5, 0.5, 0.3333333333333333, 0.5, 1.0, 0.1]
[0.3, 0.16666666666666666, 0.16666666666666666, 0.8, 0.625, 0.8]
[0.3, 0.5, 0.6666666666666666, 0.4, 0.5, 0.7]
@fcschmidt
fcschmidt / query.py
Created January 19, 2018 00:56
ValueError: invalid literal for int() with base 10: '5a612b07393e035d5b85cd69ab8618868eb5c129'
for instance in self.session.query(SessionLogModel) \
.filter(or_(SessionLogModel.session_uid.isnot(None) == get_id,
SessionLogModel.id.isnot(None) == int(get_id))):
self.resp = json.dumps(instance.to_json(), default=default)
@fcschmidt
fcschmidt / logs
Created June 6, 2018 16:20
Heroku logs - webdriver error
2018-06-06T16:15:20.723444+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2018-06-06T16:15:20.723446+00:00 app[web.1]:
2018-06-06T16:15:20.723447+00:00 app[web.1]: Traceback (most recent call last):
2018-06-06T16:15:20.723448+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
2018-06-06T16:15:20.723449+00:00 app[web.1]: response = self.full_dispatch_request()
2018-06-06T16:15:20.723453+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
2018-06-06T16:15:20.723454+00:00 app[web.1]: rv = self.handle_user_exception(e)
2018-06-06T16:15:20.723455+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
2018-06-06T16:15:20.723456+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2018-06-06T16:15:20.723457+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver"
chrome_bin = os.environ.get('GOOGLE_CHROME_BIN', "chromedriver")
options = webdriver.ChromeOptions()
options.binary_location = chrome_bin
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument('headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=options)
import os
from selenium import webdriver
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver" # Heroku instance path
GOOGLE_CHROME_BIN_DEV = "/usr/bin/google-chrome"
CHROMEDRIVER_PATH_DEV = "/home/fcschmidt/.chromedriver/bin/chromedriver"
class GoogleChromeSelenium:
import binascii
binascii.hexlify(os.urandom(24))