Skip to content

Instantly share code, notes, and snippets.

def check_setting(param_name):
"""
Simple decorator to disable pipeline for spiders with some attributes
```
class A:
f_enabled = True
@check_setting('f_enabled')
def f(self, times):
print(' '.join(['hey!'] * times))
package main
import (
"fmt"
"math/rand"
"errors"
)
func Sort(list []int) ([]int, error) {
if len(list) < 2 {
@drjackild
drjackild / comm.py
Created June 1, 2016 05:43 — forked from drocco007/comm.py
Python generator rate limiter using token bucket
from time import time, sleep
_128k = 128 * 1024
_256k = 256 * 1024
_512k = 512 * 1024
_1024k = 1024 * 1024
class TokenBucket(object):
import datetime
class Throttle(object):
def __init__(self, domain, max_hits, period):
self.domain = domain
self.max_hits = max_hits
self.hits = 0
self.period = datetime.timedelta(seconds=period)
beautifulsoup4
et-xmlfile
flake8
importmagic
jdcal
jedi
lxml
mccabe
openpyxl
pep8