Skip to content

Instantly share code, notes, and snippets.

View marciomazza's full-sized avatar

Marcio Mazza marciomazza

View GitHub Profile
@marciomazza
marciomazza / sphinx-err.log
Created May 14, 2012 01:40
bug after "make html" of collective.developermanual at commit 8760930ab289f3938ad6d89169d93dc79ecf0b63
# Sphinx version: 1.1.2
# Python version: 2.6.5
# Docutils version: 0.9 release
# Jinja2 version: 2.5.5
Traceback (most recent call last):
File "/home/mazza/.buildout/eggs/Sphinx-1.1.2-py2.6.egg/sphinx/cmdline.py", line 189, in main
app.build(force_all, filenames)
File "/home/mazza/.buildout/eggs/Sphinx-1.1.2-py2.6.egg/sphinx/application.py", line 204, in build
self.builder.build_update()
File "/home/mazza/.buildout/eggs/Sphinx-1.1.2-py2.6.egg/sphinx/builders/__init__.py", line 196, in build_update
@marciomazza
marciomazza / revert.py
Created May 19, 2012 02:23
reverting accidental replace 'tab' -> ' ' in collective.developermanual b59bd0
# reverting accidental replace 'tab' -> ' ' in https://github.com/collective/collective.developermanual/commit/b59bd0
import difflib
def agregar(lines):
diffs = []
d = []
for l in lines:
if l.startswith('diff --git'):
diffs.append(d)
@marciomazza
marciomazza / color_ps1.sh
Created June 16, 2012 14:49
Colorize the last portion of directory name in your shell prompt
function short_pwd () {
pwd | sed -e "s@$HOME@~@"
}
function ps1_dir () {
dn=$(dirname `short_pwd`)
# in ~ yields "./" that becomes ""
# in / yields "//" that becomes "/"
echo "$dn/" | sed -e 's@^\./$@@' | sed -e 's@^//$@/@'
}
@marciomazza
marciomazza / show-no-break-space.py
Created June 17, 2012 15:54
NO-BREAK SPACE: This is evil to Sphinx syntax highlight
# -*- coding: utf-8 -*-
#!/usr/bin/python
import unicodedata
# NO-BREAK SPACE: This is evil to Sphinx syntax highlight
print unicodedata.name(u" ")
@marciomazza
marciomazza / sphinx-open-html-for-rst.el
Created June 17, 2012 16:32
Emacs lisp snippet to open the buit html when editing an rst file
(defun sphinx-open-html-for-rst nil
"Opens the buit html for the current buffer rst file in the browser."
(interactive)
(browse-url-of-file
(replace-regexp-in-string
".rst$" ".html"
(replace-regexp-in-string "/source/" "/build/html/" (buffer-file-name)))))
@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 / 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(){
@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 / Unittest Output.JSON-tmLanguage
Last active August 29, 2015 14:02
Sublime Text syntax definition for unittest output
// [PackageDev] target_format: plist, ext: tmLanguage
{ "name": "Unittest Output",
"scopeName": "output.unittest",
"patterns": [
{ "match": "FAIL: ([^ ]+) (.+)",
"name": "unittest.fail",
"captures": {
"1": { "name": "entity.name.function" },
"2": { "name": "support.function" }
}
@marciomazza
marciomazza / django test.sublime-build
Created June 13, 2014 21:40
Sublime text build for Django manage.py test (and coverage as a variant)
// Assumes a virtualenv inside ~/.virtualenvs that has the same name as the project
// Assumes manage.py is inside src
{
"working_dir": "${project_path}/src",
"shell_cmd": "~/.virtualenvs/${project_base_name}/bin/python manage.py test",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"syntax": "Packages/User/Unittest Output.tmLanguage",
"quiet": "True",
"variants": [