Skip to content

Instantly share code, notes, and snippets.


Sergey Kostrukov kostrse

View GitHub Profile
kostrse /
Last active Sep 27, 2021
Mandelbrot on GPU (MATLAB gpuArray and Python cupy)
kostrse / rxjs-reconnect.ts
Last active Sep 2, 2017
RxJS subscription reconnect
View rxjs-reconnect.ts
import { Observable, ObservableInput } from 'rxjs/Observable';
import { OuterSubscriber } from 'rxjs/OuterSubscriber';
import { InnerSubscriber } from 'rxjs/InnerSubscriber';
import { Operator } from 'rxjs/Operator';
import { subscribeToResult } from 'rxjs/util/subscribeToResult';
import { Observer } from "rxjs/Observer";
import { Subscriber } from "rxjs/Subscriber";
import { Unsubscribed } from './Unsubscribed';
import 'rxjs/add/observable/empty';
import 'rxjs/add/observable/of';
kostrse / NetFxRuntimeVersion.fsx
Last active Mar 18, 2017
Determine .NET runtime
View NetFxRuntimeVersion.fsx
open System
open System.Reflection
let getMethod (bindingFlags: BindingFlags) (methodName: string) (t: Type): MethodInfo option =
if t <> null then
Some (t.GetMethod(methodName, bindingFlags))
let privateMethod (methodName: string) (t: Type) =
View CheckResponseTime.ps1
$n = 100; $sum = 0; for ($i=0; $i -lt $n; $i++) { $sum = $sum + (Measure-Command -Expression { Invoke-WebRequest -Uri $url }).Milliseconds }; $sum / $n
View AsyncThrowsTest.cs
static async Task FailsAsync(bool shouldFail)
if (shouldFail)
throw new ApplicationException("Custom exception.");
await Task.CompletedTask;
static Task Fails(bool shouldFail)
kostrse / wildcards.scala
Last active Feb 27, 2016
Wildcard search on Scala
View wildcards.scala
object Program {
val testText = "The quick brown fox jumps over a lazy dog."
val testPattern = "fox * over"
def main (args: Array[String]) {
|Text: $testText
kostrse / CircularQueue.cs
Last active Feb 27, 2016
Interview questions
View CircularQueue.cs
public class CircularQueue
// Motivation:
// We do not store count of items in the queue to avoid mutual blocking of enqueue and dequeu operaions.
// In the current implementation enqueue and dequeue do not block each other,
// but simultaneous calls of the same operations will be blocking.
// Alos we allocate array with size N + 1 to the logical capacity of the queue N,
// this is made to distinguish between cases when the queue is empty or full
View StateSwitch.cs
public class StateSwitch
private readonly Action enterAction;
private readonly Action leaveAction;
private readonly bool leaveOnSuspend;
private uint counter;
private bool entered;
kostrse / queens.cs
Last active Aug 29, 2015
Queens Puzzle
View queens.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms.Maths
public struct Queen
kostrse / hashcode.cs
Last active Aug 29, 2015
GetHashCode for Strings
View hashcode.cs
public static class StringHashCodeExtensions
public static int GetHashCodeJava(this string value)
if (value == null)
throw new ArgumentNullException("value");
int hashCode = 0;
for (int i = 0; i < value.Length; i++)