Skip to content

Instantly share code, notes, and snippets.

@jpoehls
jpoehls / EnumHelper.cs
Created April 7, 2010 13:33
Enum Helper
using System;
namespace Samples
{
public static class EnumHelper
{
public static string GetDescription(this Enum value)
{
if (value == null)
{
@jpoehls
jpoehls / WinFormsControlExtensions.cs
Created April 7, 2010 13:36
WPF & WinForms Control Extensions
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows.Forms;
namespace Samples
@jpoehls
jpoehls / CascadingListDecorator.cs
Created April 18, 2010 01:05
CascadingListDecorator for WinForms
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Samples
{
public class CascadingListDecorator<TChildValue, TParentValue> where TParentValue : class
{
private ListControl _childList;
@jpoehls
jpoehls / ViewModelIndexer.cs
Created April 28, 2010 17:58
simple ViewModel locator
using System;
using System.ComponentModel.Composition;
using System.Collections.Generic;
using System.Linq;
namespace Samples
{
public class ViewModelIndexer
{
public ViewModelIndexer()
@jpoehls
jpoehls / NotificationExtensions.cs
Created April 30, 2010 16:40
INotifyPropertyChanged Helpers
using System;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace Samples
{
public static class NotificationExtensions
{
@jpoehls
jpoehls / EngineThatCould.cs
Created October 12, 2010 13:54
Tries to perform an action several times before giving up
using System;
using System.Threading;
using log4net;
namespace Samples
{
public class EngineThatCould
{
private static readonly ILog Log = LogManager.GetLogger(typeof(EngineThatCould));
private const int SecondsBetweenAttempts = 1;
@jpoehls
jpoehls / Hg-Export.ps1
Created July 12, 2011 13:22
Hg-Export # PS function to export a diff file of uncommitted changes in the working repo
function Hg-Export([string]$Path) {
<#
.SYNOPSIS
Exports all uncommitted changes in the current HG repository
to a git formatted diff file at the specified path.
The resultant diff file can be re-imported into a repo using: hg import changes.diff
.EXAMPLE
Hg-Export changes.diff
@jpoehls
jpoehls / tortoise-svn.ps1
Created October 12, 2011 17:16
Tortoise SVN (Svn-Tortoise) PowerShell function
# Helper function for opening the Tortoise SVN GUI from a PowerShell prompt.
# Put this into your PowerShell profile.
# Ensure Tortoise SVN is in your PATH (usually C:\Program Files\TortoiseSVN\bin).
function Svn-Tortoise([string]$Command = "commit") {
<#
.SYNOPSIS
Launches TortoiseSVN with the given command.
Opens the commit screen if no command is given.
@jpoehls
jpoehls / RawResponseFromFiddler.txt
Created October 26, 2011 16:15
Glimpse blank response bug
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: deflate
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Compressed-By: HttpCompress
X-Glimpse-RequestID: e379b425-9573-477e-81d8-7eda4d1643c6
X-Powered-By: ASP.NET
Date: Wed, 26 Oct 2011 16:13:21 GMT
@jpoehls
jpoehls / BaseController.cs
Created December 2, 2011 19:38
Newtonsoft Json Results for MVC
using System;
using System.Linq;
using System.Web.Mvc;
public abstract class BaseController : Controller
{
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding)
{
return new JsonNetResult
{