Skip to content

Instantly share code, notes, and snippets.

View oleksabor's full-sized avatar

oleksii borodai oleksabor

  • Kyiv, Ukraine
View GitHub Profile
@oleksabor
oleksabor / .bashrc
Last active July 6, 2022 15:45
bashrc for Termux on phone
# Shortcuts
alias sd="cd /mnt/sdcard"
alias dl="cd /mnt/sdcard/Download"
alias g="git"
alias gs="git status"
alias gco="git commit"
alias gch="git checkout"
alias h="history"
alias j="jobs"
@oleksabor
oleksabor / program.cs
Last active December 28, 2020 17:59
timezone on Unix can differ per year
using System;
using Newtonsoft.Json;
namespace jsonTimeZone
{
//https://stackoverflow.com/questions/65436081/date-deserialization-difference-between-kestrel-on-windows-and-kestrel-on-macos
class Program
{
static void Main(string[] args)
{
@oleksabor
oleksabor / testV1stringConcat.cs
Last active April 7, 2020 09:01
WriteAsync "performance" test
const int MaxAttempts = 5;
static void Main(string[] args)
{
TestFileWriteAsync();
TestFileWrite();
TestFileWriteViaThread();
Console.ReadLine();
}
private static void TestFileWrite()
@oleksabor
oleksabor / Class1.cs
Last active March 3, 2020 09:30
System.Net.Sockets.Socket.ReceiveFromAsync sample
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@oleksabor
oleksabor / ffcut.sh
Last active May 16, 2020 21:25
bash script to cut mp3 silence at the start and at the end. ffmpeg silencedetect is used
#!/bin/bash
if [ "$1" == "" ]; then
echo "no input file name";
exit 1;
else
mp3file="$1";
fi
@oleksabor
oleksabor / Startup.cs
Last active January 27, 2020 14:00
Using IEnumerable<> configuration class properties in the asp.net core 3.1
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.Configure<Applications>(options => Configuration.GetSection("Applications").Bind(options));
var apps = services.BuildServiceProvider().GetService<IOptionsSnapshot<Applications>>();
if (apps.Value.AppList == null || !apps.Value.AppList.Any())
{
var sample = new Applications();
public class MyController
{
public object Get(string id)
{
return new { Key = id, Value = "val:" + id };
}
}
class Program
{
// Application entry-point
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace binary100KLoader
{
public class GenericResponse<T>
{
private string code = "200";
@oleksabor
oleksabor / mapVirtualKeySample.cs
Last active January 2, 2020 11:03
mapping virtual key codes
static void Main(string[] args)
{
uint[] keys = new uint[] { 56, 82, 79, 77, 72 };
var scanCodes = keys.Select(_ => MapVirtualKey(_, MapVirtualKeyMapTypes.MAPVK_VSC_TO_VK));
Console.WriteLine("mapped `{0}` to `{1}`", AsString(keys), AsString(scanCodes));
Console.WriteLine("done");
Console.ReadLine();
@oleksabor
oleksabor / TokenProvider.cs
Last active November 14, 2019 12:08
how to request the Azure token using IdentityClient
using IdentityModel.Client;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Transport
{