Skip to content

Instantly share code, notes, and snippets.

@sleemer
sleemer / vs-code-tips-and-tricks-01.txt
Created October 1, 2016 09:56
Using 'VS code - insiders' as a diff tool on my macbook.
1. Update PATH by running command below from vs code:
> Shell command: Install 'code-insiders' command in PATH
2. Open terminal and type
> code-insiders --diff <File1> <File2>
@sleemer
sleemer / stack-of-technologis-to-keep-up.md
Last active October 18, 2016 20:04
Skills and Technology stack, I think, it worth to keep up with. +Useful links.
  1. Computers fundamentals
  2. OS
  • Linux
  • osx
  1. Networking
@sleemer
sleemer / PublisherStatus.cs
Created October 3, 2016 18:48
Basic implementation of TcpPublisher with Rx
public enum PublisherStatus
{
NotRunning,
Listenning,
Publishing,
Stopped,
Failed
}
@sleemer
sleemer / networking-tcp.md
Created October 9, 2016 11:05
Short notes about TCP

Flow Control

Flow control is a mechanism to prevent the sender from overhelming the receiver. rwnd - receive window. Each ACK packet carries latest rwnd value for each side.

Slow-start

cwnd - congestion window. Sender-side limit on the amount of data the sender can have in flight before receiving an acknowledgment (ACK) from the client. cwnd is set up for each TCP connection. Maximum amount of data in flight is the minimum of the rwnd and cwnd.

  • Time to reach the cwnd size of size N: Time = RTT(log(N/initial cwnd)) (RTT - round trip time)

Congestion avoidance

Specifies algorithms for how to grow a window to minimize further packet loss once cwnd is reset.

@sleemer
sleemer / TcpPublisher.cs
Last active October 10, 2016 20:16
Rx implementation of TCP publisher.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Text;
@sleemer
sleemer / RetryWithBackoffStrategy.cs
Last active October 10, 2016 20:15
Rx extension method to retry with delay strategy
using System;
using System.Reactive.Linq;
namespace Common
{
public static class ReactiveExtensions
{
private static Func<int, TimeSpan> DefaultDelayStrategy = n => n == 1 ? TimeSpan.Zero : TimeSpan.FromSeconds(Math.Pow(2, n - 1));
/// <summary>
@sleemer
sleemer / TcpSubscriber.cs
Created October 10, 2016 20:24
Rx implementation of tcp subscriber of the remote observable sequence.
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Reactive.Linq;
using Newtonsoft.Json;
public static class TcpSubscriber
{
/// <summary>
@sleemer
sleemer / networking-tls.md
Last active October 11, 2016 19:56
Short notes about TLS

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 / algorithms-stack-largest-rectangle.cs
Last active October 31, 2016 19:04
C# implementation of algorithm of calculation LargestRectangle
/// 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 / speaking-wroclaw-dotnet-meetup-3.md
Last active November 3, 2016 21:55
Notes for my presentation on WroclawDotNetMeetup#3 (03.11.2016)