Skip to content

Instantly share code, notes, and snippets.

View marciomazza's full-sized avatar

Marcio Mazza marciomazza

View GitHub Profile
@mitchellrj
mitchellrj / configure.zcml
Created November 25, 2011 14:58
z3c.form data manager for persistent dictionaries
<configure
xmlns="http://namespaces.zope.org/zope">
<adapter
factory=".datamanager.PersistentDictionaryField" />
</configure>
@perrygeo
perrygeo / gist:1903033
Created February 24, 2012 19:09
Sed scripts to fix blank lines and whitespace; helps code comply with PEP8
# Removes whitespace chars from blank lines
pep8 -r --select=W293 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i 's/^[ \r\t]*$//'
# Removes trailing blank lines from files
pep8 -r --select=W391 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}'
# Squashes consecutive blanks lines into one
pep8 -r --select=E303 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i '/./,/^$/!d'
# confirm
@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
@ieure
ieure / python-pylint.el
Created February 12, 2010 18:49
Run pylint on Python source in Emacs.
;;; python-pylint.el --- minor mode for running `pylint'
;; Copyright (c) 2009, 2010 Ian Eure <ian.eure@gmail.com>
;; Author: Ian Eure <ian.eure@gmail.com>
;; Keywords: languages python
;; Last edit: 2010-02-12
;; Version: 1.01
@magopian
magopian / conftest.py
Last active November 1, 2018 17:10
Some pytest(-django) fixtures that I find useful. There's also an "app" fixture to take advantage of django-webtest when used with py.test.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, division
import pytest
from django_webtest import DjangoTestApp, WebTestMixin
class Stub(object):
"""Stub methods, keep track of calls."""
@ekampf
ekampf / gist:772597
Created January 10, 2011 09:56
Show the current Git branch in the command line prompt
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
@j4mie
j4mie / normalise.py
Created August 30, 2010 12:44
Normalise (normalize) unicode data in Python to remove umlauts, accents etc.
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal
@nicferrier
nicferrier / gist:2277987
Created April 1, 2012 19:34
Clone a git repo if it does not exist, or pull into it if it does exist
#!/bin/sh
REPOSRC=$1
LOCALREPO=$2
# We do it this way so that we can abstract if from just git later on
LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]
then
@rg3915
rg3915 / README.md
Last active November 29, 2023 16:26
Django padrão de nomenclatura - singular plural

Escreva quase tudo no singular, é mais fácil.

  • project: singular
  • app: singular
  • model: singular
  • field: singular
  • FK related_name: plural
  • url: plural
  • views: singular
@huytd
huytd / .gitconfig
Created August 4, 2016 16:26
Use neovim as diff tool
[merge]
tool = vimdiff
[mergetool]
prompt = true
[mergetool "vimdiff"]
cmd = nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'
[difftool]
prompt = false
[diff]
tool = vimdiff