This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
"env": { | |
"browser": true, | |
"commonjs": true, | |
"es6": true, | |
"node": true, | |
}, | |
"extends": "eslint:recommended", | |
"parserOptions": { | |
"sourceType": "module", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Simple shell script for django project creation | |
# Edit variables section and run: create_django_app.sh projectname | |
# | |
NAME=$1 | |
DOMAIN="$NAME.dev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECT=$1 | |
REPO_USER=myusername | |
REPO_API_URL=https://api.bitbucket.org/1.0/repositories/ | |
PROJECTS_DIR=/home/username/projects | |
APP_DIR="$PROJECTS_DIR/$PROJECT" | |
curl --user $REPO_USER $REPO_API_URL --data name=$PROJECT --data is_private='true' --data scm='git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tarfile | |
from contextlib import closing | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EMAIL_HOST = 'smtp.yandex.ru' | |
EMAIL_PORT = 587 | |
EMAIL_HOST_USER = '[email protected]' | |
EMAIL_HOST_PASSWORD = 'password' | |
DEFAULT_FROM_EMAIL = '[email protected]' | |
EMAIL_USE_TLS = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64) | |
# (из коробки) OpenSSL 1.1.0g 2 Nov 2017 | |
# (из коробки) curl 7.58.0 (x86_64-pc-linux-gnu) | |
# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS ) | |
# Компилим GOST-engine | |
sudo apt install cmake libssl-dev | |
git clone --branch=openssl_1_1_0 https://github.com/gost-engine/engine.git gost-engine/engine | |
cd gost-engine/engine | |
cmake . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
class SetVarNode(template.Node): | |
def __init__(self, var_name, var_value): | |
self.var_name = var_name | |
self.var_value = var_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DocumentQuerySet(models.QuerySet): | |
def pdfs(self): | |
return self.filter(file_type='pdf') | |
def smaller_than(self, size): | |
return self.filter(size__lt=size) | |
class Document(models.Model): | |
name = models.CharField(max_length=30) | |
size = models.PositiveIntegerField(default=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathToRegexp from 'path-to-regexp'; | |
export const reverse = (path, kwargs={}) => { | |
const toPath = pathToRegexp.compile(path); | |
return toPath(kwargs); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.validator.addMethod("inn", function (value, element) { | |
var multipliers = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8], | |
inn = value.split(''), i, j, ch = [0, 0, 0]; | |
for (i = 0; i < 12; i++) | |
for (j = 0; j < 3; j++) | |
if (multipliers[i + j]) | |
ch[j] = ch[j] + inn[i] * multipliers[i + j]; | |
if (inn.length == 10) | |
return inn[9] == ch[2] % 11 % 10; | |
else if (inn.length == 12) |
OlderNewer