Skip to content

Instantly share code, notes, and snippets.

View komly's full-sized avatar

Dmitry Petrov komly

View GitHub Profile
#!/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
all_commands = {} # dict: name => func
def command(func):
all_commands[func.__name__] = func
return func
@command
#!/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
import random
import matplotlib.pyplot as plt
initial = 100
def check(init, wage, n):
init = init
@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>([^<]+)<'
@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 / 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
#!/usr/bin/env python3
import re
import json
from urllib.request import urlopen
start, finish = int(input('Start thread number: ')), int(input('Finish thread number: '))
url = 'http://www.forumishqiptar.com/threads/%d'
def find_posts(text):
#!/usr/bin/env python3
import sys
import re
if len(sys.argv) < 3:
print("Usage: %s file_to_read file_to_write" % sys.argv[0])
exit(1)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int count[3];
int tables = 0;
cin >> count[0] >> count[1] >> count[2];