Skip to content

Instantly share code, notes, and snippets.

View somal's full-sized avatar

Maxim Sokolov somal

View GitHub Profile
@somal
somal / 14.py
Created December 20, 2018 03:10
H.Space
def binary_search(i,j,array, value):
if j>i:
return -1
c=(i+j)//2
if array[c]==value:
return c
elif array[c]<value:
return binary_search(i, c-1, array, value)
else:
return binay_search(i+1, c, array, value)
@somal
somal / alert.py
Created February 15, 2017 06:36
Alerting when internet is unavailable
import os
import pip
import time
import importlib
from pathlib import Path
def import_or_install(package):
try:
module = importlib.import_module(package)
@somal
somal / Google_search.py
Created November 12, 2016 12:14
Python file which search URL on pdf files using Google
import csv
from googleapiclient.discovery import build
def google_results_count(query, start):
service = build("customsearch", "v1", developerKey="AIzaSyCAQ6fo0q5CiOdZ4dhoTyNeYAXWrZOvJtg")
result = service.cse().list(
q=query,
fileType='pdf',
import cv2
def clearCapture(capture):
capture.release()
cv2.destroyAllWindows()
def countCameras():
n = 0
for i in range(10):
try:
import numpy as np
import cv2
cap = cv2.VideoCapture(1)
fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(True):
# Capture frame-by-frame
ret, frame = cap.read()