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 / Program.cs
Created November 14, 2018 07:53
[查詢 SQL Server 當下連線資訊] #dotnet #mssql
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace SqlConsoleApp
{
internal class Program
{
private static void Main(string[] args)
@poychang
poychang / CorsHandler.cs
Last active November 13, 2018 14:45
[CORS MessageHandler for Web API] #dotnet
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Add to Global.asax -- GlobalConfiguration.Configuration.MessageHandlers.Add(new CorsHandler());
namespace Common.Helpers
{
@poychang
poychang / Convert-PCL-to-Dotnet-Standard.md
Last active November 9, 2018 09:16 — forked from yuv4ik/README.md
[將 PCL 轉換成 .NET Standard] #dotnet #xamarin
@poychang
poychang / updateNpm.bat
Created November 2, 2018 03:42 — forked from johnmcase/updateNpm.bat
Update npm on windows
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1
@poychang
poychang / IsValidJson.cs
Created October 26, 2018 07:46
[檢查字串是否為合法的 JSON 字串] #dotnet
static bool IsValidJson(string input)
{
input = input.Trim();
if ((!input.StartsWith("{") || !input.EndsWith("}")) &&
(!input.StartsWith("[") || !input.EndsWith("]"))) return false;
try
{
JToken.Parse(input);
@poychang
poychang / UriScheme.cs
Last active October 24, 2018 02:38
[URI 的結構與取用方法] #dotnet
void Main()
{
/*
URI 的結構
--------------------------------------------------
* [scheme:]scheme-specific-part[#fragment] 這是基礎結構
* [scheme:][//authority][path][?query][#fragment] 可對 scheme-specific-part 做拆分
* [scheme:][//host:port][path][?query][#fragment] 再對 authority 做次分,可得到最細分的結構
--------------------------------------------------
*/
@poychang
poychang / CheckUri.cs
Created October 24, 2018 02:16
[檢查 URI 的格式是否合法] #dotnet
void Main()
{
var uriList = new List<string>() {
"https://poychang.github.io",
"http://poychang.github.io",
"ftp://poychang.github.io",
"file://localhost/test.txt",
"https://",
"http://",
"ftp://",
@poychang
poychang / Program.cs
Created October 24, 2018 02:09
[.NET Core HttpClient with progress report] 使用 HttpClient 下載檔案時,顯示進度百分比 #dotnet
using System;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace HttpClientProgressReport
{
public class Program
{
@poychang
poychang / console-backup.json
Last active October 11, 2018 07:00
Powershell theme - Monokai Dark
{
"cursor_size": "small",
"font_face": "Lucida Console",
"font_size": "0x14",
"popup_colors": "black,gray",
"dark_gray": "#586e75",
"screen_colors": "gray,black",
"dark_green": "#5a6600",
"command_history_no_duplication": false,
"window_size": "80x25",
@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>