Skip to content

Instantly share code, notes, and snippets.

@boris-arzur
boris-arzur / IDLE with asyncio + imaplib + mbsyncrc
Last active July 5, 2023 14:44
I use a mail stack based on mbsync & notmuch. I want to run mbsync on new mails. IDLE allows watching efficiently one folder in my mailbox. Async makes is easy to watch a few connections.
#!python3
import imaplib
import os
import asyncio
loop = asyncio.get_event_loop()
conf = [x.strip().split() for x in open('mbsyncrc')]
#!py -2
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# http://stackoverflow.com/questions/2455606/basichttpserver-simplehttpserver-and-concurrency
# http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
import ssl
@boris-arzur
boris-arzur / cell1.py
Last active August 29, 2015 14:19
interactive inception in ipython 3.1 notebook
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import display
import time
def printd(x):
print("option", x)
def generate_options(count):
return ["text %f %d"%(time.time(), i) for i in range(count)]
@boris-arzur
boris-arzur / keep_me_posted.py
Last active August 29, 2015 14:19
read maildir from interactive ipython notebook
%%file /ipy/mailcheck.py
import mailbox
import email.utils
import email.header
import email.iterators
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import display
@boris-arzur
boris-arzur / play_w_gist.ipynb
Last active December 27, 2015 13:09
Playing with ipython & gist
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Age,number of survivors,number of deaths,survivors rate,death rate,force of mortality,life expectancy,stationary L,stationary T
0,100000,246,0.99754,0.00246,0.09375,79.55,99808,7955005
1,99754,37,0.99963,0.00037,0.00057,78.75,99733,7855198
2,99716,26,0.99974,0.00026,0.00026,77.78,99704,7755464
3,99690,18,0.99982,0.00018,0.00022,76.80,99681,7655761
4,99672,13,0.99987,0.00013,0.00015,75.81,99665,7556080
5,99659,11,0.99989,0.00011,0.00012,74.82,99653,7456415
6,99647,10,0.99990,0.00010,0.00011,73.83,99642,7356762
7,99637,9,0.99991,0.00009,0.00010,72.84,99632,7257120
8,99628,8,0.99992,0.00008,0.00009,71.84,99623,7157488