Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Stay Home & Be Health

Poy Chang poychang

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

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

Installation

@poychang
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
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.");
Console.WriteLine();
var instanceWithCtor1 = SampleServiceWithCtor.SelfInstance("Poy Chang");
var instanceWithCtor2 = SampleServiceWithCtor.SelfInstance("Poy Chang");
@poychang
poychang / WmiSearcher.cs
Created Jun 15, 2020
[WMI Searcher] 返回容易存取的物件
View WmiSearcher.cs
void Main()
{
GetComponent("Win32_PhysicalMemory")
.Select(p => p.ToObject<Win32_PhysicalMemory>())
.ToList()
.ForEach(item => Console.WriteLine(item.Manufacturer));
}
/// <summary>
/// 取得指定硬體設備類別的所有屬性資料
@poychang
poychang / README.md
Created Mar 25, 2020 — forked from magnetikonline/README.md
PowerShell Import-Module with .ps1 quirk.
View README.md

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!

Example

We have two files callme.ps1 and functions.ps1:

functions.ps1:

@poychang
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
poychang / github-markdown.css
Created Dec 20, 2019
Markdown to HTML style sample
View github-markdown.css
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAA
@poychang
poychang / embedded-file-viewer.md
Created Dec 5, 2019 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive
View embedded-file-viewer.md

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@poychang
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: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@poychang
poychang / How to generate Google API keys.md
Created Jun 27, 2019
[如何產生上傳 Chrome Web Store 的 API 金鑰等資訊] 可取得 Travis CI 處理自動化上架時,需要的 CLIENT_ID、CLIENT_SECRET 和 REFRESH_TOKEN 資訊
View How to generate Google API keys.md