Skip to content

Instantly share code, notes, and snippets.

beautifulsoup4
et-xmlfile
flake8
importmagic
jdcal
jedi
lxml
mccabe
openpyxl
pep8
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)
@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):
package main
import (
"fmt"
"math/rand"
"errors"
)
func Sort(list []int) ([]int, error) {
if len(list) < 2 {
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))
# Load Excel files in a folder and load content to simple class
# Using first row as a header
from typing import Tuple, Generator
from types import SimpleNamespace
import os
from openpyxl import load_workbook
INPUT_BASE_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'TheKnotResults_250cities')
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(name)s: %(message)s')
cargo install whalespotter
Updating crates.io index
Installing whalespotter v0.1.4
Compiling cfg-if v0.1.10
Compiling autocfg v1.0.0
Compiling libc v0.2.68
Compiling lazy_static v1.4.0
Compiling scopeguard v1.1.0
Compiling proc-macro2 v1.0.9
Compiling log v0.4.8
use bson;
use bson::{decode_document, encode_document};
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
#[derive(Serialize, Deserialize, Debug)]
struct Move {
x: i32,
"""
Just a custom function, which allow you to use ARRAY_AGG aggregation function in TortoiseORM
"""
from typing import TYPE_CHECKING, Any, Optional, Type, cast, Iterable, Tuple
from pypika import Table
from pypika.functions import Function as PypikaFunction
from tortoise.exceptions import ConfigurationError
from tortoise.fields.relational import BackwardFKRelation, ForeignKeyFieldInstance, RelationalField