Skip to content

Instantly share code, notes, and snippets.

@fengli320
fengli320 / download-install-wsl-linux.txt
Created October 9, 2024 00:34 — forked from vheidari/download-install-wsl-linux.txt
how to download and install manually wsl2, and linux distor on windows
Manually download Windows Subsystem for Linux distro packages:
# @link: https://docs.microsoft.com/en-us/windows/wsl/install-manual#installing-your-distro
Windows Subsystem for Linux Installation Guide for Windows 10:
# @link: https://docs.microsoft.com/en-us/windows/wsl/install-win10#set-your-distribution-version-to-wsl-1-or-wsl-2
Updating Wsl :
Download Msi Wsl update package from below link then install it :
@link : https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@fengli320
fengli320 / docker-wsl2-setup.sh
Created August 8, 2023 09:33 — forked from Athou/docker-wsl2-setup.sh
install docker in Debian 11/WSL2 without Docker Desktop
# install docker in Debian 11/WSL2
# uses systemd-genie since docker requires systemd but it's not available for WSL
# this is an alternative to Docker Desktop
# prerequisites
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ca-certificates curl wget gnupg lsb-release apt-transport-https
# systemd-genie requires dotnet runtime, add Microsoft repo
@fengli320
fengli320 / gist:ec8bb7fdd260bd8350583cc4b9a7d0a5
Created June 11, 2023 10:34 — forked from Shazwazza/gist:7147978
How to inspect assemblies before including them in your application with reflection
public class PackageBinaryInspector : MarshalByRefObject
{
/// <summary>
/// Entry point to call from your code
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dllPath"></param>
/// <param name="errorReport"></param>
/// <returns></returns>
/// <remarks>
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace StateMachineConceptual
{
class Program
{
static async Task Main()
{
@fengli320
fengli320 / Fibers.cs
Created June 3, 2022 06:50 — forked from Horusiath/Fibers.cs
Minimal example of working async method builder
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Threading;
namespace Fibers
{
public struct AsyncFiberMethodBuilder<T>
{
private Fiber<T>? fiber;
@fengli320
fengli320 / introrx.md
Created August 15, 2021 07:19 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
async def main():
coroutine1 = do_some_work(1)
coroutine2 = do_some_work(2)
coroutine3 = do_some_work(4)
tasks = [
asyncio.ensure_future(coroutine1),
asyncio.ensure_future(coroutine2),
asyncio.ensure_future(coroutine3)
]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ctypes import *
from ctypes.wintypes import *
INVALID_HANDLE_VALUE = -1
CREATE_UNICODE_ENVIRONMENT = 0x00000400
@fengli320
fengli320 / UnitTests.cs
Created April 21, 2021 00:30 — forked from StephenCleary/UnitTests.cs
How StartNew responds to CancellationToken
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class StartNewCancellationTokenUnitTests
{
[TestMethod]
public void CancellationTokenPassedToStartNew_CancelsTaskWithTaskCanceledException()