Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@shiftkey
shiftkey / gist:3337426
Created August 13, 2012 06:30
My Ideal MVVM Framework
Things you need:
- a base implementation of ICommand - for Win8 I'd recommend asynchronous support. For early frameworks I'd say no.
- an interface for messaging between components - current favourite interface is MvvmLight's Messenger
- a base implementation of this messenger
Things you don't need:
- a base implementation of INotifyPropertyChanged - just IL weave and [don't think too hard about it](brendanforster.com/inotifypropertychanged-stop-the-madness.html)
@pawelpabich
pawelpabich / LogModule.cs
Created July 7, 2012 13:32
Log4Net and NLog modules for Autofac
using System;
using System.Linq;
using Autofac;
using Autofac.Core;
using NLog;
using log4net;
using LogManager = NLog.LogManager;
namespace AutofacIdea
{
@dgrunwald
dgrunwald / awaitableWPF.cs
Created March 2, 2012 20:30
Awaitable WPF Dispatcher
public static class WpfExtensions
{
public static DispatcherAwaiter GetAwaiter(this Dispatcher dispatcher)
{
return new DispatcherAwaiter(dispatcher, DispatcherPriority.Normal);
}
public static Tuple<Dispatcher, DispatcherPriority> WithPriority(this Dispatcher dispatcher, DispatcherPriority priority)
{
return Tuple.Create(dispatcher, priority);
@appakz
appakz / countLOC.ps1
Created January 25, 2012 03:13
Quick and dirty powershell script for counting lines in each file of a folder
#Quick and dirty PS script for counting lines of code in a directory. Output is dumped to a simple CSV file.
#Note that this script doesn't count blank lines.
#Parameters:
# path - the path containing the code files (note that the script will recurse through subfolders
# outputFile - fully qualified path of the file to dump the CSV output
# include (Optional) - file mask(s) to include in the count (deafults to *.*)
# exclude (Optional) - file mask(s) to exclude in the count (defaults to none)
# Example (count lines in target path including *.cs but excluding *.designer.cs)
# .\countLOC.ps1 -path "C:\code\MyProject" -outputFile "C:\code\loc.csv" -include "*.cs" -exclude "*.designer.cs"
param([string]$path, [string]$outputFile, [string]$include = "*.*", [string]$exclude = "")
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@markrendle
markrendle / MaybeMonad.cs
Created October 18, 2011 11:25
Maybe Monad in C#
namespace MaybeMonad
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
static class Monads
{
/// <summary>