Skip to content

Instantly share code, notes, and snippets.

View rmax's full-sized avatar
:octocat:
ヾ(⌐■_■)ノ♪

R Max Espinoza rmax

:octocat:
ヾ(⌐■_■)ノ♪
View GitHub Profile
"""
http://revista.python.org.ar/1/html/revista.html#desafio-python
entrada: 11
salida: 11
entrada: 8
salida 2^3
entrada: 24
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
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')
(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
(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();
@rmax
rmax / datauri.py
Created March 29, 2011 19:46
single script to convert a image into data uri
#!/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
@rmax
rmax / parse_urls.py
Created June 2, 2011 14:35
using scrapy without scrapy
"""
python parse_urls.py http://somesite/foo/ ".pdf\$"
"""
import sys
import urllib2
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.http import HtmlResponse
@rmax
rmax / bencode.py
Created August 5, 2011 02:14
bittorrent format encoder/decoder that I found somewhere in the internet
# 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.
@rmax
rmax / dupefilter.py
Created August 28, 2011 23:12
A Redis-based request dupefilter for Scrapy
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)
@rmax
rmax / merge_dicts.py
Created September 21, 2011 21:05
using itertools's chain and groupby to merge a list of dictionaries
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)