Skip to content

Instantly share code, notes, and snippets.

View pferreir's full-sized avatar
💭
Hacking

Pedro Ferreira pferreir

💭
Hacking
View GitHub Profile
@pferreir
pferreir / spy.py
Created July 29, 2011 13:16
Some ZODB introspection magic based on wrappers around the native objects
import transaction
import ZODB
from ZODB.utils import u64
import logging
from collections import defaultdict
from pprint import pformat
import inspect, traceback
logger = logging.getLogger('zodb_spy')
@pferreir
pferreir / killring.py
Last active December 13, 2015 23:59
Killring Plugin for Sublime Text
import sublime
import sublime_plugin
# Implements an Emacs-style kill ring feature
# Example bindings (.sublime-keymap)
#
#{ "keys": ["ctrl+k"], "command": "kill_area"},
#{ "keys": ["alt+y"], "command": "yank_list"},
@pferreir
pferreir / .gitconfig
Created February 27, 2013 14:09
git blame is awesome, but I needed more.
[alias]
humiliate = "!sh -c 'RECIPIENTS=`git blame $0 -e -L $1 | sed \"s/.* (<\\(.*\\)> .*/\\1/\" | sort | uniq | paste -sd \",\" -` ; git blame $0 -L $1 | mail -s \"WTF is this?\" $RECIPIENTS;'"
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 3
Comment=Edit text files
Exec=/usr/local/sublime-text-3/sublime_text
Icon=/usr/local/sublime-text-3/Icon/128x128/sublime-text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
@pferreir
pferreir / workshop.css
Created May 17, 2013 11:55
Indico CSS file for the 1st Indico Workshop (2013)
/*
Use this stylesheet to modify the layout of your
conference.
*/
/* ----------- Styles for the conference header ----------- */
@font-face {
@pferreir
pferreir / fabfile.py
Created June 4, 2013 13:48
Installing compass and jquery in indico (dev)
import os
from fabric.api import local, lcd
from fabric.context_managers import prefix
EXT_DIR = os.path.join(os.path.dirname(__file__), '../', 'ext_modules')
TARGET_DIR = os.path.join(os.path.dirname(__file__), '../', 'indico/htdocs')
NODE_VERSION = '0.10.9'
# Generated vars - do not change!
NODE_ENV = os.path.join(EXT_DIR, 'node_env')
@pferreir
pferreir / pre-commit
Last active December 18, 2015 22:49
pre-commit hook for PEP8 checking
#!/bin/sh
# vim: et ts=4 sw=4 ft=sh
# Interesting post on max line length:
# http://stackoverflow.com/questions/88942/why-should-python-pep-8-specify-a-maximum-line-length-of-79-characters
PEP8_CMD='pep8'
PEP8_OPTIONS='--max-line-length=120'
@pferreir
pferreir / test.py
Created July 4, 2013 08:13
PySCSS example
import logging
from scss import Scss, config
logging.basicConfig(level=logging.DEBUG)
config.LOAD_PATHS = ['ext_modules/compass/frameworks/compass/stylesheets/']
c = Scss(scss_opts={'compress': False})
@pferreir
pferreir / .gitconfig
Last active December 20, 2015 20:49
# Add to project-level .git/config
[wip]
public = name-of-your-github-remote
# Add to global .gitconfig
[wip]
webhook = http://indicotest1.cern.ch:8000/wip/notification/
[alias]
push-wip = "!pushit() { export BRANCH=\"$(git-rev-parse --symbolic-full-name --abbrev-ref HEAD)\"; export REMOTE=\"$(git config --get wip.public)\"; export WEB_HOOK=\"$(git config --get wip.webhook)\" ; git-push $REMOTE $1 \"$BRANCH:wip/$BRANCH\" 2>&1 | tee /dev/tty | grep -q 'To ' && curl -sS $WEB_HOOK --data-urlencode \"branch=$BRANCH\" --data-urlencode \"name=$(git config --get user.name)\" --data-urlencode \"remote=`git remote show -n $REMOTE | sed -n 2p | sed 's/.*[:\\/]\\([a-zA-Z0-9\\-]*\\)\\/\\(.*\\)\\.git/\\1\\/\\2/'`\" > /dev/null ;}; pushit"