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
def number_to_georgian(amount, currency): | |
if currency == 'GEL': | |
main_unit = 'ლარი' | |
fractional_unit = 'თეთრი' | |
elif currency == 'USD': | |
main_unit = 'დოლარი' | |
fractional_unit = 'ცენტი' | |
elif currency == 'EUR': | |
main_unit = 'ევრო' | |
fractional_unit = 'ცენტი' |
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 time | |
from datetime import datetime | |
import requests | |
URL = 'https://example.com' | |
CHECK_SECONDS = 60 | |
def monitor(): |
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
# I suggest you use memcached or redis as backend | |
import time | |
import json | |
from functools import wraps | |
def cached(timeout=1800): | |
def wrapper(f): | |
@wraps(f) |
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
# the following two lines give a two-line status, with the current window highlighted | |
hardstatus alwayslastline | |
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]' | |
# huge scrollback buffer | |
defscrollback 5000 | |
# no welcome message | |
startup_message off |
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
def coords_distance(coords_from, coords_to): | |
lat1, long1 = coords_from | |
lat2, long2 = coords_to | |
degrees_to_radians = math.pi / 180.0 | |
phi1 = (90.0 - lat1) * degrees_to_radians | |
phi2 = (90.0 - lat2) * degrees_to_radians | |
theta1 = long1 * degrees_to_radians |
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
require_relative '../vagrant/key_authorization' | |
Vagrant.configure('2') do |config| | |
config.vm.box = 'ubuntu/trusty64' | |
authorize_key_for_root config, '/home/mihail/.ssh/id_dsa.pub', '/home/mihail/.ssh/id_rsa.pub' | |
{ | |
'db' => '192.168.33.10', | |
'elasticsearch'=> '192.168.33.11', | |
'app' => '192.168.33.12' | |
}.each do |short_name, ip| |
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
Cinderella | |
The wife of a rich man fell sick, and as she felt that her end | |
was drawing near, she called her only daughter to her bedside and | |
said, dear child, be good and pious, and then the | |
good God will always protect you, and I will look down on you | |
from heaven and be near you. Thereupon she closed her eyes and | |
departed. Every day the maiden went out to her mother's grave, | |
and wept, and she remained pious and good. When winter came | |
the snow spread a white sheet over the grave, and by the time the | |
spring sun had drawn it off again, the man had taken another wife. |
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 python | |
# -*- coding: utf-8 -*- | |
# | |
# Форматирование словоформы "1, 2, 5" (посетитель/посетителя/посетителей) | |
import random | |
def choose_word_form(number, form1, form2, default): | |
mod10 = abs(number) % 10 |
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
def get_ip(request): | |
""" | |
Возвращает ip из HTTP-заголовков. Если там его нет, возвращает значение | |
атрибута remote_ip | |
@param request: экземпляр HTTPRequest | |
@return: строка, содержащая ip клиента | |
""" | |
if 'X-Real-Ip' in request.headers: |
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
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://upstream_name; | |
} |
NewerOlder