Skip to content

Instantly share code, notes, and snippets.

View pavelk2's full-sized avatar

Pavel Kucherbaev pavelk2

View GitHub Profile
class Graph:
def __init__(self, graph_dict = {}, directed = False):
self.graph_dict = graph_dict
self.directed = directed
def __str__(self):
M = self.getMatrix()
S = '\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in M])
return "\n"+S+"\n"
graph = {
1: {2:1,5:1},
2: {1:1,3:1,5:1},
3: {2:1,4:1},
4: {3:1,5:1,6:1},
5: {1:1,2:1,4:1},
6: {4:1}
}
time = 0
type image_url
image http://habrastorage.org/files/01a/a40/810/01aa40810d044a75a19fbbbfe662a508.jpg
image http://habrastorage.org/files/037/099/83d/03709983d5cb4cc4a80af0fbcaac5f08.jpg
image https://habrastorage.org/files/856/bcc/925/856bcc92508b45f395825963b3b06712.jpg
image http://habrastorage.org/files/04d/10d/54d/04d10d54dee242d988d4ff28a8029743.jpg
image http://habrastorage.org/files/0e9/77d/3a5/0e977d3a5df546ccac61244b6c940c4a.jpg
image http://habrastorage.org/files/121/9e9/277/1219e9277afb4ed6807f1e3da3b64c67.jpg
image http://habrastorage.org/files/127/61f/c68/12761fc6898643b3ab1e30552d31af52.jpg
image http://habrastorage.org/files/135/cd3/eca/135cd3ecab0646f2b2cd7924b1e0105f.jpg
image http://habrastorage.org/files/158/722/4d7/1587224d72de485eb7aed42070fafdda.jpg
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
_unit_id,_unit_state,_trusted_judgments,_last_judgment_at,is_the_image_corruptednot_available,is_the_image_corruptednot_available:confidence,type_the_address_of_the_company_provided_the_service,type_the_name_of_the_company_provided_the_service,type_the_receipt_date_here,type_the_receipt_date_here_mmddyyyy,type_the_total_sum_paid,image_url,is_the_image_corruptednot_available_gold,type,type_the_address_of_the_company_provided_the_service_gold,type_the_name_of_the_company_provided_the_service_gold,type_the_receipt_date_here_mmddyyyy_gold,type_the_total_sum_paid_gold
1423022026,finalized,3,10/25/2017 15:39:34,no,0.6757,"
none","FS
trenitalia s.p.a.
trenitalia s.p.a.","
","09/13/2017
09/13/2017
09/13/2017","7.85
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 11 columns, instead of 10. in line 5.
_unit_id,_created_at,_started_at,_trust,_country,is_the_image_corruptednot_available,type_the_address_of_the_company_provided_the_service,type_the_name_of_the_company_provided_the_service,type_the_receipt_date_here_mmddyyyy,type_the_total_sum_paid,image_url
1423022026,10/25/2017 14:15:39,10/25/2017 14:14:22,0.8,ITA,yes,,FS,09/13/2017,7.85,https://habrastorage.org/webt/59/ef/2e/59ef2edd85399794646604.png
1423022026,10/25/2017 15:31:21,10/25/2017 15:27:26,1.0,ITA,no,,trenitalia s.p.a.,09/13/2017,7.85,https://habrastorage.org/webt/59/ef/2e/59ef2edd85399794646604.png
1423022026,10/25/2017 15:39:34,10/25/2017 15:34:02,0.6667,ITA,no,none,trenitalia s.p.a.,09/13/2017,7.85,https://habrastorage.org/webt/59/ef/2e/59ef2edd85399794646604.png
1423022027,10/25/2017 14:15:39,10/25/2017 14:14:22,0.8,ITA,yes,,AZIENDA TRASPORTI VERONA SRL,09/02/2017,6.00,https://habrastorage.org/webt/59/ef/2e/59ef2edd18bb3985801448.png
1423022027,10/25/2017 15:31:21,10/25/2017 15:27:26,1.0,ITA,no,,atv azienda trasporti verona srl,09/17/2017,6.
image_url type
https://habrastorage.org/webt/59/ef/2e/59ef2edd85399794646604.png image
https://habrastorage.org/webt/59/ef/2e/59ef2edd18bb3985801448.png image
https://habrastorage.org/webt/59/ef/2e/59ef2edc9ab71468255812.png image
https://habrastorage.org/webt/59/ef/2e/59ef2edc67d6b045519411.png image
https://habrastorage.org/webt/59/ef/2e/59ef2edd54376286960885.png image
drop table socialaccount_socialaccount;
drop table socialaccount_socialapp;
drop table socialaccount_socialapp_sites;
drop table socialaccount_socialtoken;
drop table account_emailaddress;
drop table account_emailconfirmation;
drop table auth_token;
drop table django_admin_log;

Try sending requests:

Register a new user
POST /users/registration/ HTTP/1.1
Host: localhost:8000
Content-Type: application/json
Cache-Control: no-cache

{
 "username":"pavel.kucherbaev@gmail.com",
@pavelk2
pavelk2 / test.R
Last active September 17, 2015 08:17
T.Test Crowd-ReLauncher
y1 <- c(3854,3783,2195,4047,1849)
y2 <- c(679,738,1153,949,1221)
t.test(y1,y2,alternative = "greater")
t.test(y1,y2,alternative = "greater", var.equal = T)
@pavelk2
pavelk2 / ros_ml.R
Created June 23, 2015 12:18
estimate-normal-distribution-from-small-sample-with-rankings
#
# Negative log likelihood for parameters `theta`, based on a subset `y` from
# a sample of `n` iid values, associated with ranks in `m`.
#
Lambda <- function(theta, y, m, n) {
mu <- theta[1]; sigma <- theta[2]
powers <- diff(c(0, m, n+1)) - 1
gaps <- diff(c(0, pnorm(y, mu, sigma), 1))
z <- dnorm(y, mu, sigma)
#a <- lgamma(n+1) - sum(lgamma(powers+1)) # Log multinomial coefficient