Skip to content

Instantly share code, notes, and snippets.

public partial class Elmah : DbMigration
{
public override void Up()
{
Sql(CreateTable_ELMAH_Error);
Sql(CreatreProcedure_ELMAH_GetErrorXml);
Sql(CreateProcedure_ELMAH_GetErrorsXml);
Sql(CreateProcedure_ELMAH_LogError);
}
@kevinblake
kevinblake / ICacheService.cs
Created February 1, 2014 17:06
SimpleCache
internal interface ICacheService
{
T Get<T>(string cacheId, Func<T> getItemCallback) where T : class;
T Get<T>(string cacheId, CacheDependency cacheDependency, DateTime absoluteExpiration, TimeSpan slidingExpiration,
Func<T> getItemCallback) where T : class;
}
; (function ($, window, document, undefined) {
// Create the defaults once
var __indexOf =
[].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) return i;
}
return -1;
};
@kevinblake
kevinblake / ip.py
Last active December 31, 2015 15:18
Sends a pushover message, whenever your public IP address changes.
import requests,json,time,httplib, urllib, socket, yaml
f = open('ip.yaml')
settings = yaml.safe_load(f)
f.close()
while True:
f = open('ipaddress', 'r')
current = f.readline()
r=requests.get(r'http://jsonip.com')
@kevinblake
kevinblake / BlockLabelExtensions.cs
Created November 26, 2013 14:12
Html Helper class to add ASP.NET MVC error messages to a label wrapper class
using System.Linq;
using System.Linq.Expressions;
namespace System.Web.Mvc.Html
{
public static class BlockLabelExtensions
{
public static IDisposable BeginBlockLabel<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
{
string expressionText = ExpressionHelper.GetExpressionText(expression);
@kevinblake
kevinblake / jquery.boilerplate.js
Last active December 28, 2015 21:19
jquery plugin boilerplate
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
; (function ($, window, document, undefined) {
// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
// window and document are passed through as local variable rather than global
; (function ($, window, document, undefined) {
// Create the defaults once
var __indexOf =
[].indexOf || function (item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) return i;
}
return -1;
};
@kevinblake
kevinblake / trim.js
Created October 29, 2013 12:09
Trim support in IE7 & 8
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
@kevinblake
kevinblake / FormatWith.cs
Created October 24, 2013 13:42
FormatWith class
public static class FormatWith
{
public static string FormatString(string format, object source)
{
return FormatString(format, null, source);
}
public static string FormatString(string format, IFormatProvider provider, object source)
{
if (format == null)
@kevinblake
kevinblake / ResourceFinder.cs
Created October 24, 2013 13:41
Get resources static helper class
public static class ResourceFinder
{
public static string Get(string resourceName)
{
var assembly = Assembly.GetExecutingAssembly();
var result = String.Empty;
using (var stream = assembly.GetManifestResourceStream(resourceName))
{
if (stream == null)