Skip to content

Instantly share code, notes, and snippets.

View felipe-prenholato's full-sized avatar

Felipe Prenholato felipe-prenholato

View GitHub Profile
(fibs)felipe@PLAPSTMD142:~/projects/fibs$ time pypy fibs.py
real 0m3.900s
user 0m3.530s
sys 0m0.090s
(fibs)felipe@PLAPSTMD142:~/projects/fibs$ time python2.6 fibs.py
real 0m14.614s
user 0m13.660s
sys 0m0.260s
E..
======================================================================
ERROR: test_base_reader_init (data_importer.tests.ReaderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/felipe/projects/p1/django-data-importer/sampleproject/data_importer/tests/__init__.py", line 51, in test_base_reader_init
self.assertEquals(open(self.files['csv_sheet'],'rb').read(),reader.source.read())
ValueError: Mixing iteration and read methods would lose data
----------------------------------------------------------------------
# coding: utf-8
import csv
from .base import BaseReader
class CSVReader(BaseReader):
__reset=False
def __init__(self,f,**kwargs):
self.delimiter = kwargs.pop('delimiter',';')
LOG_DEBUG = logging.DEBUG # 10
LOG_INFO = logging.INFO # 20
LOG_WARN = logging.WARN # 30
LOG_ERROR = logging.ERROR # 40
LOG_CRITICAL = logging.CRITICAL # 50
LOG_STOPED = 59
LOG_FINISHED = 60
LOG_OPTIONS = (
(LOG_DEBUG,u"DEBUG"),
Downloading/unpacking importlib (from django-sentry->-r requirements.txt (line 34))
Downloading importlib-1.0.2.tar.bz2
Exception:
Traceback (most recent call last):
File "/var/www/qas3/lib/python2.6/site-packages/pip-1.0.1-py2.6.egg/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/var/www/qas3/lib/python2.6/site-packages/pip-1.0.1-py2.6.egg/pip/commands/install.py", line 223, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/var/www/qas3/lib/python2.6/site-packages/pip-1.0.1-py2.6.egg/pip/req.py", line 961, in prepare_files
self.unpack_url(url, location, self.is_download)
function handle_forms(event) {
var $triggerObj = $(event.target)
var num = parseInt($("#id_form-TOTAL_FORMS").val())
var $last_row = $("#unidades_inline > tbody > tr:last")
var $triggerObjRow = $triggerObj.parents("tr")
if ($last_row.attr('id') == $triggerObjRow.attr('id')) {
// than we are playing on last line, add new line if have something typed
console.log(event,event.keyCode,'LAST_ROW',$triggerObj.attr('id'),$triggerObj.val(),event.target.value)
@felipe-prenholato
felipe-prenholato / recreate_db_for_tests.sh
Created August 25, 2011 17:50
scripts/auxiliar/recreate_db_for_tests.sh
#!/bin/bash
function readlink_f () { X_=`pwd`; cd $1 && echo `pwd` && cd $X_; }
_SCRIPT_RELATIVE_PATH="scripts/auxiliar/recreate_db_for_tests.sh"
_DB=$1
_DBDUMP=$2
_VERSION=$3
_PORTAL_PATH=$(readlink_f $0 | sed -e "s,${_SCRIPT_RELATIVE_PATH},,")
@felipe-prenholato
felipe-prenholato / filter_and_assign_tag.py
Created August 23, 2011 13:22
A Django Tag that can do filter and exclude from a queryset, assigning to another context variable.
class FilterAndAssignNode(template.Node):
def __init__(self,parser=None,to=None,query=None,filter=None,exclude=None):
self.parser = parser
self.to = to
self.query = query
self.filter = filter or []
self.exclude = exclude or []
def do_simple_search(model,fields,q,objects=None):
if not objects:
objects = model.objects.select_related()
def make_subquery(fields,value):
_q = Q()
for fname in fields:
_q |= Q(**{fname+'__icontains': value})
return _q
diff -ur django_original/template//debug.py django/template//debug.py
--- django_original/template//debug.py 2011-05-02 13:36:03.872849001 -0300
+++ django/template//debug.py 2011-05-05 14:17:20.522849008 -0300
@@ -87,6 +87,7 @@
def render(self, context):
try:
output = self.filter_expression.resolve(context)
+ output = self.clean_pks(output)
output = localize(output)
output = force_unicode(output)