Skip to content

Instantly share code, notes, and snippets.

View akulakov's full-sized avatar

andrei kulakov akulakov

  • New York
View GitHub Profile
Espanol - Alice en pais de Maravillas
---
Alice estaba sentada en la orilla de un río con su hermana.
Alicia tenía sueño y estaba aburrida.
Su hermana estaba leyendo un libro sin dibujos.
Alicia pensó que todos los libros deberían tener dibujos.
import numpy as np, os, cv2
from keras.utils import to_categorical
from keras.models import load_model
#reads images from folder (images must be labeled 0.png, 1.png, etc...)
def read_from_folder(folder, pattern, image_number, stop):
images = []
while image_number < stop:
path = folder + pattern + '/casc (' + str(image_number)+ ').png'
import os; img_path = path; assert os.path.exists(img_path), img_path
@akulakov
akulakov / keras_for_juggling2.py
Created February 26, 2018 03:52 — forked from tjthejuggler/keras_for_juggling2.py
keras_for_juggling.py with line 9 changed
import numpy as np, os, cv2
from keras.utils import to_categorical
from keras.models import load_model
#reads images from folder (images must be labeled 0.png, 1.png, etc...)
def read_from_folder(folder, pattern, image_number, stop):
images = []
while image_number < stop:
path = folder + pattern + '/casc (' + str(image_number-119)+ ').png'
img = cv2.imread(path, 0)
@akulakov
akulakov / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/env python3
import sys
import shelve
clusters = []
separated = set()
i2cluster = {} # item to cluster mapping
def bitfunc(x):
return x**4 - 5 * x**2 + 4
def bitfunc_rect(x1, x2):
# print("bitfunc_rect ", x1, x2)
return (x2-x1) * bitfunc(x1)
def bitfunc_recur(steps, x1, x2):
if steps:
step = (x2-x1) / steps
@akulakov
akulakov / gist:9e9d18eeb8db6dc23281
Created October 12, 2014 19:18
Bitfunc: recursive, iterative, compare
(define (bitfunc-recur steps x1 x2)
(define (step) (/ (- x2 x1) steps))
(if (> steps 0)
(+ (bitfunc-rect x1 (+ x1 (step))) (bitfunc-recur (- steps 1) (+ (step) x1) x2))
0))
(define (d x) (exact->inexact x))
(define (bitfunc-iter steps x1 x2)
@akulakov
akulakov / bitwise_and
Last active August 29, 2015 14:07
bitwise and
def binp(x):
print("{:3} {:08b}".format(x, x))
def bitwise_and(a, b):
result = 0
mask = 1
while a and b:
if (a % 2) == (b % 2) == 1:
result += mask
mask <<= 1
@akulakov
akulakov / gist:b6e20ee0ed81c06883e4
Last active August 29, 2015 14:07
bitwise and Ehtesh
# allowed operators:
# - recursion
# - shift
# - add
# - mul
# - div
# - mod
def bitwise_and_1(a, b):
result = 0
index = 0