Skip to content

Instantly share code, notes, and snippets.

Artur Barseghyan barseghyanartur

Block or report user

Report or block barseghyanartur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View string_enums_graphene.md

This works for me:

from enum import Enum
import graphene


class NoValue(Enum):

    def __repr__(self):
@barseghyanartur
barseghyanartur / django_union_snippet.rst
Last active Aug 22, 2019
Django: Select 3 most recent Post objects from 3 different users in a single database query
View django_union_snippet.rst

Task

Given:

  • There are a lot of Post objects.
  • There are 3 users.

What we want:

  • Select 3 most recent Post objects from 3 different users.
View find_python_2_7_code.rst
pip install black
black . --target-version=py36 --check --quiet
@barseghyanartur
barseghyanartur / index.rst
Created May 28, 2019
Body weight/height BMI calculation
View index.rst

BMI is weight divided by height in the power of two.

bmi = weight / height**2

Body Mass Index Scale

  • Underweight: less than 18.5
  • Normal weight: 18.5 - 25
View expose_local_port_to_the_world.md
View install_postgresql9.4_postgis2.1_ubuntu.md

Remove old PostGIS Installation

The first step is to remove older version of PostGIS if any.

sudo apt-get purge postgis

Setup repository

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
@barseghyanartur
barseghyanartur / instructions.rst
Last active Jan 23, 2019
Find coordinates by postal code
View instructions.rst

Install pgeocode package:

pip install pgeocode

Find the geo coordinates by postal code:

View example.rst
@barseghyanartur
barseghyanartur / urls.py
Last active Feb 9, 2019
Minimalistic REST API view
View urls.py
from django.conf.urls import url
from views import sample_api_view
urlpatterns = [
url(
r'^sample-api-view/$',
sample_api_view,
name="sample_api_view"
),
You can’t perform that action at this time.