Skip to content

Instantly share code, notes, and snippets.

@vchirikov
vchirikov / vscode-keybindings-alt+hjkl-zation.py
Created December 9, 2020 09:21 — forked from 3v1n0/vscode-keybindings-alt+hjkl-zation.py
Make VSCode default key-bindings more HJLK friendly using Alt to alternate to them
#/usr/bin/python3
import json
import sys
import os
import re
import copy
input = sys.argv[1]
@vchirikov
vchirikov / Benchmark.md
Created March 22, 2020 19:26 — forked from buybackoff/Benchmark.md
Avx2/branch-optimized binary search in .NET

Binary search is theoretically optimal, but it's possible to speed it up substantially using AVX2 and branchless code even in .NET Core.

Memory access is the limiting factor for binary search. When we access each element for comparison a cache line is loaded, so we could load a 32-byte vector almost free, check if it contains the target value, and if not reduce the search space by 32/sizeof(T) instead of 1 element.

AVX512 with _mm256_cmpge_epi64_mask instruction should improve it even more, but it is not available on .NET yet.

Results for long. Searching [0,1,2,3,...] in [0,2,4,6,...] array (50% hit rate)

SearchBench

@vchirikov
vchirikov / index.html
Created March 19, 2020 19:30 — forked from SQL-MisterMagoo/index.html
Monitor Blazor WASM loading and report errors
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Blazor Loading</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
</head>
@vchirikov
vchirikov / _notes.md
Created March 12, 2020 06:56
AppDomainManager Injection

Let's turn Any .NET Application into an LOL Bin

We can do this by experimenting with .config files.

Many defenders catch/detect files that are renamed, they do this by matching Original Filename to Process Name

In this example, we don't have to rename anything. We simple coerce a trusted signed app to load our Assembly.

We do this by directing the application to read a config file we provide.

@vchirikov
vchirikov / ReflectionVsTypeloader.cs
Created January 24, 2020 22:58 — forked from ilmax/ReflectionVsTypeloader.cs
Reflection vs TypeLoader
void Main()
{
BenchmarkRunner.Run<TypeBenchmark>();
BenchmarkRunner.Run<FieldsBenchmark>();
BenchmarkRunner.Run<PropertiesBenchmark>();
BenchmarkRunner.Run<MethodsBenchmark>();
}
// Define other methods and classes here
[MemoryDiagnoser]
@vchirikov
vchirikov / dotnetlayout.md
Created October 7, 2018 17:05 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/