Skip to content

Instantly share code, notes, and snippets.

Avatar

Mykola Balakin nbalakin

View GitHub Profile
@nbalakin
nbalakin / Program.cs
Last active Nov 8, 2019
async + memory leak kind of issue
View Program.cs
class Program
{
private const int MegaByte = 1048576;
public static void Main(string[] args)
{
Console.WriteLine("Process ID: " + Process.GetCurrentProcess().Id);
var tasks = new List<Task>();
for (var i = 0; i < 10; i++)
View IMAX monitoring.cs
class Config
{
public static Int32 GoodRowMin => 6;
public static Int32 GoodRowMax => 9;
public static Int32 GoodColumnMin => 8;
public static Int32 GoodColumnMax => 17;
}
void Main()
{
@nbalakin
nbalakin / CustomAwaiter.cs
Last active Dec 18, 2015
await without TPL
View CustomAwaiter.cs
private async void AsyncMethod() {
var result = await Method();
}
MyTask<Int32> Method() {
return new MyTask<Int32>();
}
// ------------------------------------------------------------
@nbalakin
nbalakin / Calculator.cs
Last active Dec 9, 2015
Simple calculator on C# writen without using any arithmetic operator
View Calculator.cs
var variable = Expression.Variable(typeof(String[]));
Expression.Lambda(
Expression.Loop(
Expression.Block(
new[] { variable },
Expression.Call(typeof(Console), "Write", Type.EmptyTypes, Expression.Constant('>')),
Expression.Call(typeof(Console), "Write", Type.EmptyTypes, Expression.Constant(' ')),
Expression.Assign(variable,
Expression.Call(
Expression.Call(typeof(Console), "ReadLine", Type.EmptyTypes),
View P24GetBalance.cs
void Main() {
GetBalance("card number").Dump();
}
Decimal GetBalance(String card) {
var requestData = GetBalanceRequestData(card);
var request = HttpWebRequest.CreateHttp("https://api.privatbank.ua/p24api/balance");
request.Method = "POST";
using (var stream = request.GetRequestStream())