Skip to content

Instantly share code, notes, and snippets.

@davidalpert
davidalpert / IsAssignableTo.cs
Created November 8, 2013 22:41
A convenience method that inverts IsAssignableFrom to be semantically more straightforward.
/// <summary>
/// A convenience method that inverts <see cref="IsAssignableFrom"/> to be
/// semantically more straightforward.
/// </summary>
public static bool IsAssignableTo(this Type source, Type target)
{
return target.IsAssignableFrom(source);
}
@davidalpert
davidalpert / first draft
Last active December 26, 2015 10:59
FluentValidation question
RuleFor(x => x.EnteringAirTemperature)
.GreaterThanOrEqualTo(50)
.WithMessage("{0}", eat =>
{
if (40 <= eat.NumericValue && eat.NumericValue < 50)
{
return "An '{PropertyName}' value of '{PropertyValue}' requires low temperature construction. " +
"Please select LTAF or LTFF liners.";
}
#!/usr/bin/env ruby
require 'json'
require 'rake'
require 'date'
#include FileUtils
pattern_to_search = "./path/to/files/*.json"

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade
var $;
// Add jQuery
(function(){
if (typeof unsafeWindow.jQuery == 'undefined') {
var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement,
GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
GM_JQ.type = 'text/javascript';
@davidalpert
davidalpert / .gitconfig
Created May 7, 2013 08:21
the core of my .gitconfig file
[user]
email = [email protected]
name = David Alpert
[core]
autocrlf = true
safecrlf = false
[color]
branch = auto
diff = auto
status = auto
@davidalpert
davidalpert / ExampleWithOneProjectAndSolutionFolder.sln
Created May 5, 2013 19:35
Example VS2012 solution file with 1 project, default build configurations, and the now-standard .nuget solution folder.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpWebAdapters", "HttpWebAdapters\HttpWebAdapters.csproj", "{AE7D2A46-3F67-4986-B04B-7DCE79A549A5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8374A24A-6031-48CB-8B66-A2B510FA251F}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
@davidalpert
davidalpert / SolutionWithOneProject.sln
Last active December 17, 2015 00:38
A sample VS2012 solution file with 1 project and it's default build configurations.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpWebAdapters", "HttpWebAdapters\HttpWebAdapters.csproj", "{AE7D2A46-3F67-4986-B04B-7DCE79A549A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
@davidalpert
davidalpert / EmptySolution.sln
Created May 5, 2013 19:29
An empty VS2012 solution file.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@davidalpert
davidalpert / MSpecStackTraceParser
Created March 13, 2013 02:55
a *rough* cut of the MSpec support that Llewellyn Falco and I added to ApprovalTests.NET: https://github.com/approvals/ApprovalTests.Net/commit/98f1ae7ec004a42f2e30c3c550cf58db42e54b0e
public class MSpecStackTraceParser : IStackTraceParser
{
private Caller _caller;
private string approverMethodName;
public bool Parse(StackTrace stackTrace)
{
_caller = new Caller(stackTrace, 0);
var approvalFrame = FindApprovalFrame();
if (approvalFrame == null) return false;