Clean the repository of unnecessary comments and produce a Markdown check-list for manual review of any comments that remain.
Follow the high-level algorithm below without any parallelization.
""" | |
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 |
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.
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:
ssh-agent
from Windows Services:Services
in the Start Menu
or Win+R
and then type services.msc
to launch the Services window;OpenSSH Authentication Agent
in the list and double click on it;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
.git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
; 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 |
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.
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) | |
{ |
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) | |
{ |
readonly HttpClient http = new HttpClient(); | |
async Task<DownloadResult[]> DownloadUrlsAsync(string path) => | |
await Task.WhenAll(File.ReadLines(path).Select(DownloadAsync)); | |
async Task<DownloadResult> DownloadAsync(string url) | |
{ | |
var time = Stopwatch.StartNew(); | |
try |
// https://stackoverflow.com/questions/46467275/weird-stack-trace-growth-with-async-await-and-taskcompletionsource | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.Serialization; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.Threading; | |
using System.Threading.Tasks; |