Skip to content

Instantly share code, notes, and snippets.

View vladimirmyshkovski's full-sized avatar
🎯
Focusing

Vladimir Myshkovski vladimirmyshkovski

🎯
Focusing
View GitHub Profile
from myapp.models import User
...:
...: users = []
...:
...: for i in range(1000):
...: user = User(first_name='User%dFirstName' % i,
...: last_name='User%dLastName' % i,
...: username='user%d' % i,
...: email='user%[email protected]' % i,
...: password='hashedPasswordStringPastedHereFromStep1!',
@vladimirmyshkovski
vladimirmyshkovski / gist:c846070fbafc62b17c028921ab021702
Created May 18, 2017 00:07
find all files and get size in bytes, python
In [11]: import os
...: for root, dirs, files in os.walk('/var/www/gglobal/media/images/'):
...: for fn in files:
...: path = os.path.join(root, fn)
...: size = os.stat(path).st_size
...: print('{} {} bytes'.format(path.split('/')[-1], size))
@vladimirmyshkovski
vladimirmyshkovski / gist:c6ceeac1c441b13888fa2dfea60236b7
Created May 18, 2017 00:15
resize all images in folder PIL python
In [11]: #!/usr/bin/python
...: from PIL import Image
...: import os, sys
...:
...: path = "/var/www/gglobal/media/images/"
...: dirs = os.listdir( path )
...:
...: def resize():
...: for item in dirs:
...: if os.path.isfile(path+item):
@vladimirmyshkovski
vladimirmyshkovski / gist:be4c55924bd9569f4cfa90de3b512c72
Created June 8, 2017 14:04
html parse with beautiful soup and selenium
from bs4 import BeautifulSoup
from urllib.request import urlopen, Request
import csv
from selenium import webdriver
import time
import math
import ast
from sqlalchemy.exc import IntegrityError, InterfaceError, InvalidRequestError
@vladimirmyshkovski
vladimirmyshkovski / gist:0ea968a46d1fac2637b77038dd03f2fd
Last active June 24, 2017 08:15
create city subdomains with django-cities-light and inda (punycode)
from cities_light.models import City
import idna
file = open('/tmp/domains.txt', 'w')
cities = City.objects.all()
for city in cities:
file.write(str(idna.encode((city.alternate_names).lower().replace(' ','-') + str('.домен.рф')))+str('\n'))
file.close()
@vladimirmyshkovski
vladimirmyshkovski / gist:df651131e8977a2435366c4539b75195
Created July 16, 2017 12:23
vue.js search autocomplete for Django
<div id="base">
<div class="btn-group" :class="{show : dropDown}">
<input class="form-control mr-sm-2" placeholder="{% trans 'Search' %}" v-model="q" data-toggle="dropdown" aria-haspopup="true" :aria-expanded="{true : dropDown}">
<div class="dropdown-menu">
<search-item
v-for="item in search"
:item="item"
:key="item.id">
</search-item>
@vladimirmyshkovski
vladimirmyshkovski / docker-destroy-all.sh
Created July 18, 2017 05:27 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and 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)
docker-compose -f local.yml run --rm django coverage run --source . -m py.test
docker-compose -f local.yml run --rm django coverage report
docker-compose -f local.yml run --rm django coverage html
(function(window, document, version, callback) {
var j, d;
var loaded = false;
if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "/media/jquery.js";
script.onload = script.onreadystatechange = function() {
if (!loaded && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
callback((j = window.jQuery).noConflict(1), loaded = true);
@vladimirmyshkovski
vladimirmyshkovski / README-Template.md
Created August 18, 2017 14:11 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites