Skip to content

Instantly share code, notes, and snippets.

View PaulStovell's full-sized avatar

Paul Stovell PaulStovell

View GitHub Profile
@PaulStovell
PaulStovell / ProcessWrapperFixture.cs
Created October 30, 2011 21:31
Anthropic Principle proven
[TestFixture]
public class ProcessWrapperFixture
{
ProcessWrapper processWrapper;
[SetUp]
public void SetUp()
{
processWrapper = new ProcessWrapper(Process.GetCurrentProcess());
}
@PaulStovell
PaulStovell / Test.cs
Created November 2, 2011 18:33
SHA512Managed is not thread safe
static void Main(string[] args)
{
var hashAlgorithm = SHA512.Create();
var text = "Hello world";
var bytes = Encoding.Default.GetBytes(text);
var hashes = new List<string>();
Parallel.For(0, 10000, ignored =>
@PaulStovell
PaulStovell / DataContext.cs
Created November 17, 2011 16:25
EF Models
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Octopus.Core.Model;
namespace Octopus.Core.Persistance
{
public class DataContext : DbContext, IDataContext
{
public DataContext(string connectionString)
@PaulStovell
PaulStovell / Log.txt
Created December 23, 2011 04:03
Octopus output
Summary
-------------------------------------------------
2011-12-23 04:23:43 INFO Stage 1: Downloading packages from NuGet servers
2011-12-23 04:23:44 INFO Stage 2: Uploading packages to Tentacles
2011-12-23 04:23:44 INFO Stage 3: Installation
2011-12-23 04:23:57 INFO Deployment complete!
Details
-------------------------------------------------
Stage 1: Downloading packages from NuGet servers
@PaulStovell
PaulStovell / ApiAreaRegistration.cs
Created December 28, 2011 14:36
ApiAreaRegistration
public class ApiAreaRegistration : AreaRegistration
{
public override string AreaName
{
get { return "Api"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
MapRestfulRoutes("API120", context, "Api/Projects/{projectId}/Releases", "Releases");
@PaulStovell
PaulStovell / rss.xml
Created January 4, 2012 11:44
Ayende RSS as at 4 Jan 2012 11:44 AM GMT
<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com/blog/syndication/rss</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien 2004 - 2011 (c) 2012</copyright><ttl>60</ttl><item><title>Out of context, architecture is nothing but modern art</title><description>&lt;p&gt;
When I am thinking about modern art, I am thinking about an experience that I had that was remarkably similar to &lt;a href="http://tonyvanhelsing.blogspot.com/2011/05/modern-art.html"&gt;this one&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://1.bp.blogspot.com/-e2aJXImlhfY/TcKrSw69D4I/AAAAAAAAAIU/xjjNNNGj_Fw/s1600/modern_art.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;
@PaulStovell
PaulStovell / Machine.cs
Created January 6, 2012 00:01
Entities in Octopus
using System;
using System.Collections.Generic;
namespace Octopus.Core.Model
{
public class Machine
{
[Obsolete("Persistance")]
public Machine()
{
@PaulStovell
PaulStovell / DataContext.cs
Created January 6, 2012 00:05
The data context
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Octopus.Core.Model;
namespace Octopus.Core.Persistance
{
public class DataContext : DbContext, IDataContext
{
public DataContext(string connectionString)
@PaulStovell
PaulStovell / EnvironmentResource.cs
Created January 6, 2012 00:09
How I expose resources to JSON
using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Octopus.Core.Model;
namespace Octopus.Portal.Areas.Api.Models
{
public class EnvironmentResource : IResource
{
public int Id { get; set; }
public class EnvironmentsController : OctopusController
{
readonly IDataContext dataContext;
public EnvironmentsController(IDataContext dataContext)
{
this.dataContext = dataContext;
}
public ActionResult Index()