Skip to content

Instantly share code, notes, and snippets.

@hoangitk
hoangitk / wsl2 gui.md
Created November 16, 2020 09:37
[wsl2 gui] #wsl #wsl2

GUI on Wsl2

How to

  1. INSTALL WSL 2
> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
--Restart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
--Restart
@hoangitk
hoangitk / appcmd_iis.md
Created November 11, 2020 05:17
[appcmd] #cmd #hosting #iis

Appcmd

  • Path: APPCMD=/c/windows/system32/inetsrv/appcmd.exe
  • Stop an apppool:
$APPCMD stop apppool /apppool.name:<your-apppool>
@hoangitk
hoangitk / docker_collection.md
Created November 5, 2020 05:02
[Docker] #docker #collection

Docker

Docker Compose

  • Run
$ docker-compose up -d
  • Exec
$ docker-compose exec devbox-db psql devbox
@hoangitk
hoangitk / Pattern.cs
Created November 4, 2020 03:12 — forked from michael-wolfenden/Pattern.cs
Pattern
public class Pattern<TReturn>
: List<(Type Type, Func<object, TReturn> Map)>
{
public void Add<T>(Func<T, TReturn> map)
=> Add((typeof(T), o => map((T)o)));
public Pattern<TReturn> Default(TReturn val)
{
Add((object _) => val);
return this;
@hoangitk
hoangitk / Chrome_snippets.md
Created October 21, 2020 02:14
[Chrome snippets] #chrome #snippets

Chrome Snippets

List all urls

urls = []
$$('*').forEach(element => {
  urls.push(element.src)
  urls.push(element.href)
  urls.push(element.url)
}); console.log(...new Set(urls)) 
@hoangitk
hoangitk / Git reset remote repo.md
Last active September 18, 2021 05:40
[Git reset remote repo] #git

Re-init

Method 1 - reset, keep history and push --force

git reset --soft HEAD^
git add -A .
git commit -m "rewriting history"
git push --force origin master
@hoangitk
hoangitk / ConsolePortScanner.cs
Created September 11, 2020 06:39 — forked from jonlabelle/ConsolePortScanner.cs
Simple async C# Open Port Network Scanner
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Net.Sockets;
namespace ConsolePortScanner
{
class MainClass
@hoangitk
hoangitk / WSL.md
Last active September 28, 2025 04:28
[WSL] #wsl

WSL

Command

  • List all distros
wsl -l -v
  • List distro location
(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName,BasePath,VhdFileName
@hoangitk
hoangitk / csharp_data_annotation.md
Last active August 20, 2020 04:33
[CSharp_DataAnnotation] #csharp #validation
@hoangitk
hoangitk / LockingConcurrentDictionary.cs
Created July 30, 2020 02:39
[LockingConcurrentDictionary.cs] #csharp #metaprogramming
/*https://github.com/AutoMapper/AutoMapper/blob/18f974a091c910675eea599e6164e8b70ca3aae8/src/AutoMapper/Internal/LockingConcurrentDictionary.cs*/
public struct LockingConcurrentDictionary<TKey, TValue>
{
private readonly ConcurrentDictionary<TKey, Lazy<TValue>> _dictionary;
private readonly Func<TKey, Lazy<TValue>> _valueFactory;
public LockingConcurrentDictionary(Func<TKey, TValue> valueFactory)
{
_dictionary = new ConcurrentDictionary<TKey, Lazy<TValue>>();
_valueFactory = key => new Lazy<TValue>(() => valueFactory(key));