Skip to content

Instantly share code, notes, and snippets.

View komly's full-sized avatar

Dmitry Petrov komly

View GitHub Profile
@komly
komly / nuts.py
Created October 6, 2015 13:03
nuts.py
#!/usr/bin/env python3
import re
import os
import time
from bs4 import BeautifulSoup
from urllib.request import urlopen, Request
def get_wikipedia_page(name):
url = 'https://en.wikipedia.org/wiki/%s' % name
@komly
komly / 02
Last active October 1, 2015 18:10
#!/usr/bin/env python3
import os
import re
from collections import defaultdict
alphabet = defaultdict(set)
for root, dirs, files in os.walk('texts'):
for file in files:
@komly
komly / Parser
Created September 30, 2015 20:05
#!/usr/bin/env python3
import re
from urllib.request import urlopen
url = 'http://hist.hse.ru/persons/'
data = urlopen(url).read().decode()
regexp = r'b-greetings__person_data small">[^>]+>([^<]+)</a><p>([^<]+)<'
#!/usr/bin/env python3
import random
import matplotlib.pyplot as plt
initial = 100
def check(init, wage, n):
init = init
#!/usr/bin/env python
import json
import shelve
from urllib2 import urlopen
URL = 'http://54.200.3.128/examples/api.php'
DB_FILENAME = 'data.db'
#!/usr/bin/env python3
all_commands = {} # dict: name => func
def command(func):
all_commands[func.__name__] = func
return func
@command
#!/usr/bin/env python3
import random
def seed(grid):
for i in range(3, 0, -1):
if 0 in grid[i]:
r = random.randrange(4)
while grid[i][r] != 0:
r = random.randrange(4)
#!/usr/bin/env python3
import random
import string
import time
import sys
import json
while True:
# Twitter
from app.config import TWITTER_APP_KEY, TWITTER_APP_SECRET
twitter_oauth = oauth.remote_app(
'twitter',
consumer_key=TWITTER_APP_KEY,
consumer_secret=TWITTER_APP_SECRET,
base_url='https://api.twitter.com/1.1/',
request_token_url='https://api.twitter.com/oauth/request_token',
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.