Skip to content

Instantly share code, notes, and snippets.

View alexmacedo's full-sized avatar

Alexandre Macedo alexmacedo

  • Delivery Direto
  • São Paulo, Brazil
View GitHub Profile
@alexmacedo
alexmacedo / pipeline.py
Created January 3, 2012 00:08
Unix pipeline pattern in python
#! /usr/bin/env python
class Pipeline(object):
def __init__(self):
self.source = None
def __iter__(self):
return self.generator()
def generator(self):
@alexmacedo
alexmacedo / rmpycs.sh
Created October 27, 2011 14:08
Shell command to remove .pyc files recursively.
#! /bin/sh
# remove .pyc files recursively
find . | egrep *.pyc$ | xargs rm
@alexmacedo
alexmacedo / Usage
Created October 11, 2011 21:04
Virtualenv bootstrap script to create a Django environment
$ python generate_bootstrap.py bootstrap_base.py > django-bootstrap.py
$ python django-bootstrap.py ENV --project=NAME [ --hg --git --mysql --south --fabric --nose ]
@alexmacedo
alexmacedo / gist:1235067
Created September 22, 2011 15:29
shell functions to facilitate virtualenv use
workon()
{
if [ $# -eq 0 ]; then
echo Pass a environment to load.
return
fi
source ~/environments/$1/bin/activate
}
@alexmacedo
alexmacedo / post2posterous.py
Created June 18, 2011 13:37
Python script to post a plain markdown file to a blog, using the posterous API.
#! /usr/bin/env python
import getpass
import base64
import httplib
import urllib
import json
import getopt
import sys
@alexmacedo
alexmacedo / lazy.rb
Created November 27, 2010 14:40
lazy proc implementation in ruby
module Lazy
class LazyProc
alias __class__ class
instance_methods.each { |m| undef_method m unless m =~ /^__/ or m == :object_id }
def initialize(&computation)
@computation = computation
end
def inspect