Skip to content

Instantly share code, notes, and snippets.

@vkudyushev
vkudyushev / migrate-django.md
Created May 7, 2018 01:33 — forked from sirodoht/migrate-django.md
How to migrate Django from SQLite to PostgreSQL

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:

@vkudyushev
vkudyushev / docker-rm.sh
Created June 24, 2018 13:42
Stop and remove all Docker containers; remove all Docker images
#!/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 / json-combiner.sh
Created July 23, 2018 08:49
Combine json lines (from separate files) to (single) json array
#!/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 / insert_data.py
Created July 28, 2018 18:29 — forked from jarrettmeyer/insert_data.py
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
Indianapolis.
@vkudyushev
vkudyushev / happybase_test_put_counter.py
Created July 28, 2018 18:29 — forked from wbolster/happybase_test_put_counter.py
Python code to test HappyBase library (HBase), and counter and put speeds
#!/usr/bin/env python
import logging
import random
import time
import happybase
logging.basicConfig()
logger = logging.getLogger()
@vkudyushev
vkudyushev / valid_domain_name_regex
Created May 1, 2020 21:21 — forked from neu5ron/valid_domain_name_regex
Valid domain name regex including internationalized domain name
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