Skip to content

Instantly share code, notes, and snippets.

View huoxudong125's full-sized avatar
💭
I may be slow to respond.

Frank Huo huoxudong125

💭
I may be slow to respond.
View GitHub Profile
public sealed class DynamicMatch : DynamicObject
{
private readonly Regex _Regex;
private readonly Match _Match;
public DynamicMatch( Regex regex, Match match )
{
Contract.Requires( regex != null, "Regex cannot be null." );
@huoxudong125
huoxudong125 / VerifySessionStateFilter.cs
Created November 28, 2016 01:09 — forked from josheinstein/VerifySessionStateFilter.cs
When your ASP.NET MVC login session depends on session state, annotating your controller with this attribute will ensure that the required session state is present. Otherwise it will attempt to re-load it or log the user out if it cannot be reloaded.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.Owin.Security;
@huoxudong125
huoxudong125 / AppSettingsValueBindingWrapper.cs
Created October 24, 2016 05:24 — forked from mattbenic/AppSettingsValueBindingWrapper.cs
A generic wrapper for AppSettings values to allow them to be used in Windows Forms bindings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Reflection;
using System.ComponentModel;
/// <summary>
@huoxudong125
huoxudong125 / Model
Created October 18, 2016 03:34
WPF generate dynamic tabcontrol
namespace DynamicTabControl
{
public class Model
{
public string Header { get; set; }
public string Body { get; set; }
}
}
@huoxudong125
huoxudong125 / WPF Path Data | .cs
Created October 15, 2016 02:20 — forked from JokerMartini/WPF Path Data | .cs
XAML data paths for C# applications using WPF
// X Symbol
<Path Data="M0,0 L1,1 M0,1 L1,0" Stretch="Uniform" Stroke="Red" />
// Arrow Right
<Path Data="M4.12,0 L9.67,5.47 L4.12,10.94 L0,10.88 L5.56,5.47 L0,0.06" Stretch="Uniform" Fill="Red"/>
// Three Dots
<Path Data="M12.5,6.5 C12.5,9.8137085 9.8137085,12.5 6.5,12.5 C3.1862915,12.5 0.5,9.8137085 0.5,6.5 C0.5,3.1862915 3.1862915,0.5 6.5,0.5 C9.8137085,0.5 12.5,3.1862915 12.5,6.5 z M30.5,6.5 C30.5,9.8137085 27.813708,12.5 24.5,12.5 C21.186292,12.5 18.5,9.8137085 18.5,6.5 C18.5,3.1862915 21.186292,0.5 24.5,0.5 C27.813708,0.5 30.5,3.1862915 30.5,6.5 z M48.5,6.5 C48.5,9.8137085 45.813708,12.5 42.5,12.5 C39.186292,12.5 36.5,9.8137085 36.5,6.5 C36.5,3.1862915 39.186292,0.5 42.5,0.5 C45.813708,0.5 48.5,3.1862915 48.5,6.5 z" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="13" Margin="23.75,21.75,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="49"/>
// Paper Airplane
@huoxudong125
huoxudong125 / IRegionHostedInTabControlAware.cs
Created October 11, 2016 06:35 — forked from tiesmaster/IRegionHostedInTabControlAware.cs
Add support in PRISM for setting header of TabControl
namespace Coolblue.Wpf.Toolkit.Regions
{
public interface IRegionHostedInTabControlAware
{
string Header { get; }
}
}
@huoxudong125
huoxudong125 / latency.txt
Created September 22, 2016 02:03 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
@huoxudong125
huoxudong125 / latency.markdown
Created September 22, 2016 02:03 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@huoxudong125
huoxudong125 / SecureCallAttribute.cs
Created August 24, 2016 01:36 — forked from thehoneymad/SecureCallAttribute.cs
Custom Authorization Attribute on Asp.net web api 2.2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http;
@huoxudong125
huoxudong125 / Cache.cs
Created August 12, 2016 03:19 — forked from madelson/Cache.cs
An expression-based caching API
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.Caching;
using System.Text;
using System.Threading.Tasks;