Skip to content

Instantly share code, notes, and snippets.

View hazzik's full-sized avatar

Alex Zaytsev hazzik

  • Brisbane, Australia
View GitHub Profile
String.prototype.visualLength = (function() {
var that = this,
ruler = document.getElementById('ruler');
if (!ruler) {
ruler = document.createElement('span');
document.body.appendChild(ruler);
}
ruler.style.visibility = 'hidden';
return function () {
ruler.innerHTML = that;
@hazzik
hazzik / reset.css
Last active December 17, 2015 02:39
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
public static class NullableTypeEx
{
public static Type UnwrapIfNullable(this Type type)
{
return type.IsNullable() ? type.GetGenericArguments()[0] : type;
}
public static bool IsNullable(this Type type)
{
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof (Nullable<>);
public interface IStatefulComponent
{
StateBag ViewState { get; }
}
public class ViewStateField
{
public static ViewStateField<T> Create<T>(StateBag viewState, string key)
{
return new ViewStateField<T>(() => viewState, key);
// System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
// System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
public static class StringExtensions
{
public static bool Contains(this string self, string value, StringComparison comparisonType)
{
return self.IndexOf(value, comparisonType) != -1;
}
}
@hazzik
hazzik / IFormHandler`2.cs
Created November 9, 2012 11:10
FormController.cs
public interface IFormHandler<in TForm, out TResult> where TForm : IForm
{
TResult Handle(TForm form);
}
public class Localization
{
private readonly Func<string> message;
private Localization(string message)
: this(() => message)
{
}
private Localization(Func<string> message)
@for /d %%f in (*) do @call :update %%f
:update
pushd %1
git fetch --all
popd
@goto :eof
public class IoCAwareScanner : DefaultModelMetadataScanner
{
private readonly Action<Type, Type> registerAsTransient;
internal static readonly Type ModelMetadataConfigurationType = typeof(IModelMetadataConfiguration);
protected IoCAwareScanner(Action<Type, Type> registerAsTransient)
{
this.registerAsTransient = registerAsTransient;
}