Skip to content

Instantly share code, notes, and snippets.

View jakcharlton's full-sized avatar

Jak Charlton jakcharlton

View GitHub Profile
@jakcharlton
jakcharlton / fm.xml
Created June 15, 2011 01:41
Resharper File Template for FluentMigrations
<TemplatesExport family="File Templates">
<Template uid="188d3b0a-987e-48b4-b42a-2ebaa25b21fb" shortcut="" description="Fluent Migration" text="using FluentMigrator;&#xD;&#xA;&#xD;&#xA;namespace $NAMESPACE$&#xD;&#xA;{&#xD;&#xA; [Migration($MIGRATIONNUMBER$)]&#xD;&#xA; public class $CLASS$$MIGRATIONNUMBER$ : Migration&#xD;&#xA; {&#xD;&#xA; public override void Up()&#xD;&#xA; {&#xD;&#xA; $END$&#xD;&#xA; }&#xD;&#xA;&#xD;&#xA; public override void Down()&#xD;&#xA; {&#xD;&#xA;&#xD;&#xA; }&#xD;&#xA; }&#xD;&#xA;}&#xD;&#xA;" reformat="True" shortenQualifiedReferences="True">
<Scopes>
<Scope type="Everywhere" />
</Scopes>
<Categories />
<Variables>
<Variable name="NAMESPACE" expression="fileDefaultNamespace()" initialRange="0" />
<Variable name="MIGRATIONNUMBER" expression="getCurrentTime(&quot;yyyymmddhhss&quot;)" initialRange="0" />
<Variable name="CLASS" expression="getFileNameWithoutExtension()" initialRange="
@jakcharlton
jakcharlton / comaprison.cs
Created June 15, 2011 06:17
Property equality comparison on two objects
// Shamelessly stolen and adapted from http://stackoverflow.com/questions/506096/comparing-object-properties-in-c
public static class Comparisons
{
public static bool PublicInstancePropertiesEqual<T>(this T self, T to, params string[] ignore) where T : class
{
if (self != null && to != null)
{
var type = typeof(T);
var ignoreList = new List<string>(ignore);
foreach (System.Reflection.PropertyInfo pi in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
@jakcharlton
jakcharlton / README
Created June 20, 2011 01:03
Pros and Cos of TFS and Git
TFS
Pros
• Familiar to current team
• Has a UI tool within Visual Studio
• Close tie in to Work Items
Cons
• Slow to pull, check in and branch
• Merge conflicts are frequent
• Encourages infrequent check in due to merge conflicts and slow performance
• Branching frequently leads to time consuming conflicts
@jakcharlton
jakcharlton / .gitignore
Created June 29, 2011 04:40
Gitignore for .NET
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
@jakcharlton
jakcharlton / singleactioncontroller.cs
Created July 11, 2011 01:12
MVC Single Action Controller
public class IndexController : Controller
{
[Authorize]
public ActionResult Index()
{
return View();
}
}
@jakcharlton
jakcharlton / windsor.cs
Created July 11, 2011 01:13
SingleAction Windsor Controller Factory
public class WindsorControllerFactory : DefaultControllerFactory
{
private readonly IKernel kernel;
public WindsorControllerFactory(IKernel kernel)
{
this.kernel = kernel;
}
public override void ReleaseController(IController controller)
@jakcharlton
jakcharlton / installer.cs
Created July 11, 2011 01:15
WindsorInstaller For Single Action Controllers
public void Install(IWindsorContainer container, IConfigurationStore store)
{
foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
{
if (typeof(IController).IsAssignableFrom(type) && !type.IsAbstract)
container.Register(Component.For(type).ImplementedBy(type).Named(type.FullName.ToLower()).LifeStyle.Transient);
}
}
@jakcharlton
jakcharlton / about_scoring_project.rb
Created July 18, 2011 05:29
About Scoring from Ruby Koans
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
@jakcharlton
jakcharlton / ruby_koans_scoring_benchmarks.rb
Created July 19, 2011 00:45
Benchmarking three versions of Ruby Koans scoring algorithm
require 'benchmark'
class Gary
# https://gist.github.com/1089115
def score(dice)
score_counts(dice).inject(0) {|score, pair| score + frequency_score(pair)}
end
def frequency_score(pair)
triple_score(pair) + single_score(pair)
@jakcharlton
jakcharlton / .gitignore
Created September 12, 2011 11:48
Git ignore for VS
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo