Skip to content

Instantly share code, notes, and snippets.

Andrew Savinykh AndrewSav

  • New Zealand
Block or report user

Report or block AndrewSav

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AndrewSav
AndrewSav / docker-compose.yaml
Last active Sep 4, 2019
This demonstrates minio client failng to upload large files (when upload time is more than 30 minutes). It is not reporoducable without nginx so this is more likely is niginx problem
View docker-compose.yaml
version: '2.1'
services:
nginx-proxy:
image: jwilder/nginx-proxy:alpine
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
@AndrewSav
AndrewSav / telnet-client.txt
Last active Sep 4, 2019
How to install telnet client on different OS Types
View telnet-client.txt
#alpine
apk -U add busybox-extras
#windows
pkgmgr /iu:"TelnetClient"
#ubuntu
apt update
apt install telnet -y
@AndrewSav
AndrewSav / ReadWriteLock.ps1
Last active Sep 4, 2019
One Writer Multiple readers locking for Powershell. Readers and Writers should agree on `$maxReaders` parameter before hand and use the same one. Call `Lock-Read` or `Lock-Write` to lock and then `Unlock-Read` or `Unlock-Write` to unlock.
View ReadWriteLock.ps1
function WaitAnyMutexes($mutexes, $name, $timeout) {
try {
$result = [Threading.WaitHandle]::WaitAny($mutexes,$timeout)
if ($result -ne [Threading.WaitHandle]::WaitTimeout) {
return @{clean=$true; mutex=$mutexes[$result]; index=$result};
} else {
return $null
}
} catch [System.Threading.AbandonedMutexException]{
return @{clean=$false; mutex=$_.Exception.Mutex; index=$_.Exception.MutexIndex}
@AndrewSav
AndrewSav / GetSteamGuardCode.cs
Last active Sep 4, 2019
Calculates SteamGuard code from your base64 shared secret
View GetSteamGuardCode.cs
string GetSteamGuardCode(string base64SharedSecret)
{
long time = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + 10;
byte[] timeHash = BitConverter.GetBytes(time/30).Reverse().ToArray();
HMACSHA1 hmac = new HMACSHA1(Convert.FromBase64String(base64SharedSecret));
hmac.Initialize();
byte[] hash = hmac.ComputeHash(timeHash);
int b = hash[19] & 0xF;
int codePoint = (hash[b] & 0x7F) << 24 | (hash[b + 1] & 0xFF) << 16 | (hash[b + 2] & 0xFF) << 8 | (hash[b + 3] & 0xFF);
string steamChars = "23456789BCDFGHJKMNPQRTVWXY";
@AndrewSav
AndrewSav / clone-all-twitter-github-repos.ps1
Last active Feb 10, 2017
Clone all github repos in an organisation
View clone-all-twitter-github-repos.ps1
(Invoke-WebRequest "https://api.github.com/orgs/twitter/repos?per_page=200").Content | ConvertFrom-Json | %{ $_.clone_url } | %{ git clone $_}
@AndrewSav
AndrewSav / pln.cs
Last active Apr 18, 2016
TCP Port Listener
View pln.cs
// This is a very basic TCP port listener that allows you to listen on a port range
// If you run this program outside of firewall and run a port scanner inside a firewall
// pointing to the ip address where this program runs, the port scanner will be able you
// to tell which exactly ports are open on the firewall
// This code will run on Windows, but most importantly also on linux.
// DigitalOcean.com has all ports for their VMs open by default. So spin a new VM,
// copy pln.cs in your (root) home folder and then run:
// sudo apt-get update
// sudo apt-get install mono-complete -y
// mcs pln.cs
@AndrewSav
AndrewSav / UwpEventSource.cs
Created Apr 17, 2016
Event Provider sample for Windows IoT
View UwpEventSource.cs
using System.Diagnostics.Tracing;
namespace MyNamespace
{
[EventSource(Name = "MyEwtProvider")]
sealed class UwpEventSource : EventSource
{
public static UwpEventSource Log = new UwpEventSource();
[Event(1, Level = EventLevel.Verbose, Channel = EventChannel.Debug)]
@AndrewSav
AndrewSav / SteamShortcuts.cs
Last active Sep 4, 2019
Creates shortcuts of your whole installed steam library in a folder on your destop
View SteamShortcuts.cs
// Creates shortcuts of your whole installed steam library in a folder on your destop
// Note 1: icons for some games do not get set correctly, but than they do not get set correctly by steam itself either
// Note 2: code heavily depends on the steam interal file formats so this can stop working without notice any time
// Note 3: this code does not have any command line arguments, it tries to detect path to your steam folder
// if it can't feel free to modify it to hardcode the path. Similarily you can change where the shortcuts
// are written to in the code. Sorry, not a user friendly tool at all - you are assumed to be a developer
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@AndrewSav
AndrewSav / gist:db048b4eccedc4cf8211
Last active Aug 26, 2017
How to pin Git Shell to the taskbar (Windows 7/8)
View gist:db048b4eccedc4cf8211
I was looking how to pin Git Shell to the taskbar,
I got this answer from Github support (hope it can help other people) :
Hi Fabien,
Windows is annoying in that it doesn't let you pin certain items to the taskbar.
However, there is a clever way to trick it into allowing you to do this.
1) Right-click on the 'Git Shell' shortcut and go to the 'Target' text box
2) Add the word 'explorer' in front of the line
View JsonCompare.PrintDiff.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace Aghub.WebApi.Tests
{
public class JsonCompare
{
public static void PrintDiff(JToken x, JToken y)
You can’t perform that action at this time.