Skip to content

Instantly share code, notes, and snippets.

View yevhen's full-sized avatar
🇺🇦

Yevhen Bobrov yevhen

🇺🇦
View GitHub Profile
@yevhen
yevhen / asyncio_loop_in_thread.py
Created November 23, 2023 19:33 — forked from dmfigol/asyncio_loop_in_thread.py
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@yevhen
yevhen / 00 Dealing elements.md
Created September 11, 2021 10:28 — forked from ericnormand/00 Dealing elements.md
440 PurelyFunctional.tv Newsletter

Dealing elements

There's a function in clojure.core called partition-all. It creates subsequences of a given maximum size.

(partition-all 3 [1 2 3 4 5 6 7 8]);=> [[1 2 3] [4 5 6] [7 8]]

Notice that the first sequence gets the first three elements, the second sequence gets the second three elements, etc. We could get the original sequence again by concatenating the sequences back together.

@yevhen
yevhen / MakePowerShellRememberSSHPassphrase.md
Created July 5, 2021 16:45 — forked from danieldogeanu/MakePowerShellRememberSSHPassphrase.md
How to make Powershell remember the SSH key passphrase.

You should not use the Open SSH client that comes with Git for Windows. Instead, Windows 10 has its own implementation of Open SSH that is integrated with the system. To achieve this:

  1. Start the ssh-agent from Windows Services:
  • Type Services in the Start Menu or Win+R and then type services.msc to launch the Services window;
  • Find the OpenSSH Authentication Agent in the list and double click on it;
  • In the OpenSSH Authentication Agent Properties window that appears, choose Automatic from the Startup type: dropdown and click Start from Service status:. Make sure it now says Service status: Running.
  1. Configure Git to use the Windows 10 implementation of OpenSSH by issuing the following command in Powershell:
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
@yevhen
yevhen / capslock_remap_alt.ahk
Created May 28, 2021 21:04 — forked from Danik/capslock_remap_alt.ahk
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; Autohotkey Capslock Remapping Script
; Danik
; More info at http://danikgames.com/blog/?p=714
; danikgames.com
;
; Functionality:
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
; Cursor keys - J, K, L, I
@yevhen
yevhen / A_README.md
Created July 27, 2018 15:07 — forked from gmamaladze/A_README.md
HashSet that preserves insertion order or .NET implementation of LinkedHashSet

HashSet that preserves insertion order or .NET implementation of LinkedHashSet

Many people naively assume an ordinary .NET HashSet preserves insertion order. Indeed HashSet accidentally preserves insertion order until you remove and re-add some elements. There is such a data structure in Java - LinkedHashSet which respects order and has O(1) RW times.

No, I did not find a (working) corresponding implementation in .NET. That's I wrote this one.

The implementation uses linked list in combination with dictionary to define the iteration, ordering and at the same time allow O(1) removal.

The order is not affected if an element is re-inserted into the set it retains it's old position.

@yevhen
yevhen / ComplexTypeConvention.cs
Created March 30, 2018 12:16 — forked from tugberkugurlu/ComplexTypeConvention.cs
Bind complex type objects from body by default on ASP.NET Core 1
using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.ModelBinding;
using System;
namespace Foo.Web.Infrastructure.Conventions
{
public class ComplexTypeConvention : IActionModelConvention
{
public void Apply(ActionModel action)
{
@yevhen
yevhen / ComplexTypeConvention.cs
Created March 30, 2018 12:16 — forked from tugberkugurlu/ComplexTypeConvention.cs
Bind complex type objects from body by default on ASP.NET Core 1
using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.ModelBinding;
using System;
namespace Foo.Web.Infrastructure.Conventions
{
public class ComplexTypeConvention : IActionModelConvention
{
public void Apply(ActionModel action)
{
@yevhen
yevhen / Firewall.cs
Created March 7, 2016 15:25 — forked from ReubenBond/Firewall.cs
Snippet to open firewall ports in Windows.
// NOTE: Add a COM reference to NetFwTypeLib
namespace Site.Setup
{
using System;
using System.Linq;
using NetFwTypeLib;
/// <summary>
@yevhen
yevhen / gist:1731790
Created February 3, 2012 19:04 — forked from joliver/gist:1311195
NServiceBusCommitDispatcher
public sealed class NServiceBusCommitDispatcher : IPublishMessages
{
private const string AggregateIdKey = "AggregateId";
private const string CommitVersionKey = "CommitVersion";
private const string EventVersionKey = "EventVersion";
private const string BusPrefixKey = "Bus.";
private readonly IBus bus;
public NServiceBusCommitDispatcher(IBus bus)
{
public class SomeCommandHandler
{
uow? where are you?
public void Handle(SomeCommand command)
{
var agg = uow.GetById(command.AggId);
agg.Foo();
}
}