Skip to content

Instantly share code, notes, and snippets.

View damianh's full-sized avatar
💥

Damian Hickey damianh

💥
View GitHub Profile
@damianh
damianh / RestorePackages.ps1
Created March 31, 2011 14:35
PowerShell script to restore a projects packages and tools. Requires nuget.exe to be in the project root and commited to source control.
# Tools
.\NuGet.exe i DotCover -s \\myserver\Dev\NuGetPackages -o Tools
.\NuGet.exe i StyleCopCmd -s \\myserver\Dev\NuGetPackages -o Tools
# Dependecies
$packageConfigs = Get-ChildItem . -Recurse | where{$_.Name -eq "packages.config"}
foreach($packageConfig in $packageConfigs){
Write-Host "Restoring" $packageConfig.FullName
.\nuget.exe i $packageConfig.FullName -o Source\Packages
}
@damianh
damianh / PatchingOpenWrap.desc
Created April 11, 2011 18:54
Patching OpenWrap.desc at build time.
OpenWrap.desc file:
name: Company.Component-%BranchName%
depends: Xunit
depends: Compare-NET-Objects
depends: Moq
depends: NLog
depends: openwrap
depends: Xunit.Extensions
@damianh
damianh / Restore.ps1
Created April 14, 2011 21:44
Restores tools, and wraps from
.\NuGet.exe i psake -o tools -x
.\o.exe -ShellInstall none add-remote nuget nuget://packages.nuget.org/v1/FeedService.svc/Packages
.\o.exe -ShellInstall none update-wrap
@damianh
damianh / gist:1120821
Created August 2, 2011 18:16
IEnumerable ForEach safety extensions
namespace System.Collections.Generic
{
using System.Linq;
public static class IEnumerableExtensions
{
// Why ForEach extension is not included on IEnumerable<T> by default http://blogs.msdn.com/b/ericlippert/archive/2009/05/18/foreach-vs-foreach.aspx
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
@damianh
damianh / RavenDBTransactionTest.cs
Created August 24, 2011 20:01
RavenDB DocumentSession transaction tests
public class RavenDbTransactionTest
{
[Fact]
public void RemoteDocumentStore_ShouldNotThrow()
{
var documentStore = new DocumentStore()
{
Url = "http://localhost:8080"
};
documentStore.Initialize();
@damianh
damianh / NHibernateTransactionTest.cs
Created August 24, 2011 20:07
NHibernateTransactionTest
public class NHibernateTransactionTest
{
[Fact]
public void NHibernateSave_ShouldNotThrow()
{
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration
.MsSql2008
.ConnectionString(c => c
.Server("localhost")
@damianh
damianh / gist:1672857
Created January 24, 2012 21:35
Fleck exception on server dispose
using (var server = new WebSocketServer("ws://localhost:8181"))
{
server.Start(connection => { });
}
24/01/2012 21:29:32 [Info] Server started at ws://localhost:8181
24/01/2012 21:29:32 [Error] Listener socket is closed System.AggregateException:
One or more errors occurred. ---> System.ObjectDisposedException: Cannot access
a disposed object.
Object name: 'System.Net.Sockets.Socket'.
@damianh
damianh / gist:1673072
Created January 24, 2012 22:17
Fleck and WebSocket4Net
private static void Main(string[] args)
{
var server = new WebSocketServer("ws://127.0.0.1:8181");
server.Start(socket =>
{
socket.OnOpen = () => Console.WriteLine("Open!");
socket.OnClose = () => Console.WriteLine("Close!");
socket.OnError = ex => Console.WriteLine("Server: " + ex);
socket.OnMessage = message =>
{
@damianh
damianh / gist:1825707
Created February 14, 2012 10:42
Storage (Repository Discussion)
namespace WinPhoneKit.Storage
{
using System;
using System.IO.IsolatedStorage;
public static class IsolatedStorage
{
private static readonly IsolatedStorageSettings isolatedStorage = IsolatedStorageSettings.ApplicationSettings;
public static void Add<TEntity>(string key, TEntity entity)
@damianh
damianh / gist:1825986
Created February 14, 2012 11:22
Storage (Repository Discussion)
//Guard clauses / contracts omitted for berivity
//Thread safety not considered.
public interface IKeyValueStore
{
void Add<T>(string key, T item);
void AddOrUpdate<T>(string key, T item);
bool Remove(string key);