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 / Version.aspx
Created October 30, 2012 10:46
Show Assembly Version
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="version.aspx.cs" Inherits="MyApplication.Version" %>
{"Version" : <asp:Literal runat="server" ID="Version"></asp:Literal>, "BuildDate" : <asp:Literal runat="server" ID="BuildDateString"></asp:Literal> }
@kevinblake
kevinblake / RemovePreviewButton.cs
Created October 30, 2012 15:04 — forked from nul800sebastiaan/RemovePreviewButton.cs
Remove preview button in Umbraco
public class RemovePreviewButton : ApplicationBase
{
public RemovePreviewButton()
{
umbracoPage.Load += this.umbracoPage_Load;
}
private void umbracoPage_Load(object sender, EventArgs e)
{
var umbracoPage = (umbracoPage)sender;
@kevinblake
kevinblake / YouTubeUrl.cs
Created November 14, 2012 09:58
Parse YouTube Id from Url
public static class YouTubeUrl
{
private const string UrlRegex = @"youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)";
public static string GetVideoId(string videoUrl)
{
var regex = new Regex(UrlRegex);
var match = regex.Match(videoUrl);
@kevinblake
kevinblake / gist:4225907
Created December 6, 2012 16:41
Using timeago.js with C#
List View bound fields
<asp:BoundField DataField="Timestamp" HeaderText="Timestamp" ReadOnly="True" SortExpression="Timestamp" HtmlEncode="False" DataFormatString="<abbr class='timeago' title='{0:yyyy'-'MM'-'dd HH':'mm':'ss'Z'}'>{0}</abbr>" />
In code:
DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ");
@kevinblake
kevinblake / Modular.js
Created October 22, 2013 13:22
Modular JS
var MyNamespace = MyNamespace || {};
MyNamespace.UI = MyNamespace.UI || {};
MyNamespace.UI.ModuleName = function ($, window) {
"use strict";
var my = {};
my.options = {
@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)
@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 / 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, '');
};
}
; (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;
};