Skip to content

Instantly share code, notes, and snippets.

View zztalker's full-sized avatar
🏠
Working from home

Pavel Zaikin zztalker

🏠
Working from home
View GitHub Profile
@zztalker
zztalker / plotFx.py
Created October 17, 2014 06:11
How to plot function
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$")
@zztalker
zztalker / renderFormula.py
Last active August 29, 2015 14:07
How to render math formula to PNG with matplotlib (python)
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)
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)
@zztalker
zztalker / gist:9221077
Created February 26, 2014 00:38
Get RSS feed from Blogger and write it into separate files.
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()