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
from gevent import monkey; | |
monkey.patch_all() | |
from gevent import Greenlet | |
from gevent.pool import Pool | |
from gevent.pool import Group | |
from gevent.queue import Queue | |
import gevent | |
from BeautifulSoup import * | |
import urllib, urllib2 |
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 urllib2 | |
class RequestWithMethod(urllib2.Request): | |
def __init__(self, method, *args, **kwargs): | |
self._method = method | |
super(RequestWithMethod, self).__init__(*args, **kwargs) | |
def get_method(self): | |
if getattr(self, '_method', False): |
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
Copyright (c) 2011 Christopher Chedeau, http://blog.vjeux.com/ | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: | |
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import requests | |
from lxml.html import fromstring | |
map(lambda event: print("Status: %(status)s Fecha: %(date)s Hora: %(hour)s" % dict([(e.attrib['class'], e.text) for e in event if 'class' in e.attrib])), fromstring(requests.get('http://mrw.es/seguimiento_envios/MRW_historico_nacional.asp?enviament=026928458321').content).cssselect('.zebra')[0][1]) |
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
# -*- coding: utf-8 -*- | |
""" | |
requests.async | |
~~~~~~~~~~~~~~ | |
This module contains an asynchronous replica of ``requests.api``, powered | |
by gevent. All API methods return a ``Request`` instance (as opposed to | |
``Response``). A list of requests can be sent with ``map()``. |
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
from django.core.validators import email_re | |
from django.contrib.auth.backends import ModelBackend | |
from django.contrib.auth.models import User | |
class YaraAuthenticationBackend(ModelBackend): | |
def authenticate(self, identification, password=None): | |
try: | |
if email_re.search(identification): |
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
from django.utils import translation | |
from django.conf import settings | |
from django.utils.cache import patch_vary_headers | |
class UserLocaleMiddleware(object): | |
def process_request(self, request): | |
lang_session = request.session.get(settings.LANGUAGE_COOKIE_NAME) | |
if not lang_session: |
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
var Data = { | |
_ownKeys: [], | |
_similar: [], | |
_appKey: 'listenAnywhere', | |
set: function(key, value) | |
{ | |
var existingValue = localStorage.getItem(this._appKey); | |
if (null === existingValue) { | |
existingValue = {}; |
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 requests | |
from lxml.html import fromstring, iterlinks | |
print 'wget %s' % ' && wget '.join(['http://lsi.vc.ehu.es/pablogn/docencia/ficheros/ISO1112/%s' % l[2] for l in filter(lambda x: x[2].endswith('pdf'), iterlinks(fromstring(requests.get('http://lsi.vc.ehu.es/pablogn/docencia/ficheros/ISO1112/').content)))]) |
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
// Settings in here override those in "Default/Preferences.sublime-settings", and | |
// are overridden in turn by file type specific settings. | |
{ | |
"theme": "Soda Dark.sublime-theme", | |
"font_face": "The Sans Mono-", | |
"font_size": 14, | |
"rulers": | |
[ | |
80 | |
], |