Skip to content

Instantly share code, notes, and snippets.

View dchaplinsky's full-sized avatar

Dmitry Chaplinsky dchaplinsky

View GitHub Profile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
#Django Frontend
config.vm.network "forwarded_port", guest: 8000, host: 8080
@dchaplinsky
dchaplinsky / declarations_api.py
Last active December 3, 2021 00:06
Simple example of how to export all assets declarations from declarations.com.ua website.
import requests
import json
from time import sleep
data = []
print("Fetching page #%s" % 1)
r = requests.get("http://declarations.com.ua/search?format=opendata").json()
data += r["results"]["object_list"]
In [1]: from unicodecsv import DictReader
In [2]: fp = open("problematic.csv", "r")
In [3]: r = DictReader(fp)
In [4]: r.next() # First row is not interesting
Out[4]:
{u'\u0406\u041f\u041d': u'',
u'\u0414\u0430\u0442\u0430 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0456': u'',
Категорія ІПН Назва Посада ПІБ Дата народження Дата призначення Дата звільнення Дата відповіді Лінк на відповідь/лінк на сайт Дата народження Дата призначення Декларація 2010 Декларація 2011 Декларація 2012 Декларація 2013
Стратегічні державні підприємтсва
4687867 Український державний науково-дослідний проектний інститут азотної промисловості і продуктів органічного синтезу, м. Дніпродзержинськ Директор Барабаш Олександр Іванович 13.08.1962 04.02.2009 26.12.2014 https://drive.google.com/file/d/0B96kVmiv1cb7OXd1TW9aV1BrcmV4bzJpVzBxSU02RWNXbHJN/view?usp=sharing
import bz2
with bz2.BZ2File("test.bz2", "r") as fp:
i = 0
for l in fp:
print(l)
import re
import os.path
import requests
from random import sample, random
from collections import Counter
from pymongo import MongoClient
from glob2 import glob
client = MongoClient()
db = client.decl
INFO 2014-12-22 12:55:53 simplifying tags: looking for tag spellings
INFO 2014-12-22 12:56:06 simplifying tags: looking for spelling duplicates (skip_space_ambiguity: True)
DEBUG 2014-12-22 12:56:06 290 duplicate tags will be removed
INFO 2014-12-22 12:56:06 simplifying tags: fixing
INFO 2014-12-22 12:56:11 inlining lexeme derivational rules...
INFO 2014-12-22 12:56:12 building paradigms...
DEBUG 2014-12-22 12:56:12 word len(gramtab) len(words) len(paradigms)
DEBUG 2014-12-22 12:56:12 пообклеювати 15 15 1
DEBUG 2014-12-22 12:56:15 кричавши 1042 133287 667
DEBUG 2014-12-22 12:56:16 димувати 1249 269033 985
INFO 2014-12-21 17:20:27 simplifying tags: looking for tag spellings
INFO 2014-12-21 17:20:41 simplifying tags: looking for spelling duplicates (skip_space_ambiguity: True)
DEBUG 2014-12-21 17:20:41 313 duplicate tags will be removed
INFO 2014-12-21 17:20:41 simplifying tags: fixing
INFO 2014-12-21 17:20:46 inlining lexeme derivational rules...
INFO 2014-12-21 17:20:47 building paradigms...
DEBUG 2014-12-21 17:20:47 word len(gramtab) len(words) len(paradigms)
DEBUG 2014-12-21 17:20:47 пообклеювати 15 15 1
DEBUG 2014-12-21 17:20:50 кричавши 1186 133287 667
DEBUG 2014-12-21 17:20:51 димувати 1417 269033 985
@dchaplinsky
dchaplinsky / titleua.py
Last active August 29, 2015 14:10
Simple implementaiton of python's title that works well with ukrainian surnames and names (including compound ones and names with apostrophes)
# -*- coding: utf-8 -*-
from string import capwords
def title(s):
chunks = s.split()
chunks = map(lambda x: capwords(x, u"-"), chunks)
return u" ".join(chunks)
if __name__ == '__main__':
@dchaplinsky
dchaplinsky / unshred_gtd_stats.js
Created November 11, 2014 22:37
Some interesting stats that we've obtained during beta test on GTD dataset.
>> db.tagging_speed.aggregate(
{
$match:
{
msec: {$gte: 2 * 1000, $lte: 180 * 1000}
}
},
{
$group:
{