This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
http://revista.python.org.ar/1/html/revista.html#desafio-python | |
entrada: 11 | |
salida: 11 | |
entrada: 8 | |
salida 2^3 | |
entrada: 24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import oursql | |
import sys | |
from twisted.enterprise import adbapi | |
from twisted.internet import defer, reactor | |
from twisted.python import log | |
log.startLogging(sys.stderr) | |
# Use 'test' database with default credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Pass 122 | |
test_remove_filename (__main__.GridFSTest) ... FAIL | |
====================================================================== | |
FAIL: test_remove_filename (__main__.GridFSTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "test_put.py", line 18, in test_remove_filename | |
self.assertEqual(f._id, id2) | |
AssertionError: ObjectId('4cc20c88e779893aae0002d6') != ObjectId('4cc20c88e779893aae0002d8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pyall)rolando@atlantis:~/src/jquery/src$ grep IE *.js | |
ajax.js: rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL | |
ajax.js:// #8138, IE may throw an exception when accessing | |
ajax.js: // since IE will modify it given document.location | |
ajax.js: // to avoid any 'Permission Denied' errors in IE | |
ajax.js: // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) | |
attributes.js: // Fixes Bug #2551 -- select.val() broken in IE after form.reset() | |
attributes.js: // We can't allow the type property to be changed (since it causes problems in IE) | |
attributes.js: // convert the value to a string (all browsers do this but IE) see #1070 | |
attributes.js: // Some attributes require a special call on IE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
window.FlashMessages = { | |
init: function() { | |
this.container = $("#flash-messages") | |
.find("a.message-close") | |
.fadeIn("slow") | |
.live("click", function() { | |
$(this).parent() | |
.fadeOut("slow", function() { | |
$(this).remove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Simple script to convert a image into data uri. | |
More info http://en.wikipedia.org/wiki/Data_URI_scheme | |
""" | |
import base64 | |
import mimetypes | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python parse_urls.py http://somesite/foo/ ".pdf\$" | |
""" | |
import sys | |
import urllib2 | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
from scrapy.http import HtmlResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The contents of this file are subject to the Python Software Foundation | |
# License Version 2.3 (the License). You may not copy or use this file, in | |
# either source code or executable form, except in compliance with the License. | |
# You may obtain a copy of the License at http://www.python.org/license. | |
# | |
# Software distributed under the License is distributed on an AS IS basis, | |
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
# for the specific language governing rights and limitations under the | |
# License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
from scrapy.dupefilter import BaseDupeFilter | |
from scrapy.utils.request import request_fingerprint | |
class RedisDupeFilter(BaseDupeFilter): | |
def __init__(self, host, port): | |
self.redis = redis.Redis(host, port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge_dicts(dict_list): | |
"""Merge all values from dict list into a single dict | |
>>> d1 = {'a': 1, 'b': 2} | |
>>> d2 = {'a': 2, 'b': 3} | |
>>> merge_dicts([d1, d2]) | |
{'a': [1, 2], 'b': [2, 3]} | |
""" | |
kviter = chain.from_iterable(d.iteritems() for d in dict_list) |