This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
def romanToInt(str): | |
table = [ ['M', 1000], ['D', 500], ['C', 100], ['L', 50], ['X', 10], ['V', 5], ['I', 1] ] | |
sum = 0 | |
previous = 999999 | |
chars = str.split() | |
for c in chars: | |
for pair in table: | |
if (pair[0] == c): | |
val = pair[1] | |
sum = sum + val |
<?xml version="1.0" encoding="utf-8" ?> | |
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> | |
<class name="Company.Domain.Orders.GiftCard, Company.Domain" table="GiftCards"> | |
<id name="GiftCardId" column="GiftCardId" type="Int32" unsaved-value="0"> | |
<generator class ="native" /> | |
</id> | |
<many-to-one name="Order" column="OrderId" class="Company.Domain.Orders.Order, Company.Domain" not-null="true" /> | |
<property name="PIN" column="PIN" length="4" not-null="true" /> | |
<property name="Number" column="Number" type="string" not-null="true" /> | |
<property name="RedemptionAmount" column="RedemptionAmount" type="Company.Data.MoneyUserType, Company.Data" not-null="true" /> |
public class Mapper : IMapper | |
{ | |
private static readonly bool initialized; | |
private static readonly object lockObject = new object(); | |
static Mapper() | |
{ | |
if(initialized) | |
return; |
public void Run() | |
{ | |
IEnumerable<LookupEntry> parsedDimensions = parser.BuildTopDimensions(); | |
IEnumerable<LookupEntry> currentDimensions = dimensionService.GetDimensions(); | |
IDictionary<string, LookupEntry> mostRecentVersions = dimensionVersioner.GetMostRecentVersions(currentDimensions); | |
IEnumerable<LookupEntry> dimensionsToVersion = dimensionVersioner.Version(parsedDimensions, getMostRecentVersions); | |
dimensionService.AddDimensions(dimensionsToVersion); |
public interface ISpecification<T> | |
{ | |
bool IsSatisfiedBy(T candidate); | |
ISpecification<T> And(ISpecification<T> other); | |
ISpecification<T> Or(ISpecification<T> other); | |
ISpecification<T> Not(); | |
} | |
public abstract class Specification<T> : ISpecification<T> | |
{ |
var assemblyProvider = new AssemblyProvider(yourAssembly); | |
var assembly = assemblyProvider.MoveAssembly(destinationFileName); | |
return new FileStreamResult(assembly.FileStream, "application/octet-stream") | |
{ | |
FileDownloadName = assembly.Name | |
}; |
public class CustomServerHeaderModule : IHttpModule | |
{ | |
public void Init(HttpApplication context) | |
{ | |
context.PreSendRequestHeaders += (sender, e) => ((HttpApplication)sender).Response.Headers.Remove("Server"); | |
} | |
public void Dispose() | |
{ | |
} |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
[Test] | |
public void SearchController_routes_MotorcycleSearch_correctly() | |
{ | |
"~/motorcycle-search/handlebars".ShouldMapTo<SearchController>(x => x.SingleSearch("handlebars")); | |
} | |
[Test] | |
public void SearchController_routes_Product_correctly() | |
{ | |
var route = "~/product/123-456".ShouldMapTo<SearchController>(x => x.ProductDetail(null)); |
(function($) { | |
$.productFeedback = function(element, options) { | |
var defaults = { | |
idPrefix: "productFeedbackElement", | |
message: "Was this information helpful?", | |
containerClass: "product-feedback", | |
linkClass: "clickable", | |
postAction: "/feedback/add", |