Skip to content

Instantly share code, notes, and snippets.

View alexey-senexx's full-sized avatar

alexey-senexx

View GitHub Profile
@alexey-senexx
alexey-senexx / int.py
Last active August 29, 2015 14:16
Interview question for real Pythonista
# 1. What is x?
type(x) = x
# 2. What's the output of the following code
# What's wrong with it?
# How to fix?
def foo(x=1, a=[]):
a.append(x)
return a
@alexey-senexx
alexey-senexx / txamqp_reconnecting client
Created January 28, 2015 21:23
txAMQP reconnecting client redefiend.
import os
from logging import getLogger
from twisted.internet import protocol, reactor, task
from twisted.internet.defer import inlineCallbacks, Deferred, returnValue, DeferredList
from txamqp import spec
from txamqp.protocol import AMQClient
from txamqp.client import TwistedDelegate
from txamqp.content import Content
import re
from scrapy import log
from scrapy.http import Request
from scrapy.exceptions import IgnoreRequest
from scrapy.utils.httpobj import urlparse_cached
from scrapy.contrib.downloadermiddleware.redirect import RedirectMiddleware
class RedirectOffsiteMiddleware(RedirectMiddleware):