Skip to content

Instantly share code, notes, and snippets.

@hoangitk
hoangitk / ProxyGenerator.cs
Last active July 30, 2020 02:40
[ProxyGenerator.cs] #csharp #metaprogramming
/*https://github.com/AutoMapper/AutoMapper/blob/18f974a091c910675eea599e6164e8b70ca3aae8/src/AutoMapper/Execution/ProxyGenerator.cs*/
public static class ProxyGenerator
{
private static readonly byte[] privateKey =
StringToByteArray(
"002400000480000094000000060200000024000052534131000400000100010079dfef85ed6ba841717e154f13182c0a6029a40794a6ecd2886c7dc38825f6a4c05b0622723a01cd080f9879126708eef58f134accdc99627947425960ac2397162067507e3c627992aa6b92656ad3380999b30b5d5645ba46cc3fcc6a1de5de7afebcf896c65fb4f9547a6c0c6433045fceccb1fa15e960d519d0cd694b29a4");
private static readonly byte[] privateKeyToken = StringToByteArray("be96cd2c38ef1005");
private static readonly MethodInfo delegate_Combine = typeof(Delegate).GetRuntimeMethod("Combine", new[] { typeof(Delegate), typeof(Delegate) });
@hoangitk
hoangitk / git_commands.md
Last active November 24, 2021 06:52
[Git command] #git #collection

Git Commands

How to remove local untracked files from the current Git branch

  • List of untracked files
git clean -n
@hoangitk
hoangitk / csharp_notes.md
Created July 23, 2020 04:28
[C# Localization] #dotnet

System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

@hoangitk
hoangitk / send-weixin.ps1
Created July 22, 2020 02:52
[send-weixin(wechat)] #powershell #wechat
# https://blog.51cto.com/lixiaosong/1689886
function send-weixin {
Param(
[Parameter(Mandatory = $True, Position = 1)]
[String]$Username,
[Parameter(Mandatory = $True, Position = 2)]
[String]$Content
)
$auth_string = https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=【你自己的Corpid】&corpsecret= 【你自己的密码】
$auth_values = Invoke-RestMethod $auth_string
@hoangitk
hoangitk / git_submodules.md
Created June 29, 2020 07:22 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@hoangitk
hoangitk / Find_and_Replace.md
Created June 26, 2020 07:51
[Find and Replace] #tips #regex

Find and Replace tips

Regex

  • Find All a tag with bookmark
     <a.+?\s*href\s*=3D\s*["\']?([^"\'\s>]+\#(\w*))["\']?
@hoangitk
hoangitk / SqlKataExample.cs
Created June 23, 2020 06:49 — forked from benmccallum/SqlKataExample.cs
Optimized, cursor-based paging for connections with MS SQL CTEs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using AutoGuru.Client.Shared;
using AutoGuru.Client.Shared.Dtos;
using AutoGuru.Client.Shared.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
@hoangitk
hoangitk / Self-signed SSL.md
Last active June 18, 2020 07:42
[Self-signed SSL] #hosting #ssl

Self-signed SSL

Powershell

 New-SelfSignedCertificate -DnsName *.clientcert.test -CertStoreLocation cert:\LocalMachine\My

CARoot

makecert.exe ^
@hoangitk
hoangitk / ngrok.md
Created June 17, 2020 02:43
[ngrok] #ngrok #hosting

Ngrok

Start

  • ngrok start --all --config=ngrok.yml
@hoangitk
hoangitk / A New Pattern for Exception Logging.md
Created June 12, 2020 17:11
[A New Pattern for Exception Logging] #dotnet #csharp #exception