Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1B
- Decimal:
27
I ran into a problem with python where a file I wanted to read in and parse contained unexpected non-UTF-8 encoded characters. I am certain there are many ways to solve this problem, but capturing my quick and dirty appraoch below for posterity.
^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|[\xEE-\xEF][\x80-\xBF]{2}|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$
WSA or Windows Subsystem for Android is a Tool that allows Windows to run Android Apps directly without using any emulator. The problem is Windows Subsystem for Android is currently only available through preview via the Beta Channel of the Windows Insider Program. But if you follow my guide, you don't have to be in Windows Insider Program to try it out. The only thing you need is Windows 11 installed and some patience.
#LINQPad optimize+ | |
BenchmarkRunner.Run<BenchmarkJob>(); | |
[SimpleJob(RunStrategy.ColdStart, targetCount: 10)] | |
[MemoryDiagnoser] | |
public class BenchmarkJob | |
{ | |
[Benchmark] | |
public void Method1() |
You can download whole courses from an array of tutorial sites with the CLI tool youtube-dl
. In the example further down I'm using my Pluralsight account to get videos from a course at their site. Here is a list of all supported sites that you can download from with this tool
The flags you have to supply may vary depending on which site you make a request to.
You can get a free 3 month trial to Pluralsight by signing up for free to Visual Studio Dev Essentials
public static class ThenExtension | |
{ | |
/// <summary> | |
/// "然後呢"擴充方法 | |
/// </summary> | |
/// <typeparam name="T">原本的物件型別</typeparam> | |
/// <param name="instance">原本的物件</param> | |
/// <param name="fn">然後你要執行什麼,並回傳變更後的物件</param> | |
/// <returns>原本的物件,可能會變更原本物件的屬性值</returns> | |
public static T Then<T>(this T instance, Func<T, T> fn) => fn(instance); |
void Main() | |
{ | |
var instance1 = SampleService.Instance; | |
var instance2 = SampleService.Instance; | |
Console.WriteLine(instance1.WhoAmI().Equals(instance2.WhoAmI()) ? "It's the same instance." : "It's NOT the same instance."); | |
Console.WriteLine(); | |
var instanceWithCtor1 = SampleServiceWithCtor.SelfInstance("Poy Chang"); | |
var instanceWithCtor2 = SampleServiceWithCtor.SelfInstance("Poy Chang"); |
void Main() | |
{ | |
GetComponent("Win32_PhysicalMemory") | |
.Select(p => p.ToObject<Win32_PhysicalMemory>()) | |
.ToList() | |
.ForEach(item => Console.WriteLine(item.Manufacturer)); | |
} | |
/// <summary> | |
/// 取得指定硬體設備類別的所有屬性資料 |
Well, not so much a quirk - but an interesting anti-pattern I found in some (poor quality) PowerShell. Documenting the "how and why" so I can refer to it again if needed!
We have two files callme.ps1
and functions.ps1
:
functions.ps1
:
// 搭配 Quokka.js 來測試會比較方便看 | |
function* rangeGenerator(start, end) { | |
for (let i = start; i < end; i++) yield i; | |
} | |
function range(start, end) { | |
return Array.from({ length: end - start }, (_, i) => i + start); | |
} |