Skip to content

Instantly share code, notes, and snippets.

View vpavlenko's full-sized avatar
🇦🇲

Vitaly Pavlenko vpavlenko

🇦🇲
View GitHub Profile
@vpavlenko
vpavlenko / darvin.500.js
Last active November 30, 2017 09:46
Request with 1 item
var request = require("request");
var options = { method: 'POST',
url: 'http://api.iiko.ru/php/router.php',
qs: { a: 'add_order' },
headers:
{ 'postman-token': '8ac0fba1-afc8-5490-329d-528ca4c1cf53',
'cache-control': 'no-cache',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
formData:
This file has been truncated, but you can view the full file.
[pid: 13113|app: 0|req: 3457/22626] 24.7.23.129 () {50 vars in 1541 bytes} [Thu Jan 26 03:21:44 2017] POST /visualizer/execute/ => generated 998 bytes in 289 msecs (HTTP/1.1 200) 1 headers in 51 bytes (1 switches on core 0)
[pid: 13113|app: 0|req: 3458/22627] 24.7.23.129 () {50 vars in 1531 bytes} [Thu Jan 26 03:21:55 2017] POST /backup_source/ => generated 2 bytes in 45 msecs (HTTP/1.1 200) 2 headers in 65 bytes (1 switches on core 0)
[pid: 13113|app: 0|req: 3459/22628] 24.7.23.129 () {50 vars in 1531 bytes} [Thu Jan 26 03:21:55 2017] POST /save_progress/ => generated 2 bytes in 42 msecs (HTTP/1.1 200) 2 headers in 65 bytes (1 switches on core 0)
[pid: 12257|app: 0|req: 2467/22629] 24.7.23.129 () {44 vars in 1435 bytes} [Thu Jan 26 03:21:56 2017] GET /get_master_solution/?problem=digit_after_decimal_point => generated 205 bytes in 62 msecs (HTTP/1.1 200) 2 headers in 65 bytes (1 switches on core 0)
[pid: 5041|app: 0|req: 4871/22630] 169.233.140.230 () {42 vars in 814 bytes} [Thu Jan 26 03:21:59 2017] GET /le
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
АНО детский сад ВЕГА;
АНО ОСШ "Город Солнца";
АНО СОШ Учебный центр Перспектива;
"ГОУ ДОД ""Федеральный детский эколого-биологический центр""";
"ГОУ ДОД ""Федеральный центр детско-юношеского туризма и краеведения""";
"Знаменская гимназия";
"Некоммерческое партнерство Центр развития личности дошкольника ""Гармония""";
"Новая гуманитарная школа";
"НОУ ""Институт информационных систем""";
"НОУ Учебно-воспитательный Центр ""ОНФИМ""";

The pyspark documentation doesn't include an example for the aggregateByKey RDD method. I didn't find any nice examples online, so I wrote my own.

Here's what the documetation does say:

aggregateByKey(self, zeroValue, seqFunc, combFunc, numPartitions=None)

Aggregate the values of each key, using given combine functions and a neutral "zero value". This function can return a different result type, U, than the type of the values in this RDD, V. Thus, we need one operation for merging a V into a U and one operation for merging two U's, The former operation is used for merging values within a partition, and the latter is used for merging values between partitions. To avoid memory allocation, both of these functions are allowed to modify and return their first argument instead of creating a new U.

reduceByKey and aggregateByKey are much more efficient than groupByKey and should be used for aggregations as much as possible.

@vpavlenko
vpavlenko / dabblet.css
Last active August 29, 2015 14:12
Untitled
html, body {
padding: 0;
margin: 0;
height: 100%;
}
.sky {
position: relative;
height: 50%;
background: linear-gradient(to top, lightblue, blue);
@vpavlenko
vpavlenko / gist:71316f32ee5e2ac4d05f
Last active August 29, 2015 14:08
Семинар по Джаве, 25.10.2014

Кодирование длин серий

Напишите функцию, принимающую на вход последовательность и заменяющую в ней все серии одинаковых элементов на пару (количество, элемент). Серией называется любое количество одинаковых элементов идущих подряд (серия может иметь длину 1).

Напишите так же функцию, выполняющую обратное преобразование.

Пример:

compress([1, 2, 2, 2, "test", "test", 2]) = [(1, 1), (3, 2), (2, "test"), (1, 2)])
import math
def distance_of_points(p1, p2):
'''
>>> distance_of_points((3, 0), (0, 4))
5.0
'''
return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)
import java.util.HashMap;
import java.util.Map;
public class HelloWorld{
public static void main(String []args){
Map m = new HashMap<String, String>();
m.put("abc", 123);
System.out.println(m.get("abc"));
}
Дано:
! [first-fix] local patched with lay
! [lay] lay
! [master] lay
! [really-first-fix] first after review
* [second-fix] second fix after review
-----
* [second-fix] second fix after review
* [second-fix^] second fix