Skip to content

Instantly share code, notes, and snippets.

Avatar

Vadim K vkudyushev

  • Russia
View GitHub Profile
@vkudyushev
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,})))'
#Python
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
else:
return False
@vkudyushev
vkudyushev / happybase_test_put_counter.py
Created Jul 28, 2018 — forked from wbolster/happybase_test_put_counter.py
Python code to test HappyBase library (HBase), and counter and put speeds
View happybase_test_put_counter.py
#!/usr/bin/env python
import logging
import random
import time
import happybase
logging.basicConfig()
logger = logging.getLogger()
@vkudyushev
vkudyushev / insert_data.py
Created Jul 28, 2018 — forked from jarrettmeyer/insert_data.py
Inserting data into HBase with Python
View insert_data.py
#!/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
Indianapolis.
@vkudyushev
vkudyushev / json-combiner.sh
Created Jul 23, 2018
Combine json lines (from separate files) to (single) json array
View json-combiner.sh
#!/bin/bash
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
vkudyushev / docker-rm.sh
Created Jun 24, 2018
Stop and remove all Docker containers; remove all Docker images
View docker-rm.sh
#!/bin/bash
# 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
vkudyushev / migrate-django.md
Created May 7, 2018 — forked from sirodoht/migrate-django.md
How to migrate Django from SQLite to PostgreSQL
View migrate-django.md

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

You can’t perform that action at this time.