Skip to content

Instantly share code, notes, and snippets.

View Orlys's full-sized avatar
🍭

Oz Orlys

🍭
View GitHub Profile
@Orlys
Orlys / MockMailServerAndClient.cs
Created May 6, 2024 02:32
Mock Mail Server & Client
using SmtpServer.ComponentModel;
using SmtpServer;
using MimeKit;
using MailKit.Net.Smtp;
using SmtpServer.Storage;
using System.Buffers;
// **PREREQUIRED: ADD '127.0.0.1 aaa.bbb' to HOSTS file.
sudo apt-get remove software-center && sudo snap remove snap-store && sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y install docker docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin net-tools dnsutils && sudo snap install --classic dotnet-sdk && sudo snap install mqttx && sudo snap install postman && sudo snap install redisinsight && sudo snap install beekeeper-studio && sudo snap install --classic go && sudo snap install --classic codium && codium --force --install-extension Gruntfuggly.todo-tree && codium --force --install-extension hediet.vscode-drawio && codium --force --install-extension mhutchie.git-graph && codium --force --install-extension ms-azuretools.vscode-docker && codium --force --install-extension ms-vscode.makefile-tools && codium --force --install-extension waderyan.gitblame && codium --force --install-extension zaaack.markdown-editor && codium --force --install-extension hashicorp.terraform && codium --force --install-extension muhammad-samm
@Orlys
Orlys / Big5UrlDecoder.cs
Created August 9, 2023 04:39
Big5 Url Decoder
// MIT License
//
// Copyright © 2023 Orlys (Orlys Ma)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@Orlys
Orlys / dnsbl.cs
Created October 3, 2022 06:55
域名黑名單(DNSBL)與垃圾訊息(Spam)檢查
//
// Copyright 2022 Orlys Ma
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@Orlys
Orlys / every8d.cs
Created July 26, 2022 14:57
台灣簡訊商 Every8d 的發信 API 簡易封裝
// Copyright 2022 Orlys Ma
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@Orlys
Orlys / EntityFrameworkHelper.cs
Last active January 18, 2022 17:40
Determines DbContext is Database-First or not.
public static class EntityFrameworkHelper
{
private static readonly System.Reflection.ConstructorInfo s_constructor =
typeof(System.Data.Entity.Infrastructure.UnintentionalCodeFirstException).GetConstructor(System.Type.EmptyTypes);
private static readonly System.Collections.Concurrent.ConcurrentDictionary<System.Type, bool> s_caches =
new System.Collections.Concurrent.ConcurrentDictionary<System.Type, bool>();
public static bool IsDatabaseFirst<TDbContext>() where TDbContext : System.Data.Entity.DbContext
@Orlys
Orlys / latency.txt
Created January 12, 2021 04:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
public interface IIndexedEnumerator<T> : IEnumerator<T>
{
int Index
{
get;
}
bool IsOdd
{
@Orlys
Orlys / Enumeration.cs
Last active May 24, 2020 03:57
Enumeration type extension methods. (For resolve Attribute, attach/detach enum values).
// author: Orlys
// source: github.com/orlys
// contact: contact.orlys@gmail.com
// required: C# 7.3
// license: MIT
// Copyright 2020 © Orlys Ma
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
namespace SelfSerialization
{
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
public class BinarySerializer : Serializer<BinarySerializer>
{