Skip to content

Instantly share code, notes, and snippets.

View cdcd72's full-sized avatar

Neil cdcd72

View GitHub Profile
@cdcd72
cdcd72 / 2019-https-localhost.md
Created January 10, 2024 03:32 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"console_title_template": " {{ .Folder }} :: {{if .Root}}Admin{{end}}",
"palette": {
"main-bg": "#24283b",
"terminal-blue": "#9cbbff",
"terminal-red": "#ff9797",
"terminal-yellow": "#ffffb9",
"terminal-green": "#d2ffa1",
"terminal-magenta": "#dcb5ff",
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
@cdcd72
cdcd72 / DefaultENG.ps1
Created November 24, 2021 14:55
Change windows default input to ENG.
# From https://blog.miniasp.com/post/2020/03/19/Devs-must-setup-multi-language-input-method
$UserLanguageList = New-WinUserLanguageList -Language "zh-TW"
$UserLanguageList.Add("en-US")
Set-WinUserLanguageList -LanguageList $UserLanguageList -Force
Set-WinDefaultInputMethodOverride -InputTip "0409:00000409"
@cdcd72
cdcd72 / Builder.ts
Created November 17, 2020 09:06
Builder Pattern in TypeScript
// 假期建造者 - Builder
export interface VocationBuilder {
/**
* 設定開始日期
* @param {Date} date?
* @returns VocationBuilder
*/
setBeginDate(date?: Date): VocationBuilder;
@cdcd72
cdcd72 / DeployAsWindowsService.ps1
Created April 10, 2020 09:25
.Net core worker service deploy as windows service & control windows service script.
# Build and Publish Application
dotnet build
dotnet publish -c Release -o "PathToPublish"
# Create ServiceName Service
sc.exe create ServiceName binpath="PathToPublish\ServiceName.exe"
@cdcd72
cdcd72 / HtmlEncoder.js
Created March 27, 2020 06:38
HtmlEncoder in javascript
// HtmlEncode
function HtmlEncode(str) {
// 創造 div 元素
var element = document.createElement('div');
// 創造文字節點放文字
element.appendChild(document.createTextNode(str));
// https://developer.mozilla.org/zh-TW/docs/Web/API/Element/innerHTML
@cdcd72
cdcd72 / Singleton.ts
Last active November 17, 2020 09:07
Singleton Pattern in TypeScript
class Singleton {
private static instance: Singleton;
private constructor() { }
/**
* 取得實例
* @returns Singleton
*/