Skip to content

Instantly share code, notes, and snippets.

View dmitriiweb's full-sized avatar
😀

Dmitrii K dmitriiweb

😀
  • Python developer, Data and AI engineer
View GitHub Profile
@dmitriiweb
dmitriiweb / bs_vs_lxml.py
Last active March 13, 2024 02:22
BeautifulSoup vs lxml
from datetime import datetime
from datetime import datetime
import requests
from bs4 import BeautifulSoup as BSoup
from lxml import html
def get_html():
url = 'https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States'
@dmitriiweb
dmitriiweb / requests_download_file.py
Last active December 15, 2018 05:02
requests shutil download file
import requests
import shutil
r = requests.get('url', stream=True)
if r.status_code == 200:
with open(path, 'wb') as f:
r.raw.decode_content = True
shutil.copyfileobj(r.raw, f)
@dmitriiweb
dmitriiweb / install_chrome_driver
Last active July 5, 2020 14:13 — forked from thotmx/install_chrome_driver
Install chromedriver in Ubuntu (14.04)
# ONLY UBUNTU < 20.04
$ sudo apt-get install chromium-chromedriver chromium-browser
$ sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
@dmitriiweb
dmitriiweb / replace_specific_characters.py
Created June 7, 2019 09:21
Replace language specific characters in python with English letters
import unicodedata
city = "České Budějovice"
normalized = unicodedata.normalize('NFD', city)
new_city = u"".join([c for c in normalized if not unicodedata.combining(c)])
print(new_city) # Ceske Budejovice
@dmitriiweb
dmitriiweb / clear_text_decorator.py
Last active July 25, 2020 12:38
Decorator, remove non visible characters from string
def clear_text(func):
"""Remove non visible characters (\\n, \\r, \\t)
Example:
>>> @clear_text
>>> def foo():
... return "blah \\n blah"
...
>>> foo()
... blah blah
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream backend {
server 127.0.0.1:3000 fail_timeout=0;
}
upstream streaming {
@dmitriiweb
dmitriiweb / postLimit.sh
Created April 18, 2025 22:09 — forked from adlerweb/postLimit.sh
Mastodon v4.3.x (<4.3.4) docker post character limit change
#!/bin/bash
# Mastodon v4.3.x docker character limit change
# Does *NOT* word with >= 4.3.4 as the handling was changed
# Based on https://mpp-service.de/en/mastodon-character-limit-increase-in-a-docker-environment/
# Based on https://fouquet.me/2024/10/10/mastodon-4-3-char-limit
# ./postLimit.sh 2500 → change post limit to 2500
# Must be executed in the directory Mastodons docker-compose.yaml is located
set -e