Skip to content

Instantly share code, notes, and snippets.

View maxkarelov's full-sized avatar
🏠
Working from home

Max Karelov maxkarelov

🏠
Working from home
View GitHub Profile
@maxkarelov
maxkarelov / jenkins-create-job.sh
Created December 1, 2015 15:59
create jenkins job from xml file
java -jar jenkins-cli.jar -s http://server create-job newmyjob < myjob.xml
@maxkarelov
maxkarelov / fc-algorithm.cpp
Created April 20, 2015 15:19
Code of FC-Algorithm for Line Clipping in C++ Programming language
void Clip1Left(point &A, point &B, point Pmin, point Pmax)
{
A.y = B.y - (B.x - Pmin.x) * (B.y - A.y) / (B.x - A.x);
A.x = Pmin.x;
}
void Clip1Top(point &A, point &B, point Pmin, point Pmax)
{
A.x = B.x - (B.y - Pmax.y) * (B.x - A.x) / (B.y - A.y);
A.y = Pmax.y;
@maxkarelov
maxkarelov / cohen-sutherland-algorithm.cp
Last active September 14, 2020 22:26
Code of Cohen-Sutherland Algoritm for Line Clipping in C++ Programming language
// Cohen–Sutherland Algorithm
bool clip(point &A, point &B, point Pmin, point Pmax) {
while (true) {
unsigned int C1 = 0;
if (A.x < Pmin.x) C1 += 1;
if (A.x > Pmax.x) C1 += 2;
if (A.y < Pmin.y) C1 += 4;
if (A.y > Pmax.y) C1 += 8;
unsigned int C2 = 0;
@maxkarelov
maxkarelov / measure_img_similarity.py
Created March 20, 2019 00:17 — forked from duhaime/measure_img_similarity.py
Compare image similarity in Python using Structural Similarity, Pixel Comparisons, Wasserstein Distance (Earth Mover's Distance), and SIFT
import warnings
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.stats import wasserstein_distance
from scipy.misc import imsave
from scipy.ndimage import imread
import numpy as np
import cv2
##
curl http://api.ofdx.ru/v1/items?fn=123&fpd=123&fd=123
@maxkarelov
maxkarelov / haproxy.conf
Created August 10, 2018 10:08 — forked from thpham/haproxy.conf
test config haproxy for gRPC loadbalancing
global
tune.ssl.default-dh-param 1024
defaults
timeout connect 10000ms
timeout client 60000ms
timeout server 60000ms
frontend fe_http
mode http
@maxkarelov
maxkarelov / nicol-lee-nicol-algorithm.cpp
Created March 24, 2015 16:25
Code of Nicol Lee Nicol Algorithm for Line Clipping in C++ Programming language
bool clip(point &A, point &B, point Pmin, point Pmax) {
/* 1 */
if (A.x > B.x) std::swap(A, B);
/* 2 */
int C1 = 0;
if (A.x < Pmin.x) C1 += 1;
if (A.x > Pmax.x) C1 += 2;
if (A.y < Pmin.y) C1 += 4;
if (A.y > Pmax.y) C1 += 8;
@maxkarelov
maxkarelov / qr_decode.py
Created May 25, 2017 13:41
decode qr code from photo sample script
from PIL import Image
import zbarlight
file_path = '/Users/ivankumar/Downloads/sample3.jpg'
with open(file_path, 'rb') as image_file:
image = Image.open(image_file)
image.load()
codes = zbarlight.scan_codes('qrcode', image)
print('QR codes: %s' % codes)
@maxkarelov
maxkarelov / gist:b3a799bddcf30dfac45908dfa6f927b3
Created October 19, 2016 18:19
marathon application requests for seed and regular nodes
# SEED NODE
{
"id": "/mycoolenv/cassandra-seed",
"cmd": "chown -R cassandra /var/lib/cassandra && start $SEED",
"cpus": 0.5,
"mem": 400,
"disk": 0,
"instances": 1,
"constraints": [
[
def com(A, B):
result = [[[] for j in range(0, 4)] for i in range(0, 4)]
for i in range(0, 4):
T = []
for j in range(0, 4):
for k in range(0, 4):
result[i][j].append(min(A[i][k], B[k][j]))
return result