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 feedparser | |
d = feedparser.parse('http://pavel.zaikin.pro/feeds/posts/default') | |
for e in d.entries: | |
title = e.title.replace('"',"'") | |
content = e.content | |
f = open(title + ".html", "w",encoding='utf-8') | |
f.write('<html><body>') | |
f.write(content[0]['value']) | |
f.write("</body></html>") | |
f.close() |
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 lastDigit(barcode): | |
if len(barcode)!=12: | |
return "error:wrong len" | |
else: | |
control2 = int(barcode[1])+int(barcode[3])+int(barcode[5])+int(barcode[7])+int(barcode[9])+int(barcode[11]) | |
control1 = int(barcode[0])+int(barcode[2])+int(barcode[4])+int(barcode[6])+int(barcode[8])+int(barcode[10]) | |
control = 10-(control2*3+control1)%10 | |
if control == 10: | |
control = 0 | |
return str(control) |
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 matplotlib.mathtext as mt | |
s = r'$\int_{0}^{\frac{\sqrt{2}}{2}} 1-x^2 dx - \int_{0}^{\frac{\sqrt{2}}{2}} x^2 dx + \int_{\frac{\sqrt{2}}{2}}^{1} 1-x^2 dx$' | |
m = mt.MathTextParser("Bitmap") | |
m.to_png('test.png',s) |
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 math import * | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def f1(x): | |
return x*x | |
x = np.arange(0,1.0,0.01) | |
plt.plot(x,f1(x),label=r"$y=x^2$") |
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
s = file.readline() | |
for e in file.readlines(): | |
l = e.split('\t') | |
row = db.docs(doc_id=l[0]) | |
if not row: | |
db.docs.insert(doc_id=l[0],type_doc1=l[1],type_doc2=l[2],type_doc3=l[3], | |
surname1 = l[4], name1 = l[5], patronymic1 = l[6], | |
surname2 = l[7], name2 = l[8], patronymic2 = l[9]) | |
rec = db.doc_status.insert(doc_id=l[0],status=l[10],status_ex=l[11],date_change=l[12]) | |
else: |
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 ajax_addbasket(): | |
# получаем данные из пост заспроса, для Flask request.forms | |
s = request.vars.senddata.split(",") | |
qRec = 0 | |
for doc in s: | |
if len(doc)!=0: | |
db.basket.insert(doc_id = doc, userid = session.auth.user.id) | |
qRec += 1 | |
#print u"Успешно добавлено "+str(qRec)+" записей" | |
qRecStr = str(qRec) |
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
<form> | |
<input type="button" value="В корзину" | |
onclick="myajax('{{=URL('ajax_addbasket')}}','target')"/> | |
<input type="hidden" id="senddata" name="senddata" value=""/> | |
</form> | |
<script> | |
function myajax(u,t) { | |
var trList = jQuery(".clickedRow") | |
//var table = document.getElementById('idWalkTable'); |
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 functools import wraps | |
def islogged(func): | |
# нужен декоратор на декорируемую функцию, т.к. app.route - составляет таблицу view - и ему нужны уникальные ссылки на функции. | |
# Если не добавить подобный декоратор, то ссылки будут одинаковые - на функцию decorated_view | |
# wraps - использует создание экземпляра объекта partial - (каждый экземпляр обладает уникальной ссылкой и ведёт себя как функция) | |
# https://docs.python.org/3/library/functools.html#functools.partial | |
@wraps(func) | |
def decorated_view(*args, **kwargs): | |
if not session.get('logged_in'): |
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 datetime | |
s = input("Date in format yyyy\mm\dd: ").split("\\") | |
d = datetime.date(int(s[0]),int(s[1]),int(s[2])) | |
N = input("Diff days: ") | |
print(d+datetime.timedelta(days=int(N))) |
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 mpl_toolkits.mplot3d import Axes3D | |
from matplotlib import cm | |
from matplotlib.ticker import LinearLocator, FormatStrFormatter | |
import matplotlib.pyplot as plt | |
import numpy as np | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
X = np.arange(1, 9, 1) | |
print(X) |
OlderNewer