Skip to content

Instantly share code, notes, and snippets.

View deliro's full-sized avatar
🦀
Rust in action

deliro

🦀
Rust in action
  • Tochka Bank
  • Russia
View GitHub Profile
@deliro
deliro / Dockerfile
Last active April 17, 2020 12:33
python alpine lxml image example
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 && \
@deliro
deliro / parse_wiki.py
Last active November 21, 2020 16:33
async parsing of wikipedia with process pool
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)
@deliro
deliro / wiki_parser.go
Created March 5, 2021 11:44
Walk through Wikipedia link graph (close to BFS) and find path from the main page to the page contain search term
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"log"
"net/http"
"regexp"
"strings"
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) {
from django.template.defaultfilters import slugify as django_slugify
alphabet = {'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i',
'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't',
'у': 'u', 'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ы': 'i', 'э': 'e', 'ю': 'yu',
'я': 'ya'}
def slugify(s):
"""