Skip to content

Instantly share code, notes, and snippets.

View marciomazza's full-sized avatar

Marcio Mazza marciomazza

View GitHub Profile
@marciomazza
marciomazza / stripbuildoutcache.py
Created July 9, 2012 01:46
Strips the buildout cache from older egg versions
#!/usr/bin/python
import os
from itertools import groupby
from shutil import rmtree
from pkg_resources import parse_version
def main():
"""Strips the buildout cache from older egg versions
@marciomazza
marciomazza / propostas_pybr12.py
Last active July 20, 2016 22:40
Scrapping das propostas no site da pybr 12
#!/usr/bin/env python
# requirements:
#
# beautifulsoup4
# requests
# unidecode
from itertools import groupby
a == 1 or a == 2 or a == 3 # a == 1 or a == 2 or a == 3 or ... or a == N
a in [1, 2, 3] # a in [1, 2, 3, ..., N]
a if a else b
a or b
# ... list building with appends => list comprehensions
@marciomazza
marciomazza / gist:7158411
Last active January 7, 2019 13:28 — forked from alextakitani/gist:6413691
Cedilha em teclado us-internacional, no Ubuntu 13.10 Saucy Salamander
1) Editar cada um dos arquivos:
/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache
/usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/gtk.immodules
Procurar uma linha que começa com cedilla e adicione um :en no último parâmetro, assim:
"cedilla" "Cedilla" "gtk20" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"
Ou simplesmente rode:
@marciomazza
marciomazza / commits_from_author.py
Last active June 7, 2019 14:19
Get commits from an author in a time period
from datetime import datetime
from git import Repo
def get_commits_from_author(repo_path, author_term, start_date, end_date):
repo = Repo(repo_path)
start_date, end_date = [
datetime.fromisoformat(d).date() for d in (start_date, end_date)
]
@marciomazza
marciomazza / highlight_sel_element.py
Created July 10, 2012 22:10
Highlights a Selenium Webdriver element
def highlight(element):
"""Highlights (blinks) a Webdriver element.
In pure javascript, as suggested by https://github.com/alp82.
"""
driver = element._parent
driver.execute_script("""
element = arguments[0];
original_style = element.getAttribute('style');
element.setAttribute('style', original_style + "; background: yellow; border: 2px solid red;");
setTimeout(function(){