Skip to content

Instantly share code, notes, and snippets.

Avatar

Vlad Kovalev sleemer

View GitHub Profile
@sleemer
sleemer / .editorconfig
Last active Dec 21, 2020
My config files for .net projects
View .editorconfig
# EditorConfig is awesome:http://EditorConfig.org
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
@sleemer
sleemer / gist:f9849b7a8a2c17a30e771df30ed8c55c
Last active Jun 28, 2018
Word frequency counter algorithm based on MemoryMappedFile
View gist:f9849b7a8a2c17a30e771df30ed8c55c
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
namespace WordFrequencyCounter
{
public sealed class WordCounter
{
@sleemer
sleemer / Dockerfile.debug
Last active Jun 6, 2017
Investigation report of how to set up debugging of aspnetcore:2 containerised app in @VScode
View Dockerfile.debug
FROM microsoft/aspnetcore-build:2
ENV NUGET_XMLDOC_MODE skip
WORKDIR /vsdbg
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
unzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg
RUN mkdir /app
@sleemer
sleemer / TwitterListener.cs
Created Nov 22, 2016
Simple sample of using Twitter streaming API using TweetinviAPI
View TwitterListener.cs
using System;
using System.Linq;
using Tweetinvi;
using Tweetinvi.Core.Extensions;
using Tweetinvi.Events;
using Tweetinvi.Models;
public class Program
{
public static void Main(string[] args)
@sleemer
sleemer / algorithms-stack-and-xor-or.cs
Created Nov 11, 2016
Implementation of algorithm that solves 'And-Xor-Or' problem from hackerrank.com
View algorithms-stack-and-xor-or.cs
// https://www.hackerrank.com/challenges/and-xor-or
// Original statement could be simplified: ((M1&M2)^(M1|M2))&(M1^M2) == M1^M2
public int MaxAndOrXor(string input)
{
var numbers = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToArray();
var max = 0;
foreach (var pair in GetSmallestPairs(numbers))
{
@sleemer
sleemer / algorithms-stack-poisoned-plants.cs
Created Nov 8, 2016
Implementation of variation of 'The stock span problem'
View algorithms-stack-poisoned-plants.cs
// https://www.hackerrank.com/challenges/poisonous-plants/submissions/code/31921305
// Stack will be used to track series of plants splitted by the survived plants.
// Stack is a tuple of index of plant and amount of day that it will servive (0 - will live forever).
// eaxamle input: 3 7 1 2 4 8 2 7 9
// serie splitter: | |
// index: 0 1 2 3 4 5 6 7 8
// amount of days: 0 1 0 1 1 1 2 1 1
// maximum: 2
public int PoisonousPlants(string input)
{
@sleemer
sleemer / speaking-wroclaw-dotnet-meetup-3.md
Last active Nov 3, 2016
Notes for my presentation on WroclawDotNetMeetup#3 (03.11.2016)
View speaking-wroclaw-dotnet-meetup-3.md
@sleemer
sleemer / algorithms-stack-largest-rectangle.cs
Last active Oct 31, 2016
C# implementation of algorithm of calculation LargestRectangle
View algorithms-stack-largest-rectangle.cs
/// Description of the problem can be found at https://www.hackerrank.com/challenges/largest-rectangle/editorial
/// As a real use case we could consider usage of this algorithm to find out the largest rectangular subarray containing only ones.
/// For more details go to http://www.drdobbs.com/database/the-maximal-rectangle-problem/184410529
public int LargestRectangle(string input)
{
var heights = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.Concat(new[] { 0 }) // add tail 0 to force calculation when we reach the last element
.ToArray();
var positions = new Stack<int>();
@sleemer
sleemer / networking-tls.md
Last active Oct 11, 2016
Short notes about TLS
View networking-tls.md

TLS provides all protocols above three essential services:

  • Encription. A mechanism to obfuscate what is sent from one computer to another.
  • Authentication. A mechanism to verify the validity of provided identification material.
  • Data integrity. A mechanism to detect a message tampering and forgery.
@sleemer
sleemer / TcpSubscriber.cs
Created Oct 10, 2016
Rx implementation of tcp subscriber of the remote observable sequence.
View TcpSubscriber.cs
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Reactive.Linq;
using Newtonsoft.Json;
public static class TcpSubscriber
{
/// <summary>