Skip to content

Instantly share code, notes, and snippets.

View jrusbatch's full-sized avatar

Justin Rusbatch jrusbatch

View GitHub Profile
@jrusbatch
jrusbatch / gist:4731149
Last active December 12, 2015 06:39
A wrapper for Twitter Bootstrap's typeahead plugin that supports objects.
(function($) {
'use strict';
function TypeaheadItem(value, selectedText, suggestionText) {
this.value = value;
this.text = selectedText;
this.suggestion = suggestionText || selectedText;
}
TypeaheadItem.prototype.toString = function () {
/// <summary>
/// Represents an IIS Express site.</summary>
public class IISExpress : IDisposable
{
private readonly string applicationPath;
private readonly Uri address;
private Process process;
private bool disposed;
@jrusbatch
jrusbatch / AvailablePorts.cs
Created December 5, 2012 02:17
Find an Available Port with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;
using System.Net;
namespace AvailablePort
{
class Program
@jrusbatch
jrusbatch / gist:3872094
Created October 11, 2012 12:54
Precompile.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Created by Craig Andrews http://candrews.integralblue.com [email protected] -->
<UsingTask TaskName="Microsoft.WebDeployment.Tasks.AspNetMerge" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.Tasks.dll"/>
<PropertyGroup>
<_PackageTempDirCompiled>$(PackageTempRootDir)\PackageTempCompiled</_PackageTempDirCompiled>
public class DocumentSessionFactory : IDisposable
{
private readonly IDocumentStore documentStore;
public DocumentSessionFactory()
{
documentStore = new EmbeddableDocumentStore { RunInMemory = true };
documentStore.Initialize();
}
/**
* Both of the below methods are valid actions in an ApiController, and both would result in the
* same response being sent to the client.
**/
// GET api/strings
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
@@@ // dont' really want external subclasses
internal RedisConnectionBase(string host, int port = 6379, /* ... */)
@jrusbatch
jrusbatch / Base36.cs
Created September 2, 2012 21:23
A C# type representing a base-36 encoded 64-bit integer.
using System;
using System.Collections.Generic;
[Serializable]
public struct Base36 : IEquatable<Base36>, IComparable<Base36>
{
private const string Characters = "0123456789abcdefghijklmnopqrstuvwxyz";
public static readonly Base36 MaxValue = new Base36(long.MaxValue);
public static readonly Base36 MinValue = new Base36(long.MinValue + 1);
public interface IHaveState
{
object State { get; }
}
Action x;
x = () => x();
return x();