Skip to content

Instantly share code, notes, and snippets.

@RaD
RaD / json-dumps.py
Created Mar 16, 2020
Пример, как выгрузить JSON с форматированием и русскими строками
View json-dumps.py
with open('expected_data.json', 'w', encoding='utf8') as json_file:
json.dump(EXPECTED_DATA, json_file, ensure_ascii=False, indent=4, sort_keys=True)
@RaD
RaD / nginx-ssl.yml
Created Dec 6, 2019
SSL for services
View nginx-ssl.yml
# Конфигурация для запуска nginx в качестве SSL прокси для других контейнеров.
# Не забудьте создать сеть перед запуском этой конфигурации:
# docker network create nginx-proxy
# и добавить следующую строку к проксируемым контейнерам '--network nginx-proxy'.
version: '2'
services:
nginx:
image: nginx
View append_mptt_into_django_fixture.py
import json
path_src = './references/migrations/0004_speciality.json'
path_dst = './references/migrations/0004_speciality.json'
src = open(path_src, 'r')
dst = open(path_dst, 'w')
payload = json.loads(src.read())
result = []
index = 0
for i in payload:
@RaD
RaD / Dockerfile
Created Nov 2, 2018
How to build Docker image in the Docker container
View Dockerfile
FROM alpine:3.8
MAINTAINER Ruslan Popov <ruslan.popov@gmail.com>
ARG SOURCE_VERSION=UNSPECIFIED
ARG SOURCE_COMMIT=UNSPECIFIED
ENV \
SOURCE_VERSION=${SOURCE_VERSION} \
SOURCE_COMMIT=${SOURCE_COMMIT} \
View isincos.py
#!/usr/bin/env python
import math
OUTBITS = 16
BITS_PER_CYCLE = 16
BITS_PER_QUARTER = BITS_PER_CYCLE - 2
BITS = 8
ONE = 1 << BITS
HALF = ONE / 2
C = 70710 * ONE / 100000
@RaD
RaD / lintrunner.py
Created Dec 30, 2016
Flake8 integration
View lintrunner.py
#!/usr/bin/env python
"""
Install packages:
wajig install pylint pyflakes pep8 pychecker
pip install flake8
"""
import os
@RaD
RaD / examples.py
Created Sep 29, 2016
Some Django related stuff
View examples.py
# -*- coding: utf-8 -*-
import os
from datetime import timedelta
from django.utils import timezone
from django.db import models
from django.utils.translation import ugettext_lazy as _
class Vehicle(models.Model):
@RaD
RaD / gisrest.py
Created Sep 15, 2016
Simple RESTful service on Flask with CRUD and GIS
View gisrest.py
# requirements: flask-restful
import math
from flask import Flask
from flask_restful import Resource, Api, abort, reqparse
app = Flask(__name__)
api = Api(app)