Skip to content

Instantly share code, notes, and snippets.

View ChrisMissal's full-sized avatar
💭
set status

Chris Missal ChrisMissal

💭
set status
View GitHub Profile
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);
@ChrisMissal
ChrisMissal / specification.cs
Created October 18, 2010 18:36
A generic set of .Net classes to handle a specification pattern.
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>
{
@ChrisMissal
ChrisMissal / ControllerUsage.cs
Created March 12, 2011 02:32
This is an example of how to use the AssemblyProvider within a Controller.
var assemblyProvider = new AssemblyProvider(yourAssembly);
var assembly = assemblyProvider.MoveAssembly(destinationFileName);
return new FileStreamResult(assembly.FileStream, "application/octet-stream")
{
FileDownloadName = assembly.Name
};
@ChrisMissal
ChrisMissal / CustomServerHeaderModule.cs
Created June 1, 2011 16:32
This HttpModule removes the Server header from an ASP.NET Response.
public class CustomServerHeaderModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += (sender, e) => ((HttpApplication)sender).Response.Headers.Remove("Server");
}
public void Dispose()
{
}
@ChrisMissal
ChrisMissal / about.md
Created August 17, 2011 16:13 — forked from jasonrudolph/about.md
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));
@ChrisMissal
ChrisMissal / productFeedback.js
Created September 23, 2011 18:34
Product Feedback plugin
(function($) {
$.productFeedback = function(element, options) {
var defaults = {
idPrefix: "productFeedbackElement",
message: "Was this information helpful?",
containerClass: "product-feedback",
linkClass: "clickable",
postAction: "/feedback/add",