Skip to content

Instantly share code, notes, and snippets.

View mturilin's full-sized avatar

Mikhail Turilin mturilin

  • Google
  • San Francisco, CA
View GitHub Profile
@mturilin
mturilin / quote.py
Last active February 29, 2016 23:36
Email reformatting and quoting workflow for Alfred
def find_next_space(text, start):
while start < len(text):
if text[start] == " ":
return start
else:
start += 1
return start
def find_next_non_space(text, start):
while start < len(text):
@mturilin
mturilin / README.txt
Last active September 1, 2019 20:44
Word Count
Get text file from URL, count all the words, and print top 20 words with the number of times they appear in the file.
URL: http://www.gutenberg.org/files/5200/5200.txt
(please copy this *exact* URL into your code)
Sample output:
the - 34
a - 12
hello - 5
@mturilin
mturilin / multi_pipe.py
Last active August 29, 2015 14:00
Python multi-threading example
from multiprocessing import Process, Pipe
import sys
import time
import random
def worker(p):
while True:
s = p.recv()
if not s:
break
import json
import unicodecsv as csv
import sys
def recursive_keys(row):
keys = set()
for k in row.keys():
if isinstance(row[k], dict):
for subkey in recursive_keys(row[k]):