Skip to content

Instantly share code, notes, and snippets.

View gileno's full-sized avatar

Gileno Filho gileno

View GitHub Profile
from urllib.parse import urlparse, parse_qs
def video_id(value):
"""Video ID from youtube, vimeo and facebook links
>>> video_id('http://youtu.be/SA2iWivDJiE')
'SA2iWivDJiE'
>>> video_id('http://www.youtube.com/watch?v=_oPAwA_Udwc&feature=feedu')
'_oPAwA_Udwc'
import urllib.request
import re
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/5’
}
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(r) as response:
html = response.read().decode(‘utf-8’)
preco = re.findall(r'<input type="hidden" value="(.*)" id="taxa-comercial">', html)[0]
print(preco)
@gileno
gileno / utils.py
Created October 12, 2017 13:45
UTM to Latitude / Longitude
import math
def utm_to_latlng(easting, northing, zone=25, northernHemisphere=False):
if not northernHemisphere:
northing = 10000000 - northing
a = 6378137
e = 0.081819191
e1sq = 0.006739497
@gileno
gileno / verdade.py
Created June 10, 2017 16:46
Verdade 87
import turtle
def letra_o(pen, x, y):
pen.up()
pen.goto(x, y)
pen.down()
pen.goto(x, y + 100)
pen.goto(x + 50, y + 100)
pen.goto(x + 50, y)
@gileno
gileno / contatos.py
Created April 4, 2017 19:28
Lista de Contatos
numero = input("Quantos contatos quer cadastrar? ")
numero = int(numero)
contador = 0
emails = []
nomes = []
telefones = []
while contador < numero:
@gileno
gileno / simulador_dados.py
Created April 4, 2017 18:01
Simulador de Dados
import random
def gerar_dado():
faces = input("Digite o número de faces: ")
faces = int(faces)
print("Simulador de Dados: ", random.randint(1, faces))
contador = 0
dados = input("Quantos dados vocês quer? ")
@gileno
gileno / adinha01.py
Last active April 4, 2017 17:40
Adivinha Araripina
import random
numero = random.randint(1, 100)
contador = 0
while contador < 5:
print("Tentativa de número: ", contador)
chute = input("Digite um chute: ")
@gileno
gileno / source.list
Created April 3, 2017 14:54
Linux Educacional source.list
#deb cdrom:[LE 5.0 _le5/escola_ - Release i386 (20130421)]/ precise main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://br.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://br.archive.ubuntu.com/ubuntu/ precise main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://br.archive.ubuntu.com/ubuntu/ precise-updates main restricted
# coding=utf-8
import os
DEBUG = True
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DATABASES = {
'default': {
@gileno
gileno / views.py
Created February 19, 2016 19:58
Django Filter
def minha_view(request):
marca = request.GET.get("marca", "")
if marcar:
context["brands_list"] = Post.objects.filter(is_active=True, brands__exact='MARCA01').order_by('created_date')
else:
context["brands_list"] = Post.objects.filter(is_active=True).order_by('created_date')