Skip to content

Instantly share code, notes, and snippets.

View jakcharlton's full-sized avatar

Jak Charlton jakcharlton

View GitHub Profile
@jakcharlton
jakcharlton / 1.9.3.md
Created February 18, 2012 22:24
Ruby 1.9.3 and Rails 3.2 on Heroku

http://railsapps.github.com/rails-heroku-tutorial.html

Ruby 1.9.3 and Rails 3.2 on Heroku Heroku’s newest stack, “Celadon Cedar,” supports Rails 3.2 but installs Ruby 1.9.2 by default. Ruby 1.9.3 is recommended for Rails 3.2.

You can configure the Heroku environment to use Ruby 1.9.3.

Note: Heroku makes it clear that Ruby 1.9.3 on Heroku is experimental, which means “no support, the ruby_version will change in the future, and this feature may change or be removed without warning.” In response to an inquiry on January 31, 2012, Heroku said, “there is no timeline yet” to fully support Ruby 1.9.3.

Install the heroku-labs plugin:

@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
@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 / 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 / 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 / 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 / singleactioncontroller.cs
Created July 11, 2011 01:12
MVC Single Action Controller
public class IndexController : Controller
{
[Authorize]
public ActionResult Index()
{
return View();
}
}
@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 / 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 / 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))