Skip to content

Instantly share code, notes, and snippets.

View poychang's full-sized avatar
🌠
Magic Transforms the World

Poy Chang poychang

🌠
Magic Transforms the World
View GitHub Profile
@poychang
poychang / Visual Studio Code - Dark.ps1xml
Last active October 11, 2018 05:52 — forked from stuartleeks/Visual Studio Code - Dark.ps1xml
Powershell ISE theme - VS Code Dark
<?xml version="1.0" encoding="utf-16"?>
<StorableColorTheme xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Keys>
<string>ErrorForegroundColor</string>
<string>ErrorBackgroundColor</string>
<string>WarningForegroundColor</string>
<string>WarningBackgroundColor</string>
<string>VerboseForegroundColor</string>
<string>VerboseBackgroundColor</string>
<string>DebugForegroundColor</string>
@poychang
poychang / README.md
Last active August 29, 2019 09:25 — forked from doggy8088/settings.json
Poy Chang 的 VSCode 使用者設定檔

editor

  • "editor.minimap.enabled": true
    • 在捲軸上開啟 MiniMap 功能。
  • "editor.minimap.renderCharacters": false
    • 如果開啟 MiniMap 的話,預設會顯示實際字元 (字超小),根本看不清楚。
    • 將這個設定關閉,就會改顯示彩色區塊而已,這會讓 VSCode 反應速度更快。

files

@poychang
poychang / ThreadLock.cs
Last active August 14, 2018 03:28
[執行緒同步資源鎖定 lock / SyncLock 範例] #dotnet
// REF: [C#.NET][Thread] 執行緒同步資源鎖定 lock / SyncLock
// https://dotblogs.com.tw/yc421206/2011/01/07/20624
private static List<Thread> _threads = new List<Thread>();
private static object _thisLock = new object();
static void Main()
{
for (int i = 0; i < 5; i++)
{
@poychang
poychang / DictionaryAddRange.cs
Last active August 9, 2018 05:06
[合併 2 個 Dictionary] 擴增 Dictionary 的方法,使之可以合併 2 個 Dictionary 物件 #dotnet
void Main()
{
Dictionary<string, string> dictionary1 = new Dictionary<string, string>() { { "1", "A" }, { "2", "A" } };
Dictionary<string, string> dictionary2 = new Dictionary<string, string>() { { "2", "A" }, { "3", "A" } };
dictionary1.AddRange(dictionary2).Dump();
}
public static class DExtension
{
@poychang
poychang / Groping.cs
Last active August 8, 2018 09:28
[利用 LINQ GroupBy 快速分組歸類] 指定欄位將清單做分組,如同 SQL 語法中的 GROUP BY #dotnet #csharp
void Main()
{
var data = new List<DemoModel>() {
new DemoModel{ Status ="A", Name ="1" },
new DemoModel{ Status ="A", Name ="2" },
new DemoModel{ Status ="B", Name ="3" },
new DemoModel{ Status ="C", Name ="4" },
new DemoModel{ Status ="B", Name ="5" }
};
// Original:
@poychang
poychang / Startup.cs
Last active August 8, 2018 09:17 — forked from regisdiogo/Startup.cs
[設定 ASP.NET Core 可以序列化 Enum]- 修改 MVC 的 Json 序列化設定,使之可以將 Enum 序列化成文字併忽略 null 值 #dotnet #csharp
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
}
@poychang
poychang / SampleService.cs
Created July 17, 2018 06:51
[C# 物件自行建立自己的單例] 透過這個寫法可以讓物件自己建立出自己的單例,或許可以叫做 Self Singleton 自體單例 #dotnet #csharp
void Main()
{
SampleService.Instance.WhoAmI();
SampleService.Instance.WhoAmI();
}
// Define other methods and classes here
public class SampleService {
private static SampleService instance;
@poychang
poychang / SampleService.ts
Created July 17, 2018 03:18
TS/JS 迭代器範例
class SampleService {
prizes = [{ numberOfWinner: 1, prizeItem: '獎項1' }, { numberOfWinner: 1, prizeItem: '獎項2' }];
drawPrize: Iterator<any>;
*GetDrawPrize() {
for (let i = 0; i < this.prizes.length; i++) {
yield this.prizes[i];
}
}
@poychang
poychang / Singleton.js
Last active July 12, 2018 08:37
[一種 JavaScript 的 Singleton 寫法] 就使用上來說沒有 new 的動作,且語意上可以通 #javascript #typescript
export default class Singleton {
static instance;
constructor(){
if(Singleton.instance){
return Singleton.instance;
}
Singleton.instance = this;
}
@poychang
poychang / iterm2-solarized.md
Created June 2, 2018 15:26 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k