Skip to content

Instantly share code, notes, and snippets.

@ShvedAction
ShvedAction / sum_variation.html
Created February 27, 2015 12:55
algorithmic quest
<script type="text/javascript">
function iteration(max, callback){
var ins = [];
var n = 0;
var r = 0;
do{
while(n <= max){
ins[r] = n;
callback(ins);
n++;
@ShvedAction
ShvedAction / AnonimusObjectGetProperty.cs
Last active February 14, 2024 23:55
C# Reflection: How to get access to property of anonymous objects.
object getProp(object source, string name)
{
var type = source.GetType();
var prop = type.GetProperty(name);
return prop.GetValue(source);
}
@ShvedAction
ShvedAction / GenerateSqlException.cs
Created September 20, 2016 09:16
How to create the mock of SqlException for the unit test.
/// <summary>
/// Create SqlException for unit test(Reflection).
/// taken from: http://blog.gauffin.org/2014/08/how-to-create-a-sqlexception/
/// </summary>
/// <param name="number">This number will be at exception.number</param>
/// <param name="error_message">message</param>
/// <returns>new SqlException</returns>
private SqlException CreateSqlException(int number, string error_message = "the mock error message")
{
var collectionConstructor = typeof(SqlErrorCollection)
@ShvedAction
ShvedAction / MeanCenteredFunction.R
Created October 3, 2016 11:43
Centrated some variable in the data frame around his mean value.
centered <- function(centreted_data_frame, var_names){
centreted_data_frame[var_names] = lapply(var_names, function(name_var){
centreted_data_frame[name_var]-mean(centreted_data_frame[[name_var]])
})
return(centreted_data_frame)
}
@ShvedAction
ShvedAction / Program.cs
Last active May 25, 2020 09:53 — forked from dynajoe/Program.cs
Example C# HTTP Async Server
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace ExampleSimpleWebserver
{
class HttpAsyncServer
{
@ShvedAction
ShvedAction / SequencingPermutation.py
Last active August 1, 2017 13:04
Перечисление перестановок по порядку. Генерация i-ой перестановки без вычисления предыдущих.
import math
class SequencePermutation(object):
def __init__(self, plenty_object, count_item):
self.plenty_object = list(plenty_object)
self.count_item = count_item
self.power_plenty = len(plenty_object)
@staticmethod
@ShvedAction
ShvedAction / BinaryTreeFromBracketsString.py
Last active May 17, 2020 11:43
Биекция правильной скобочной последовательности и бинарного дерева.
class BinaryNode(object):
def __init__(self):
self.right_node = False
self.left_node = False
def to_brackets_string(self):
result = "("
if self.left_node is not False:
result += self.left_node.to_brackets_string()
result += ")"
@ShvedAction
ShvedAction / bon
Last active November 12, 2017 12:54
lightShow
[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,2,0,2,0,4,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,4,0,0,0,4,0,0,0,2,0,2,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,8,0,0,0,0,0,0,0,2,0,2,0,0,
@ShvedAction
ShvedAction / Dockerfile
Created March 20, 2018 20:19
ml docker
FROM ubuntu
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y build-essential cmake gfortran git pkg-config
RUN apt-get install -y python-dev software-properties-common wget vim
RUN apt-get autoremove -y
RUN apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libopencv-dev
@ShvedAction
ShvedAction / largest-area-of-histogram.cpp
Created October 27, 2019 12:41
solution alg problem
template <class T>
class Links{
public:
list<T*> childs;
T *parent;
};
class Node{
public:
Links<Node> rights;