Skip to content

Instantly share code, notes, and snippets.

@guojianwei001
guojianwei001 / rm-commits-from-history.md
Last active September 2, 2022 09:35
Purging a file from your repository's history, i.e. clean all the commits of a file
@guojianwei001
guojianwei001 / BuildInMemoryConfiguration.cs
Last active July 7, 2022 08:33
Create a in-memory json configuraiton that is used to mock IConfiguration.
var inMemorySettings = new Dictionary<string, string>
{
{"Languages:0", "en"},
{"Languages:1", "cn"},
{"Languages:2", "ar"}
{"SectionName:SomeKey", "SectionValue"},
//...populate as needed for the test
};
var configuration = new ConfigurationBuilder()
@guojianwei001
guojianwei001 / aproducer.py
Created June 1, 2022 12:49 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@guojianwei001
guojianwei001 / program.cs
Last active May 30, 2022 13:01
Convert old BeginRead/EndRead asyn method to async/await method; implete a simple FromAsync similar to Task.Factory.FromAsync
#nullable enable
using System;
using System.IO;
using System.Threading.Tasks;
namespace AsyncAwaitPlay
{
class Program
{
/*
<div id='app'></div>
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/react@15.2.1/dist/react.min.js"></script>
<script src="https://unpkg.com/react-dom@15.2.1/dist/react-dom.min.js"></script>
<script src="https://unpkg.com/redux@^3.5.2/dist/redux.min.js"></script>
<script src="https://unpkg.com/react-redux@4.4.5/dist/react-redux.min.js"></script>
<script src="https://unpkg.com/@reactivex/rxjs/dist/global/Rx.js"></script>
<script src="https://unpkg.com/redux-observable/dist/redux-observable.min.js"></script>
<meta charset="utf-8">