Skip to content

Instantly share code, notes, and snippets.


Ilya V. Schurov ischurov

View GitHub Profile
ischurov /
Created Feb 8, 2015
creates a makefile to convert all ipynb-files to html and pdf
import glob
import re
import os.path
import sys
published_dir=sys.argv[1] if len(sys.argv)>1 else "published"
bns=map(lambda f: os.path.splitext(f)[0], ipynb)
ischurov / ruarticle.tplx
Last active Aug 29, 2015
Template for creating pdfs from ipynb (based on latex_article.tplx). Depends on hse-coursedata.sty which contains data about the particular course
View ruarticle.tplx
%custom IPython Notebook / NBConvert template
%based on latex_article.tplx from ipython notebook
%modified by Ilya V. Schurov <ilya at>
%license: BSD-like (see for details)
% Default to the notebook output style
((* if not cell_style is defined *))
((* set cell_style = 'style_ipython.tplx' *))
((* endif *))
ischurov /
Last active Dec 12, 2015
Get all page titles for pages in some category in Wikipedia (presently, names of all personalias are requested from ruwiki)
import requests
url = ""
query = {'action':'query',
'cmtitle':'Категория: Персоналии по алфавиту',
ischurov /
Last active Jan 2, 2016
Upload all JPG files in folder to Flickr using `flickrapi`.
import flickrapi # we're using
import glob
# get your own on
flickr = flickrapi.FlickrAPI(api_key, api_secret)
ischurov /
Created Jan 12, 2016
Send emails according to the list from Google Spreadsheet with SMTP and put them into 'Sent' folder with IMAP.
import imaplib
import time
from email.mime.text import MIMEText
from email.utils import formataddr
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
import json
import pandas as pd
View Simple example of using odeint to solve two-dimensional ode
%matplotlib inline
# to use in Jupyter
from scipy.integrate import odeint
import numpy as np
def f(Z, t):
# x = Z[0], y = Z[1]
return [Z[1], -Z[0]]
t = np.linspace(0, 10)
ischurov / testcase-mathjax-node-ee.html
Created Feb 15, 2016
Testcase for bugreport on mathjax node.
View testcase-mathjax-node-ee.html
<div style='visibility: hidden; display: none;'>
<h1 id="label_chap_notion_of_ODE"><span class="section__number">1. </span>Понятие дифференциального уравнения </h1><h2 id="label_h2_number_1"><span class="section__number">1. </span>Примеры моделей, приводящих к дифференциальным уравнениям
</h2>Прежде, чем говорить о дифференциальных уравнения в общем виде, обсудим
несколько простых примеров, в которых они возникают естественным образом.
View get_uik_data.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
ischurov /
Created Nov 3, 2016
This gist provides a function that makes pep-8-friendly multiline representation of long string.
def repr_long_str(s, maxlen=70, correction=-1, doprint=False):
assert maxlen > 3
cur = 0
out = []
while cur < len(s):
end = cur + maxlen - 2 + correction
while len(repr(s[cur:end])) > maxlen + correction:
end -= 1
correction = 0
View answer on removing empty elements.markdown

This is due to fact that you modify your list when iterating it. You can check what's going on with visualizer or add some print statements like this:

    templist = ['', 'hello', '', 'hi', 'mkay', '', '']
    for i, element in enumerate(templist):
        print("Step", i)
        print('element is', repr(element), 'and templist is', templist)
        if element == '':
            print("element is empty")