Skip to content

Instantly share code, notes, and snippets.

View vladimirmyshkovski's full-sized avatar
🎯
Focusing

Vladimir Myshkovski vladimirmyshkovski

🎯
Focusing
View GitHub Profile
@vladimirmyshkovski
vladimirmyshkovski / UserInitials.vue
Created October 15, 2020 09:19 — forked from cb109/UserInitials.vue
Vuetify User Initials Avatar
<template>
<v-avatar v-if="user !== null"
:size="size"
:style="{'background-color': backgroundColor}">
<strong class="initials"
:style="{'color': fontColor,
'font-size': fontSize}">
{{ (user.first_name[0] + user.last_name[0]) || '?' }}
</strong>
@vladimirmyshkovski
vladimirmyshkovski / main.go
Created September 29, 2020 18:49 — forked from mcihad/main.go
Check standart django password in go language
package main
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"golang.org/x/crypto/pbkdf2"
"strconv"
"strings"
)
@vladimirmyshkovski
vladimirmyshkovski / djargon2i.go
Created September 29, 2020 18:37 — forked from hanpama/djargon2i.go
Django Argon2PasswordHasher compatible password hasher in Golang
package djargon2i
import (
"crypto/rand"
"crypto/subtle"
"encoding/base64"
"errors"
"fmt"
"strings"
@vladimirmyshkovski
vladimirmyshkovski / timeago.js
Created September 19, 2020 10:05 — forked from pomber/timeago.js
Get a time ago human friendly string from a date (like dates in twitter).
const MINUTE = 60,
HOUR = MINUTE * 60,
DAY = HOUR * 24,
YEAR = DAY * 365;
function getTimeAgo(date) {
const secondsAgo = Math.round((+new Date() - date) / 1000);
if (secondsAgo < MINUTE) {
return secondsAgo + "s";
# -*- coding: utf-8 -*-
import scrapy
import json
class FreelancerComRuSpider(scrapy.Spider):
name = 'freelancer_com_ru'
allowed_domains = ['www.freelancer.com.ru']
iDisplayStart = 0
@vladimirmyshkovski
vladimirmyshkovski / drf_optimize.py
Created December 23, 2018 18:09 — forked from jackton1/drf_optimize.py
MetaClass to Improve DRF ModelViewsSet query.
from django.db import ProgrammingError, models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query import normalize_prefetch_lookups
from rest_framework import serializers
from rest_framework.utils import model_meta
class OptimizeRelatedModelViewSetMetaclass(type):
"""
This metaclass optimizes the queryset using `prefetch_related` and `select_related`.
@vladimirmyshkovski
vladimirmyshkovski / gulpfile.js
Created May 12, 2018 12:38 — forked from soin08/gulpfile.js
Gulpfile.js to use with Django projects. Based on gulpfile.js from Google Web Starter Kit.
//Based on gulpfile.js from Google Web Starter Kit.
//https://github.com/google/web-starter-kit
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
@vladimirmyshkovski
vladimirmyshkovski / mixin.py
Created April 20, 2018 21:10 — forked from cyberdelia/mixin.py
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
# sample implementation for http://stackoverflow.com/questions/37851053/django-query-group-by-month#new-answer
from __future__ import unicode_literals
from django.db import models
from django.db.models import Func, F, Sum
from django.db.transaction import atomic, rollback
from django.utils.timezone import now
class Invoice(models.Model):
@vladimirmyshkovski
vladimirmyshkovski / django-image-save.py
Created December 1, 2017 13:06 — forked from iambibhas/django-image-save.py
Programatically save ImageField in Django
import requests
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
def save_image_from_url(model, url):
r = requests.get(url)
img_temp = NamedTemporaryFile(delete=True)