This file contains hidden or 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
class Semaphore { | |
constructor(max = 1) { | |
if (max < 1) { max = 1; } | |
this.max = max; | |
this.count = 0; | |
this.queue = []; | |
} | |
acquire() { | |
let promise; | |
if (this.count < this.max) { |
This file contains hidden or 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
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"regexp" | |
"strings" |
This file contains hidden or 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 asyncio | |
from concurrent.futures import ProcessPoolExecutor | |
import aiohttp | |
from loguru import logger as loguru | |
from lxml.html import fromstring | |
pool = ProcessPoolExecutor() | |
parser_sem = asyncio.Semaphore(pool._max_workers) |
This file contains hidden or 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 redis | |
from time import sleep | |
from random import randint | |
from redq import RedisDeque | |
r = redis.StrictRedis() | |
q = RedisDeque(r, "l") | |
def consumer(): | |
while True: |
This file contains hidden or 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 pickle as _pickle | |
import json | |
from functools import partial | |
class pickle: | |
dumps = partial(_pickle.dumps, protocol=_pickle.HIGHEST_PROTOCOL) | |
loads = _pickle.loads | |
This file contains hidden or 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 node:9-alpine AS admin-build | |
WORKDIR /app | |
COPY manager . | |
RUN npm install && npm run build | |
FROM python:3.7-alpine3.7 | |
EXPOSE 5000 | |
WORKDIR /app |
This file contains hidden or 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 python:3.7-alpine | |
EXPOSE 8000 | |
WORKDIR /app | |
COPY . . | |
RUN apk add --update --no-cache --virtual .build-deps \ | |
g++ \ | |
python-dev \ | |
libxml2 \ | |
libxml2-dev && \ |
This file contains hidden or 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 heapq import heappush | |
from functools import total_ordering, reduce | |
def ip(s): | |
return reduce(lambda r, c: c + (r << 8), map(int, s.split(".")), 0) | |
@total_ordering | |
class Subnet: | |
def __init__(self, start, end): | |
self.start = start |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import argparse | |
import csv | |
import os | |
import re | |
import subprocess | |
import sys | |
from collections import OrderedDict, namedtuple | |
from datetime import datetime, timedelta |
This file contains hidden or 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 math import log | |
from array import array | |
from struct import unpack | |
from hashlib import sha512 | |
class Bits: | |
__slots__ = ('data',) | |
def __init__(self, cap): |
NewerOlder