Skip to content

Instantly share code, notes, and snippets.

View marciomazza's full-sized avatar

Marcio Mazza marciomazza

View GitHub Profile
@marciomazza
marciomazza / i18n_from_portuguese.py
Last active August 29, 2015 14:07
Script to aid on a "reverse translation" FROM [a portuguese codebase with no i18n] TO [an english one with i18n]
# Script to aid on a "reverse translation":
# * FROM a portuguese codebase with no i18n
# * TO an english one with i18n
#
# Process:
#
# In the cenario wher your have all your code with portuguese strings and no i18n
# (Naturally that applies to other languages as well)
#
# 1. Mark all your translatable portuguese strings with gettext marks _(...)
@marciomazza
marciomazza / postactivate
Last active August 29, 2015 14:17
Virtualenv general postactivate hook to trigger sublime projects and more
#!/bin/bash
# This hook is run after every virtualenv is activated.
# (~/.virtualenvs/postactivate)
DOT_PROJECT="${VIRTUAL_ENV}/.project"
if [ -f $DOT_PROJECT ]; then
PROJECT_DIR=`head -n 1 ${DOT_PROJECT} | tr -d '[[:space:]]'`
# GIT status
if [ -d "$PROJECT_DIR/.git" ]; then
git -C $PROJECT_DIR status -sb
import getpass
from github import Github
def main():
username = raw_input("User: ")
pw = getpass.getpass('Sua senha: ')
g = Github(username, pw)
me = g.get_user()
@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 / 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)
]