Skip to content

Instantly share code, notes, and snippets.

View cromwellryan's full-sized avatar

Ryan Cromwell cromwellryan

View GitHub Profile
@cromwellryan
cromwellryan / bad.js
Created April 5, 2012 18:57
Moving from high churn to low churn, single responsibility, common closure-y code
function calculatebonus( employee, currentsalary ) {
var bonus = 0;
switch( employee.ReviewResult ) {
case "Good":
return 0.025 * currentsalary;
case "Great":
return 0.04 * currentsalary
case "InvestementBanker":
return 2 * currentsalary;
}
using System;
using System.Dynamic;
using System.Linq;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class SmokeTestController : Controller
{
private readonly Func<SmokeTestResult>[] smokeTests;
@cromwellryan
cromwellryan / Microsoft.Web.Publishing.targets.xml
Created May 3, 2012 02:35
.Net 2.0 MSBuild file for ASP.Net projects
<!--
***********************************************************************************************
Microsoft.Web.Publishing.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your web deploy projects from the command-line or the IDE.
This file defines the steps in the standard build process to deploy web application projects.
@cromwellryan
cromwellryan / .gitignore
Created May 5, 2012 18:34
Conways GOL in Coffeescript with Underscore
node_modules
@cromwellryan
cromwellryan / wrapper.coffee
Created June 8, 2012 17:40
Word wrap Kata in coffeescript
wrap = (sent, col) ->
result = ''
if sent.length <= col
result = sent
else
space = sent.substring(0,col).lastIndexOf(' ')
wrapline = (sent, stop, skip) ->
sent.substring(0,stop) + '\n' + wrap(sent.substring(stop+skip),col)
@cromwellryan
cromwellryan / host.ps1
Created August 17, 2012 22:44
Host a directory using IIS Express a-la python -m http.server
function start-host($root) {
$iisexpress = "$env:ProgramFiles\\IIS Express\\iisexpress.exe"
if (!(test-path $iisexpress)) {
write-error "Unable to locate IIS Express at $iisexpress"
return
}
$approot = resolve-path $root
@cromwellryan
cromwellryan / commitmessage.txt
Created August 22, 2012 15:55
An acceptable commit message?
Refactoring done earlier didn't execute acceptance tests. This makes me wonder why we even have acceptance tests. The acceptance tests (and the bug they surfaced) are fixed. Ugh. Professionalism people. Please.
namespace ClassLibrary3
{
using System.Diagnostics;
using Xunit;
public class CombiningEnums
{
[Fact]
public void EnumsCanBeXored()
@cromwellryan
cromwellryan / drive.js
Created October 16, 2012 17:55
DCC 12-2012
describe('panda',function(){
it('scalene',function(){
expect(classify(1,2,3)).toBe('scalene');
});
it('isosceles', function() {
expect(classify(2,2,3)).toBe('isosceles');
expect(classify(1,2,2)).toBe('isosceles');
expect(classify(2,1,2)).toBe('isosceles');
});
nodeProcessCommandLine: "node_modules/coffee-script/bin/coffee app.coffee"