Skip to content

Instantly share code, notes, and snippets.

View MarkLavrynenko's full-sized avatar

Mark Lavrynenko MarkLavrynenko

View GitHub Profile
angular.module('geomApp')
.controller('MainCtrl', function ($scope) {
$scope.testesTriangles = [];
//$scope.points = [{x: 40, y: 400},
// {x: 16, y: 300},
// {x: 230, y: 200},
// {x: 430, y: 100},
// {x: 330, y: 400},
// {x: 130, y: 270}];
$scope.points = [{x: 116, y: 300}];
@MarkLavrynenko
MarkLavrynenko / gist:93c12dbd0ef5636e154b
Created May 16, 2015 10:20
Artificial Intelligence
/*
# 1) a, b- min(x) a^x <= b
# 2) list - a, b; (a - b ) union (b - a)
# 3) a - find last atom
# 4) depth - the deepest sublist with sublists
# 5) sublists count
# 6) лінеаризація
# 7) min-max tree optonal
*/
@MarkLavrynenko
MarkLavrynenko / gist:74783a5329ce957e2bf0
Created June 27, 2015 09:35
Python process safe queue usage example and logging from multiple processes
from multiprocessing import Process, Queue
from time import sleep
def func(q, cnt, log):
for i in range(0, cnt):
item = q.get()
message = "Got an item %s\n" % item
log.put(message)
if __name__ == '__main__':
@MarkLavrynenko
MarkLavrynenko / gist:e411985a9dd0a496f7b3
Last active August 29, 2015 14:23
Discardable distributed job
from multiprocessing import Process, Manager, Event
from random import randint
children_count = 5
block_size = 10000
def find(my_id, found):
print("Process with id %s has been started" % my_id)
left = block_size * my_id
right = left + block_size
@MarkLavrynenko
MarkLavrynenko / gist:02711dc9c16242afd96f
Created June 27, 2015 17:42
Interesting thing with Pipe
from multiprocessing import Pool, Pipe, Process
def work(process_name, pipe):
while True:
print("%s Start w8!" % process_name)
data = pipe.recv()
print("%s You sent %s" % (process_name, data))
if __name__ == "__main__":
import string
class Node:
def __init__(self):
self._links = {}
self._is_finite = False
def set_link(self, letter, node):
if letter == '.':
@MarkLavrynenko
MarkLavrynenko / gist:5b763e36b128170cdb77
Created June 5, 2015 17:02
Download Pdf file using AJAX (angular)
angular.module("test-app", [])
.controller("PDFDownloadController", ["$scope", "$http", function($scope, $http) {
function handleResponse(response){
var pdfFile = new Blob([response.data], { type : 'application/pdf' })
var downloadURL = URL.createObjectURL(pdfFile);
var link = document.createElement('a');
link.href = downloadURL;
link.download = "preview.pdf"
document.body.appendChild(link);
link.click();