Skip to content

Instantly share code, notes, and snippets.

View dmitryTsatsarin's full-sized avatar

Dmitry Tsatsarin dmitryTsatsarin

View GitHub Profile
import sys
def snail(n, m):
dx, dy = 1, 0
x, y = 0, 0
arr = [[0] * m for _ in range(n)]
for i in range(1, n * m + 1):
print(y, x)
arr[x][y] = i
import sys
a = int(sys.argv[1])
s = bin(a)[2:]
reverse = s[::-1]
print('Result is %s' % int(reverse, 2))
@dmitryTsatsarin
dmitryTsatsarin / .yaml
Created October 2, 2018 10:31
Swagger 2.0 example
swagger: '2.0'
info:
title: Simple API overview
version: v2
paths:
/:
get:
operationId: listVersionsv2
summary: List API versions
parameters: [{
@dmitryTsatsarin
dmitryTsatsarin / start-celery-for-dev.py
Created September 20, 2018 10:15 — forked from chenjianjx/start-celery-for-dev.py
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os
@dmitryTsatsarin
dmitryTsatsarin / .py
Created July 28, 2017 15:56
Python говнецо
page = urllib.urlopen('http://export.finam.ru/'+str(row['code'])+'_'+str(year_start)+str(month_start)+str(day_start)+'_'+str(year_end)+str(month_end)+str(day_end)+str(e)+'?market='+str(row['id_exchange_2'])+'&em='+str(row['em'])+'&code='+str(row['code'])+'&apply=0&df='+str(df)+'&mf='+str(mf)+'&yf='+str(yf)+'&from='+str(day_start)+'.'+str(month_start)+'.'+str(yf)+'&dt='+str(dt)+'&mt='+str(mt)+'&yt='+str(yt)+'&to='+str(day_end)+'.'+str(month_end)+'.'+str(yt)+'&p='+str(p)+'&f='+str(row['code'])+'_'+str(year_start)+str(month_start)+str(day_start)+'_'+str(year_end)+str(month_end)+str(day_end)+'&e='+str(e)+'&cn='+str(row['code'])+'&dtf='+str(dtf)+'&tmf='+str(tmf)+'&MSOR='+str(MSOR)+'&mstimever='+str(mstimever)+'&sep='+str(sep)+'&sep2='+str(sep2)+'&datf='+str(datf)+'&at='+str(at))
print('http://export.finam.ru/'+str(row['code'])+'_'+str(year_start)+str(month_start)+str(day_start)+'_'+str(year_end)+str(month_end)+str(day_end)+str(e)+'?market='+str(row['id_exchange_2'])+'&em='+str(row['em'])+'&code='+str(row['
class Employee:
def __init__(self, name, salary = 0):
self.name = name
self.salary = salary
def giveRaise(self, percent):
self.salary = self.salary + (self.salary * percent)
def work(self):
print(self.name, "I work")
Дан электронный журнал. Который содержит "разделы" (содержащий заголовок, и возрастной ценз). А также "статьи" (имеет заголовок, содержание, имя автора)
Создать страницу редактора, который будет заниматься выставлением связи между статьей и разделом.
Использовать git, сделать минимум 5 коммитов.
@dmitryTsatsarin
dmitryTsatsarin / es.py
Created June 8, 2016 06:51
Открытие тикета по Alt-F2 в Linux
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import subprocess
if len(sys.argv)>1:
ticket_number = sys.argv[1]
subprocess.check_output("google-chrome https://leverxeu.atlassian.net/browse/EESP01-%s" % ticket_number, shell=True)
else:
print 'Need to put number of ticket'
@dmitryTsatsarin
dmitryTsatsarin / .py
Created May 24, 2016 06:25
Fibonacci (python)
f = [1, 1]
n = 15
for i in xrange(2, n):
f.append(f[i-1]+f[i-2])
print f
# coding=utf-8
#Задание 1
#Даны числа a и b (a < b). Выведите сумму всех натуральных чисел от a до b (включительно).
while True:
print("Условие: a < b")
a = int(input("Введите число а: "))
b = int(input("Введите число b: "))
if a < b:
s = 0