Skip to content

Instantly share code, notes, and snippets.

View xpando's full-sized avatar

David Findley xpando

View GitHub Profile
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public abstract class HierarchyNode
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public abstract class HierarchyNode
{
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Demo.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
@xpando
xpando / ExtendBundleCollection.cs
Created February 20, 2012 00:07
Use config files with ASP.NET 4.5 Bundles
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using System.IO;
namespace MvcApplication3
{
public static class ExtendBundleCollection
@xpando
xpando / gist:1866903
Created February 20, 2012 01:04
Custom base razor view page that resolves bundle urls
public abstract class MyViewPage<TModel> : System.Web.Mvc.WebViewPage<TModel>
{
public override string Href(string path, params object[] pathParts)
{
if (BundleTable.Bundles.Any(b => b.Path.Equals(path, StringComparison.InvariantCultureIgnoreCase)))
return BundleTable.Bundles.ResolveBundleUrl(path);
return base.Href(path, pathParts);
}
}
@xpando
xpando / Retry.cs
Created May 1, 2012 21:02
C# fluent retries
public class Retry
{
int _times;
Func<int, TimeSpan> _delay = i => TimeSpan.FromTicks(0);
List<Predicate<Exception>> _shouldRetry = new List<Predicate<Exception>>();
Action<int, Exception> _log = (i, ex) => { Debug.WriteLine("Quartet.Core.Retry: {0}", ex.ToString()); };
Retry(int times)
{
_times = times;
@xpando
xpando / Clean.ps1
Created May 3, 2012 21:37
Delete all bin/obj folders in solution
dir .\ -Include bin,obj -Recurse | del -Force -Recurse
@xpando
xpando / RandomString.cs
Created May 9, 2012 22:27
Generate random string
public static class StringExtensions
{
// Generates a random seq of characters
// e.g. "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ01234567890!@#$%&*()-+".Randomize(8);
public static string Randomize(this string characters, int len)
{
var rng = new RNGCryptoServiceProvider();
var builder = new StringBuilder(len);
var bytes = new byte[4];
for (var i = 0; i < len; i++)
@xpando
xpando / gist:2888710
Created June 7, 2012 13:07
Reset Permissions on NTFS Driver after install
TAKEOWN /f "X:\" /r /d y
ICACLS "X:\" /reset /T
@xpando
xpando / gist:2901449
Created June 9, 2012 15:30
Full Text Catalog properties
SELECT
cat.name,
ItemCount = FULLTEXTCATALOGPROPERTY(cat.name, 'ItemCount'),
MergeStatus = FULLTEXTCATALOGPROPERTY(cat.name, 'MergeStatus'),
PopulateCompletionAge = FULLTEXTCATALOGPROPERTY(cat.name, 'PopulateCompletionAge'),
PopulateStatus = FULLTEXTCATALOGPROPERTY(cat.name, 'PopulateStatus'),
ImportStatus = FULLTEXTCATALOGPROPERTY(cat.name, 'ImportStatus')
FROM
sys.fulltext_catalogs AS cat