Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View poychang's full-sized avatar
🏠
Stay Home & Be Health

Poy Chang poychang

🏠
Stay Home & Be Health
View GitHub Profile
@poychang
poychang / settings.json
Last active April 24, 2020 01:09
[Windows Terminal Profiles]
// 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 June 27, 2019 03:52
[如何產生上傳 Chrome Web Store 的 API 金鑰等資訊] 可取得 Travis CI 處理自動化上架時,需要的 CLIENT_ID、CLIENT_SECRET 和 REFRESH_TOKEN 資訊
@poychang
poychang / EnumerateSubDirectories.cs
Last active May 1, 2019 14:04
[取得指定往下第幾層的資料夾路徑] 只取指定層數的資料夾路徑,避免子資料夾路徑太深、太多造成效能問題 #dotnet
using System.IO;
using System.Collections.Generic;
/// <summary>
/// 取得指定往下第幾層的資料夾路徑
/// </summary>
/// <remarks>使用此方法只取指定層數的資料夾路徑,避免子資料夾路徑太深、太多造成效能問題</remarks>
/// <param name="path">根路徑</param>
/// <param name="depth">第幾層的資料夾路徑</param>
/// <returns></returns>
@poychang
poychang / vue.md
Last active November 4, 2019 00:07 — forked from oomusou/vue.md
[Functional Vue Architecture] 你應該用 Functional 的方式來想怎麼寫 Vue #vue

Functional Vue Architecture

Sam Xiao, Feb.18, 2019

Web 所面臨的挑戰

後端 MVC

約在 2015 年,主流的 Web 開發架構仍以後端 MVC 為主:

@poychang
poychang / MultiplyTimeSpan.cs
Last active January 7, 2019 05:43
[時間的乘法運算] #dotnet
void Main()
{
DemoMultiplyTimeSpan();
DemoTimePlusMultiplyTimeSpan();
}
// Define other methods and classes here
void DemoMultiplyTimeSpan()
{
var duration = TimeSpan.FromMinutes(1);
@poychang
poychang / GzipCompressString.cs
Last active January 2, 2019 08:36
[將字串做 Gzip 壓縮/解壓縮] #dotnet
void Main()
{
var rawString = "Hi, my name is Poy Chang. I am currently conducting a project of enterprise app through Angular and .NET Core. As a developer and designer, I believe that keep learning and practicing is the most important thing. Reading, watching movies and traveling are also my favorites in my life.";
var zippedString = GZipCompressString(rawString);
Console.WriteLine($"壓縮結果:\r\n{zippedString}\r\n");
var unzipString = GZipDecompressString(zippedString);
Console.WriteLine($"解壓縮後:\r\n{unzipString}\r\n");
@poychang
poychang / StorePocoObjectToRedis.cs
Last active January 3, 2019 01:00
[將物件做二進位序列化後存至 Redis 中] #dotnet
void Main()
{
//Can StackExchange.Redis be used to store POCO?
//https://stackoverflow.com/questions/27857945/can-stackexchange-redis-be-used-to-store-poco
var connection = ConnectionMultiplexer.Connect("YOUR_REDIS_SERVER_CONNECTION_STRING");
var db = connection.GetDatabase();
var data = new PocoType { Id = 1, Name = "YouNameIt", List = new List<string> { "A", "B", "C" } };
Write<PocoType>(db, data);
Read<PocoType>(db).Dump();
@poychang
poychang / CsvToModel.cs
Last active December 13, 2018 07:25
[將 CSV 轉成 Model] 用最簡單的方式將 CSV 轉成 Model,但要注意 CSV 是否有標頭,以及轉型的問題 #dotnet
void Main()
{
//var content = File.ReadAllLines("YOUR_FILE.csv");
var content = new string[] { "2018/12/13,Data1,100", "2018/12/14,Data2,200", "2018/12/14,Data3,300" };
var models = content
.Select(p => p.Split(','))
.Select(p => new Model
{
Date = DateTime.Parse(p[0]),
Data = p[1],
@poychang
poychang / LinqToCSVHelper.cs
Last active December 3, 2018 00:49
[Linq To CSV] #dotnet
public static class LinqToCSVHelper
{
public static string ToCsv<T>(this IEnumerable<T> items, bool hasHeader = true, bool hasWrapper = false, string separator = ",")
where T : class
{
var csvBuilder = new StringBuilder();
var properties = typeof(T).GetProperties();
var firstLine = hasHeader;
foreach (var item in items)
@poychang
poychang / CheckDotnetHostingBundleVersion.ps1
Created November 23, 2018 01:29
[檢查 IIS 的 .NET Core Hosting Bundle 版本] #powershell
$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core"
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath
$NotInstalled = $True
$DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object {
$NotInstalled = $False
Write-Host "The host has installed $_"
}
If ($NotInstalled) {
Write-Host "Can not find ASP.NET Core installed on the host"
}