This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<NuGetReference>YamlDotNet</NuGetReference> | |
<Namespace>YamlDotNet.Serialization</Namespace> | |
<Namespace>YamlDotNet.Core</Namespace> | |
<Namespace>System.Security.Cryptography</Namespace> | |
<Namespace>System.Runtime.InteropServices</Namespace> | |
</Query> | |
void Main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, you must get the previous commit sha, the one before the forced push: | |
## Hit through terminal | |
curl -u <username> https://api.github.com/repos/:owner/:repo/events | |
# Then you can create a branch from this sha: | |
## Hit through terminal | |
curl -u <github-username> -X POST -d '{"ref":"refs/heads/<new-branch-name>", "sha":"<sha-from-step-1>"}' https://api.github.com/repos/:owner/:repo/git/refs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Testing Syncthing interaction via REST api from scratch via command line | |
# Make sure you have xml2 and jq: | |
# apt intall xml2 jq | |
# Create docker network for the container instances | |
docker network create syncthing | |
# Create individual directories for each instance | |
mkdir -p syncthing1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Invoke-WebRequest "https://api.github.com/orgs/twitter/repos?per_page=200").Content | ConvertFrom-Json | %{ $_.clone_url } | %{ git clone $_} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
NewerOlder