Skip to content

Instantly share code, notes, and snippets.

vkudyushev / valid_domain_name_regex
Created May 1, 2020 — forked from neu5ron/valid_domain_name_regex
Valid domain name regex including internationalized domain name
View valid_domain_name_regex
domain_regex = r'(([\da-zA-Z])([_\w-]{,62})\.){,127}(([\da-zA-Z])[_\w-]{,61})?([\da-zA-Z]\.((xn\-\-[a-zA-Z\d]+)|([a-zA-Z\d]{2,})))'
domain_regex = '{0}$'.format(domain_regex)
valid_domain_name_regex = re.compile(domain_regex, re.IGNORECASE)
self.domain_name = self.domain_name.lower().strip().encode('ascii')
if re.match(valid_domain_name_regex, self.domain_name ):
return True
return False
vkudyushev /
Created Jul 28, 2018 — forked from wbolster/
Python code to test HappyBase library (HBase), and counter and put speeds
#!/usr/bin/env python
import logging
import random
import time
import happybase
logger = logging.getLogger()
vkudyushev /
Created Jul 28, 2018 — forked from jarrettmeyer/
Inserting data into HBase with Python
#!/usr/bin/env python
Insert data into HBase with a Python script.
To create the table, first use the hbase shell. We are going to create a
namespace called "sample_data". The table for this script is called "rfic",
as we will be inserting Request for Information Cases from the City of
vkudyushev /
Created Jul 23, 2018
Combine json lines (from separate files) to (single) json array
shopt -s nullglob
declare -a jsons
jsons=(*.json) # ${jsons[@]} - в переменной jsons теперь список всех файлов
echo '[' > combined.json
if [ ${#jsons[@]} -gt 0 ]; then # проверяем что список не пустой
cat "${jsons[0]}" >> manifest.json # первый файл в файл выхода
unset jsons[0] # и убираем из спика
for f in "${jsons[@]}"; do # и циклом по оставшимся
vkudyushev /
Created Jun 24, 2018
Stop and remove all Docker containers; remove all Docker images
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
vkudyushev /
Created May 7, 2018 — forked from sirodoht/
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 dumpdata > datadump.json

Change to Postgres backend.

Make sure you can connect on PostgreSQL. Then: