Skip to content

Instantly share code, notes, and snippets.

View alexb5dh's full-sized avatar
☄️
Creating things

Alex Bespalov alexb5dh

☄️
Creating things
View GitHub Profile
using System.Collections.Generic;
using System.Globalization;
// https://stackoverflow.com/a/7048016/3542151
public class NaturalComparer: IComparer<string>
{
private readonly CultureInfo _culture;
private readonly CompareOptions _compareOptions;
public NaturalComparer(CultureInfo culture = null, CompareOptions? compareOptions = null)
@alexb5dh
alexb5dh / Mouse Clicker.ahk
Last active October 31, 2019 12:52
Repeats clicks while ALT or LMB is held
!LButton::
Loop
{
if not GetKeyState("LButton", "P") && not GetKeyState("LAlt", "P")
break
Click
}
return
taskkill /im explorer.exe /f
start explorer.exe
exit
function areSameWeek(date1, date2){
if (date1.getDate() === date2.getDate())
return true;
if (Math.abs(date1.getDate() - date2.getDate()) >= 7)
return false;
return (date1.getDay() > date2.getDay() && date1.getTime() > date2.getTime()) ||
(date1.getDay() < date2.getDay() && date1.getTime() < date2.getTime());
}
@alexb5dh
alexb5dh / VSCode.reg
Created December 31, 2017 10:33
[VS Code .ahk] VS Code registry entry for .ahk 'Edit Script' #reg #vscode
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit]
@="Edit Script"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit\Command]
@="\"C:\\Program Files\\Microsoft VS Code Insiders\\Code - Insiders.exe\" \"%1\""
@alexb5dh
alexb5dh / Remove Windows Apps.ps1
Last active December 31, 2017 09:55
[Remove Windows Apps] #script
#
# https:#www.howtogeek.com/224798/how-to-uninstall-windows-10s-built-in-apps-and-how-to-reinstall-them/
#
# Uninstall 3D Builder:
Get-AppxPackage *3dbuilder* | Remove-AppxPackage
# Uninstall Calendar and Mail:
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
@alexb5dh
alexb5dh / VSCode.reg
Last active December 31, 2017 09:56
[VSCode protocol] Install VS Code Insiders as 'vscode:' protocol handler #reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\vscode]
@="URL:vscode"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\vscode\shell]
[HKEY_CLASSES_ROOT\vscode\shell\open]
using System;
using System.Collections;
using System.Collections.Generic;
public class DefaultDictionary<TKey, TValue>: IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
{
private readonly Dictionary<TKey, TValue> _dictionary;
public Func<TKey, TValue> ValueFactory { get; }
public class DefaultDictionary<TKey, TValue>: IDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>
{
private readonly Dictionary<TKey, TValue> _dictionary;
public Func<TKey, TValue> ValueFactory { get; }
#region Factory constructors
public DefaultDictionary(Func<TKey, TValue> valueFactory)
{
using System.Threading.Tasks;
public static class TaskExtensions
{
/// <summary>
/// Synchronously awaits task throwing first exception if any instead of <see cref="System.AggregateException"/>.
/// </summary>
public static T Await<T>(this Task<T> task) => task.GetAwaiter().GetResult();
/// <summary>