Skip to content

Instantly share code, notes, and snippets.

@relyky
relyky / TextFiled.input.html
Created June 9, 2022 04:20
CSS, TextField, 以 Tailwind CSS 為基底實作 Material UI TextField。
<!--
Material UI Textfield</h3>
以 Tailwind CSS 為基底實作 Material UI TextField。<br/>
ref→[Material UI Textfield - By wan54](https://tailwindcomponents.com/component/material-ui-textfield-1)
-->
<!DOCTYPE html>
<html>
<head>
@relyky
relyky / AjaxValidateAntiForgeryTokenAttribute.cs
Created April 8, 2022 02:39
MVC5, AjaxWebApi, AjaxValidateAntiForgeryToken, AntiForgery, with axios
using System;
using System.Net;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using YourProject.DB;
using YourProject.Models;
namespace YourProject
{
@relyky
relyky / Ubunt_Linux.sh
Last active July 12, 2022 10:10
Ubuntu/Linux 常用指令
§§ Ubuntu/Linux 常用指令
## su
切換成 super user。
## sudo
## ls: 列出檔案清單
ls -l
列出現在目錄的檔案清單與授權授權狀況。
ls -la
@relyky
relyky / GenerateBig5File.cs
Last active February 24, 2023 05:34
NET6, Encoding, Big5, No data is available for encoding 950, MemoryStream, FileStream
void GenerateBig5File(List<YourInfo> dataList)
{
try
{
// register and get Big5 Encoding
System.Text.Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // 註冊Big5等編碼
Encoding big5Enc = Encoding.GetEncoding(950);
//## 暫寫入記憶體檔
using var ms = new MemoryStream();
@relyky
relyky / new-eventlog.ps1
Last active August 25, 2023 04:42
PowerShell, 常用指令, sc.exe, smtp
### 用 PowerShell 建立新的 Eventlog
# ※需有管理員權限才能建立 EventLog。
New-EventLog -source MyEventSource -LogName MyApplication
@relyky
relyky / GenShortTicket.cs
Last active February 11, 2022 08:30
short ticket, 產生短期門票
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace conShortSession
{
class Program
@relyky
relyky / ServiceActivator.cs
Last active January 12, 2022 09:41
.NET6, IServiceProvider, ServiceActivator, 手動注入物件
using Microsoft.Extensions.DependencyInjection;
using System;
namespace Vista.Biz.AOP
{
/// <summary>
/// Add static service resolver to use when dependencies injection is not available
/// ref → [Resolving instances with ASP.NET Core DI in static classes](https://www.davidezoccarato.cloud/resolving-instances-with-asp-net-core-di-in-static-classes/)
/// 請在 Startup 把 IServiceProvider 註冊進來使用。
/// </summary>
@relyky
relyky / singleton.html
Created December 9, 2021 09:21
html5, 判斷介面已過期,同時開啟多個 tabpage 時只留用最新開啟的介面。expires UI, tabpage
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<p id="message">Click on this document to give it focus.</p>
@relyky
relyky / AesExample.cs
Last active December 29, 2021 09:28
.NET6, Aes 範例, System.Security.Cryptography, Cypher, 加密, Encryption
///
/// ref->[Aes 類別](https://docs.microsoft.com/zh-tw/dotnet/api/system.security.cryptography.aes?view=net-6.0)
///
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
@relyky
relyky / JwtHelper.apply.cs
Last active December 3, 2021 01:20
JWT helper, jose-jwt 範例
record MyInfo
{
public string foo { get; set; }
public string bar { get; set; }
public decimal abc { get; set; }
}
var info = new MyInfo {
foo = "FOO 123.456",
bar = "我是中文字",