Skip to content

Instantly share code, notes, and snippets.

View solesensei's full-sized avatar
on a coffee break

Dima Goncharenko solesensei

on a coffee break
View GitHub Profile
@solesensei
solesensei / mirror.cpp
Last active April 3, 2019 08:06
Mash#1 mirror by SoleSensei
Image mirror(const Image& src_image, const int radius)
{
Image res_image{src_image.n_rows + 2*radius, src_image.n_cols + 2*radius};
for(ssize_t i = 0; i < res_image.n_rows; ++i)
for(ssize_t j = 0; j < res_image.n_cols; ++j){
auto x = i - radius;
auto y = j - radius;
if(x >= src_image.n_rows)
x = 2*(src_image.n_rows-1) - x;
if(y >= src_image.n_cols)
@solesensei
solesensei / Strassen_algorithm.cpp
Last active April 3, 2019 08:06
Shtrassen algorithm of matrices multiplication by SoleSensei
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ofstream fc("mtrC.txt");
ifstream fa("mtrA.txt");
ifstream fb("mtrB.txt");
@solesensei
solesensei / sky_fragment.glsl
Last active April 3, 2019 08:05
skybox openGL (SoleSensei)
#version 330 core
out vec4 FragColor;
in vec3 TexCoords;
uniform samplerCube skybox;
void main()
{
FragColor = texture(skybox, TexCoords);
@solesensei
solesensei / MathPhys13.pdf
Last active January 11, 2018 17:00
Equations of Mathematical Physics. 13
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
  1. Целями стандарта являются (отметьте правильное)
  • +Соответствие качества современному уровню развития технологий
  • +Защита потребителя
  • Лоббирования национальные интересов
  • +Защита инвестиций
  • +Совместимости и взаимозаменяемости собъектами стандартизации той же категории
  • Продвижение продуктов на рынке
  • +Единства измерений
  • +Обеспечение безопасности объекта стандартизации для окружающей среды

@solesensei
solesensei / Travelling Salesman Problem.pdf
Last active November 26, 2018 20:42
Travelling Salesman Problem TeX ( Задача Коммивояжера)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@solesensei
solesensei / prolog_func.pl
Last active April 3, 2019 08:03
Some useful basic Prolog functions by SoleSensei
% Some useful basic Prolog functions
% CMC MSU, 7 sem
% ? member(X, Y) - check if element X is in list Y
member(X, [X|L]).
member(X, [Y|L]) :- member(X, L)
% ? concat(L1,L2,L3) - concatenate lists L3 = L1L2
concat(L1, [], L1).
concat(L1, [X|L2], [X|L3]) :- concat(L1,L2,L3)
@solesensei
solesensei / interactive_input.py
Last active April 3, 2019 07:57
Python script which make you able to edit stdout printed text
# Script make you able to edit printed text
# stdin and stdout at the same time
# https://asciinema.org/a/238478
# https://gist.github.com/SoleSensei/05a97bbe8b75cd2368a8e6d5e00d6047
import sys
from getch import getch
def flush_append(char):
# just append char to the end
sys.stdout.write(char)
@solesensei
solesensei / detect_day_night.py
Last active April 19, 2019 08:07
Simple script to detect time of day on images
import os
import cv2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# ------------- Parametrs -------------
img_root = "/mnt/w/prj/data/bdd100k/"
csv_new = "bdd100k_train.csv"
col_names = ['image_filename', 'lighting', 'pixels_light']
@solesensei
solesensei / lru_cache.py
Last active February 17, 2020 11:00
LRU cache decorator | Async LRU cache decorator | Python 3.7
from functools import wraps
def lru_cache(maxsize=None):
_cache = {}
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
key = tuple(args) + tuple(sorted(kwargs.items()))