Skip to content

Instantly share code, notes, and snippets.

View lukesmith's full-sized avatar

Luke Smith lukesmith

View GitHub Profile
this.For<IRepository<ICommandLog>>()
.Use(x => {
var session = x.GetInstance<ISessionFactory>().OpenSession();
session.FlushMode = FlushMode.Commit;
return new CommandLogRepository(new NHibernateUnitOfWork(session));
});
using System;
using System.Linq;
namespace BookUpon.Tests
{
public static class IMappedEngineConfigurationBuilderExtensions
{
public static void ScanAssembly<T>(this IMappedEngineConfigurationBuilder builder)
{
var maps = typeof(T).Assembly.GetTypes().Where(x => typeof(IAutoPocoMap<>).IsAssignableFrom(x) && !x.IsAbstract);
<?xml version="1.0" encoding="utf-8" ?>
<commands>
<command name="CreateUserCommand">
<username>lukesmith</username>
<password>password1</password>
<firstname>Luke</firstname>
<lastname>Smith</lastname>
<emailaddress>luke@somesite.com</emailaddress>
</command>
<command name="CreateUserCommand">
[Serializable]
public class EmailAddress : IComparable<EmailAddress>
{
public const int MaxLength = 256;
// Regex based on Phil Haacks http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx
public const string Expression = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|uk)\b";
private readonly string value;
public EmailAddress(string value)
{
[Serializable]
public class EmailAddressType : IUserType
{
public SqlType[] SqlTypes
{
get
{
var types = new SqlType[1];
types[0] = new SqlType(DbType.String);
@lukesmith
lukesmith / update_point.rb
Created May 16, 2011 12:48
Ruby script to update a point dns record with the public ec2 instance ip address
require 'open-uri'
require 'point'
ip = open('http://169.254.169.254/latest/meta-data/public-ipv4').read
Point.username = "user@example.com"
Point.apitoken = "......"
zone = Point::Zone.find(<ZoneId>) # example.com
record = zone.record(<RecordId>) # teamcity.example.com
@lukesmith
lukesmith / common.target
Created May 19, 2011 13:26
common target file for sharing settings across projects
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(ToolsDir)' == ''">
<ToolsDir>$(SolutionDir)\Tools\</ToolsDir>
</PropertyGroup>
<PropertyGroup>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<StyleCopAnalysisTarget Condition=" '$(StyleCopAnalysisTarget)' == '' ">$(ToolsDir)StyleCop\Microsoft.SourceAnalysis.targets</StyleCopAnalysisTarget>
@lukesmith
lukesmith / gist:1029107
Created June 16, 2011 12:06
OpenRasta exception stacktrace
[ArgumentNullException: Value cannot be null.
Parameter name: collection]
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +12646187
OpenRasta.Pipeline.PipelineStage..ctor(IPipeline pipeline) +73
OpenRasta.Hosting.AspNet.OpenRastaModule.HandleHttpApplicationPostResolveRequestCacheEvent(Object sender, EventArgs e) +548
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266
@lukesmith
lukesmith / AppConfig.Transformation.targets
Created June 17, 2011 11:24 — forked from jmangelo/AppConfig.Transformation.targets
VS 2010 RTM - MSBuild Project file for App.config XML transformations.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- 20110617 : Luke Smith : Imports Microsoft.WebApplication.targets for SP1 support. Added exists condition for when the TransformedConfig doesn't exist -->
<!-- 20110224 : Ryan Milligan : Created OverrideAppConfigWithTargetPath target to fix ClickOnce deploy bug -->
<!-- 20100827 : João Angelo : Fixed bug when using Publish command within Visual Studio -->
<PropertyGroup>
<!-- Prevent circular dependency on Build target -->
<PipelineDependsOnBuild>false</PipelineDependsOnBuild>
<!-- Override project config file name (By default is set to Web.config) -->
<ProjectConfigFileName>App.config</ProjectConfigFileName>
@lukesmith
lukesmith / gist:1511222
Created December 22, 2011 18:01
Why can't i do this?
class MyClass
@@defaults = {
:path => MyClass.default_path
}
def self.default_path
"something"
end
end