Skip to content

Instantly share code, notes, and snippets.

View Svetomech's full-sized avatar

Andrey Belyaev Svetomech

View GitHub Profile
@Svetomech
Svetomech / there_is_no_spoon.cs
Created September 12, 2017 18:50
"There is no Spoon - Episode 1" CodinGame solution
using System;
class Player
{
static void Main(string[] args)
{
int width = int.Parse(Console.ReadLine());
int height = int.Parse(Console.ReadLine());
var grid = new char[width, height];
@Svetomech
Svetomech / vscode-menu_entries.ps1
Created August 28, 2017 22:27
Adds Visual Studio Code menu entries for ALL users (which the installer won't do, even though it requires admin rights)
## Configure Open with VSCode Context Menu ##
# Configure VSCode location
$vscodeLoc = [Environment]::ExpandEnvironmentVariables("%PROGRAMFILES%") + '\Microsoft VS Code\Code.exe'
$regHive = 'HKLM:' # Change this to 'HKCU:' if you only want this for your current user
# Configure Open with VSCode for files
New-Item -Path "$regHive\SOFTWARE\Classes\*\shell\VSCode"
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\*\shell\VSCode" -Name '(Default)' -Type ExpandString -Value 'Open with VSCode'
Set-ItemProperty -LiteralPath "$regHive\SOFTWARE\Classes\*\shell\VSCode" -Name 'Icon' -Type ExpandString -Value "$vscodeLoc"
public static class Populate
{
public static Window[] FromHandles(string[] handles)
{
var windows = new Window[handles.Length];
for (int i = 0; i < windows.Length; ++i)
{
windows[i] = new Window(new IntPtr(Convert.ToInt32(handles[i])));
}
using System.Security.Cryptography;
public byte[] GetPasswordHash(string username, string password, string salt)
{
// get salted byte[] buffer, containing username, password and some (constant) salt
byte[] buffer;
using (MemoryStream stream = new MemoryStream())
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(salt);
using System;
using System.Security.Cryptography;
namespace FDL.Library.Numeric
{
public static class RandomNumber
{
        private static readonly RNGCryptoServiceProvider _generator = new RNGCryptoServiceProvider();
        public static int Between(int minimumValue, int maximumValue)