Skip to content

Instantly share code, notes, and snippets.

View MykolaBalakin's full-sized avatar

Mykola Balakin MykolaBalakin

View GitHub Profile
@MykolaBalakin
MykolaBalakin / Program.cs
Last active November 8, 2019 10:22
async + memory leak kind of issue
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++)
class Config
{
public static Int32 GoodRowMin => 6;
public static Int32 GoodRowMax => 9;
public static Int32 GoodColumnMin => 8;
public static Int32 GoodColumnMax => 17;
}
void Main()
{
@MykolaBalakin
MykolaBalakin / CustomAwaiter.cs
Last active December 18, 2015 17:16
await without TPL
private async void AsyncMethod() {
var result = await Method();
}
MyTask<Int32> Method() {
return new MyTask<Int32>();
}
// ------------------------------------------------------------
@MykolaBalakin
MykolaBalakin / Calculator.cs
Last active December 9, 2015 13:48
Simple calculator on C# writen without using any arithmetic operator
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),
@MykolaBalakin
MykolaBalakin / P24GetBalance.cs
Last active December 9, 2015 14:11
P24 GetBalance
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())