Skip to content

Instantly share code, notes, and snippets.

Stay Home & Be Health

Poy Chang poychang

Stay Home & Be Health
View GitHub Profile
poychang /
Created Jul 28, 2021 — forked from edgardo001/
Using youtube-dl to download courses from Pluralsight

Download courses from learning sites with youtube-dl

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


poychang / ThenExtension.cs
Created May 6, 2021
[LINQ 擴充] "然後呢"擴充方法 #C# #dotnet
View ThenExtension.cs
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);
poychang / main.cs
Created Mar 2, 2021
[Self Instance 的寫法] 簡單的 Singleton 寫法 #dotnet #c
View main.cs
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.");
var instanceWithCtor1 = SampleServiceWithCtor.SelfInstance("Poy Chang");
var instanceWithCtor2 = SampleServiceWithCtor.SelfInstance("Poy Chang");
poychang / WmiSearcher.cs
Created Jun 15, 2020
[WMI Searcher] 返回容易存取的物件
View WmiSearcher.cs
void Main()
.Select(p => p.ToObject<Win32_PhysicalMemory>())
.ForEach(item => Console.WriteLine(item.Manufacturer));
/// <summary>
/// 取得指定硬體設備類別的所有屬性資料
poychang /
Created Mar 25, 2020 — forked from magnetikonline/
PowerShell Import-Module with .ps1 quirk.

PowerShell Import-Module with .ps1 quirk

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:


poychang / rangeGenerator.js
Created Mar 4, 2020
[比較 Array 和 Generator 的作法]
View rangeGenerator.js
// 搭配 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);
poychang / github-markdown.css
Created Dec 20, 2019
Markdown to HTML style sample
View github-markdown.css
@font-face {
font-family: octicons-link;
poychang /
Created Dec 5, 2019 — forked from tzmartin/
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')[OFFICE_FILE_URL]

<iframe src='[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>

OneDrive Embed Links

poychang / settings.json
Last active Apr 24, 2020
[Windows Terminal Profiles]
View settings.json
// This file was initially generated by Windows Terminal 0.11.1121.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see:
"$schema": "",
poychang / How to generate Google API
Created Jun 27, 2019
[如何產生上傳 Chrome Web Store 的 API 金鑰等資訊] 可取得 Travis CI 處理自動化上架時,需要的 CLIENT_ID、CLIENT_SECRET 和 REFRESH_TOKEN 資訊
View How to generate Google API