Skip to content

Instantly share code, notes, and snippets.

@yakreved
yakreved / python_junior_practic.py
Last active March 23, 2023 11:52
Задачки для собеседования джуна Python
# Удобно спрашивать через шар экрана и https://www.online-python.com/
import datetime
import math
import json
from typing import List
# 1. Создайте класс Студнт с полями Имя, Факультет, Дата Рождения
class Student():
def __init__(self, name: str, faculty: str, birth_date: datetime.datetime):
self.name, self.faculty, self.birth_date = name, faculty, birth_date
@yakreved
yakreved / Config.py
Created July 25, 2019 13:15
Convert .ini file to python3 config class. One of the answers to question: how to manage configs for python scripts.
import configparser
import os
import re
class Config:
MAX_THREADS = 5
MAX_FILE_SIZE = 2**30
#Other default options
@yakreved
yakreved / Config.py
Created July 25, 2019 13:14
Convert .ini file to python3 config class.
import configparser
import os
import re
class Config:
MAX_THREADS = 5
MAX_FILE_SIZE = 2**30
#Other default options
@yakreved
yakreved / evolution
Created January 14, 2015 01:05
Играл с эволюционным алгоритмом
class Evolution
def initialize(sample_array, quality_func)
#attr_accessor :sample_array, :quality_func, :population_size, :generations_count, :mutations_in_generation
@sample_array = sample_array
@quality_func = quality_func
@population = []
@population_size = 1000
@generations_count = 100
@mutations_in_generation = 100
end
@yakreved
yakreved / mergeparallelsortwinapi
Created December 16, 2014 17:24
mergeparallelsortwinapi
// ShellWinApi.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>
@yakreved
yakreved / shell sort parallel winapi
Created December 5, 2014 21:47
shell sort parallel winapi LAB3 pp
// ShellWinApi.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <iostream>
@yakreved
yakreved / ruby_serialization_speed_test.rb
Created September 4, 2014 03:22
ruby serialization speed test
require 'ruby-prof'
require 'factory_girl'
require 'date'
include FactoryGirl
class User
def initialize
@name= "jkjkj"+Random.rand(200).to_s
@birth = Date.today - Random.rand(3)
@num = Random.rand(600)
@yakreved
yakreved / image_to_text
Created August 24, 2014 04:40
рисуем картинку текстовыми символами
require 'mini_magick'
require 'chunky_png'
def color_to_s(i)
dict = [' ', '.','`', ',', '^', '"',':','-','|','/','+','c','a','w','4','A','%','$','#','@']
dict.reverse!
curr =dict.length
curr = (i/(4294967040/(dict.length-1))).floor if i!=0
dict[curr]
end
@yakreved
yakreved / thm
Last active August 29, 2015 13:59
thm
class Network
attr_accessor :columns, :neurons_in_column,:connectedPerm,:desiredLocalActivity
def initialize
@minOverlap = 5
@neurons_in_column = 5
@connectedPerm = 0.5 #пороговое значение – минимальное значение перманентности при котором синапс считается «действующим» («подключенным»)
@columns = Array.new(10){Column.new}
@desiredLocalActivity = 3 #Параметр контролирующий число колонок победителей после шага подавления.
@yakreved
yakreved / SocketBrowserConnection
Created February 21, 2014 14:31
SocketBrowserConnection
using UnityEngine;
using System.Collections;
//передача сообщений между браузером и сокет сервером через Юнити
using System.Collections.Generic;
using System;
public class SocketBrowserConnection : MonoBehaviour
{