Skip to content

Instantly share code, notes, and snippets.

View badzil's full-sized avatar

Benoit Thiell badzil

  • Boston, MA
View GitHub Profile
@badzil
badzil / install_homebrew.rb
Created November 10, 2011 14:05 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# unzip https://github.com/mxcl/homebrew/zipball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
* Strip spaces at start and end
* Replace tabs with space
* Collapse multiple spaces
* Reverse the affiliations file
* Load into Google refine.
@badzil
badzil / ADS_affiliation_parser.py
Created February 16, 2011 23:50
ads_affiliations_splitter.py
import re
_RE_MULTIPLE_SPACES = re.compile('\s\s+')
_RE_AFFILIATION_PREFIX = re.compile('([A-Z][A-Z]+)\(')
_RE_AFFILIATION_SUFFIX = re.compile('\)[,;]? [A-Z][A-Z]+\(')
_RE_EMAIL = re.compile(';?\s?<EMAIL>\s?(.*?)\s?</EMAIL>;?')
def clean_affiliations_string(affiliations_string):
"""
Strips the spaces and collapses multiple spaces.
Original inspiration found here:
http://www.openerp.com/forum/topic21864.html
== Install libxml2 ==
$ wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.7.8.tar.gz
$ tar xvf libxml2-sources-2.7.8.tar.gz
$ cd libxml2-2.7.8/
$ ./configure --with-python=/usr/bin/python2.6
$ make
@badzil
badzil / invenio_collection_creator.py
Created December 3, 2010 18:59
Invenio automatic collection creator
#!/usr/bin/python
from invenio.dbquery import run_sql
from invenio.websearchadminlib import add_col
def collection_exist(tag):
"""
Checks if a collection exists.
@return: The name of the collection if it exists, None otherwise.
"""