Skip to content

Instantly share code, notes, and snippets.

// 页面定时刷新
<head>
@if (ViewBag.RefreshSeconds != null && ViewBag.RefreshSeconds > 0)
{
<meta http-equiv="refresh" content="@ViewBag.RefreshSeconds">
}
</head>
@CleanCoder
CleanCoder / ExternalConfigurationManager From MS.txt
Last active December 13, 2017 01:52
ExternalConfigurationManager From MS
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace ExternalConfigurationStore.Cloud
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading;
@CleanCoder
CleanCoder / DB
Created January 23, 2018 01:33
DB
using EntityFramework;
using EntityFramework.Mapping;
using EntityFramework.Reflection;
using Next.Dal.Entity;
using Next.Dal.Repertory;
using Next.Dal.Repertory.DbRepertory;
using Next.Dal.Repertory.MemoryRepertory;
using Spring.Reflection.Dynamic;
using System;
using System.Collections.Generic;
internal sealed class DynamicEqualityComparer<T> : IEqualityComparer<T>
where T : class
{
private readonly Func<T, T, bool> _func;
public DynamicEqualityComparer(Func<T, T, bool> func)
{
DebugCheck.NotNull(func);
_func = func;
internal static class TaskHelper
{
internal static Task<T> FromException<T>(Exception ex)
{
var completion = new TaskCompletionSource<T>();
completion.SetException(ex);
return completion.Task;
}
internal static Task<T> FromCancellation<T>()
@CleanCoder
CleanCoder / WinDBG
Last active November 17, 2021 19:58
WinDBG
1) 准备工作
.loadby sos clr
.cordll -ve -u -l
.load <<path>>\sosex.dll
.load <<path>>\mex.dll
.symfix
.reload
2) 常用方法
!pe [<exceptionAddr>] most recent exception data (don’t forget the external stack)
// Dynamic Invoke Generic Method
MethodInfo methodInfo = typeof(MyClass).GetMethod("TestProc");
MethodInfo genericMethod = methodInfo.MakeGenericMethod(new[] { typeof(string) });
genericMethod.Invoke(null, new[] { "Hello" }); // the first parameter is null, means it is a static method
https://www.codeproject.com/Articles/584720/ExpressionplusbasedplusPropertyplusGettersplusandp
// returns property getter
public static Func<TObject, TProperty> GetPropGetter<TObject, TProperty>(string propertyName)
{
clear # clean screen
netstat -tulpn | grep LISTEN # check the listening ports and applications
@CleanCoder
CleanCoder / Task Extension
Last active April 8, 2020 09:47
Task Extension
static async Task<T> Otherwise<T> (this Task<T> task, Func<Task<T>> orTask) {
task.ContinueWith (async innerTask => {
if (innerTask.Status == TaskStatus.Faulted)
return await orTask ();
return await Task.FromResult<T> (innerTask.Result);
}).Unwrap ();
}
static async Task<T> Retry<T> (Func<Task<T>> task, int retries, TimeSpan delay, CancellationToken cts = default (CancellationToken)) {
@CleanCoder
CleanCoder / FP
Created July 20, 2018 02:07
Funtional Programming
struct Result<T> {
public T Ok { get; }
public Exception Error { get; }
public bool IsFailed { get => Error != null; }
public bool IsOk => !IsFailed;
public Result (T ok) {
Ok = ok;
Error = default (Exception);
}