Skip to content

Instantly share code, notes, and snippets.

View mitchdenny's full-sized avatar
💭
Currently setting my user status :)

Mitch Denny mitchdenny

💭
Currently setting my user status :)
View GitHub Profile
@mitchdenny
mitchdenny / BasicCalculatorSpecification.cs
Created December 31, 2010 02:15
This is a specification for a calculator with no implementation provided.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MSTestContrib.Specifications;
namespace Calculator.Core.Specifications
{
[TestClass]
[SpecificationDescription("As a user I want to perform mathematical calculations so that my head doesn't hurt.")]
public class BasicCalculatorSpecification : Specification
{
@mitchdenny
mitchdenny / BasicCalculatorSpecification.cs
Created December 31, 2010 02:31
This is a specification for a basic calculator with the implementation rounded out.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MSTestContrib.Specifications;
namespace Calculator.Core.Specifications
{
[TestClass]
[SpecificationDescription("As a user I want to perform mathematical calculations so that my head doesn't hurt.")]
public class BasicCalculatorSpecification : Specification
{
public class SubscriptionController : Controller
{
public SubscriptionController(ISubscriberRepository subscriberRepository, IObserver<SubscribedToNewsletter> subscribedToNewsletterObserver, IObserver<UnsubscribedFromNewsletter> unsubscribedFromNewsletterObserver)
{
SubscriberRepository = subscriberRepository;
SubscribedToNewsletterObserver = subscribedToNewsletterObserver;
UnsubscribedFromNewsletterObserver = unsubscribedFromNewsletterObserver;
}
}
@mitchdenny
mitchdenny / ShortUrlTokenGenerator.cs
Created April 3, 2011 08:42
The purpose of this class is to generate a random short URL.
using System;
public static class ShortUrlTokenGenerator
{
private const string alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
private static Random generator = new Random();
public static string GenerateToken(int tokenLength)
{
var builder = new StringBuilder();
@mitchdenny
mitchdenny / pisetup.sh
Created December 27, 2012 04:33
A quick little script to remind me of the packages that I like to install on my Raspberry Pi device.
sudo apt-get install nodejs npm node-semver
sudo apt-get install mono-complete
sudo apt-get install emacs
@mitchdenny
mitchdenny / MainViewModel.cs
Created February 2, 2013 10:53
Some code from a WP8 application that uses the proximity sensor.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
using Windows.Networking.Proximity;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Excel Selection Changed Demo</title>
<link rel="stylesheet" type="text/css" href="../Content/Office.css" />
<link rel="stylesheet" type="text/css" href="../Content/App.css" />
<script src="../Scripts/jquery-1.7.1.js"></script>
<!--<script src="https://appsforoffice.microsoft.com/lib/1.0/hosted/office.js"></script>-->
@mitchdenny
mitchdenny / Web.config
Last active December 14, 2015 23:39
Example code to support executing Node.js in a particular sub-folder of an ASP.NET web-site.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="Node">
<system.webServer>
<handlers>
<add name="iisnode" path="*.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument enabled="true">
<files>
<add value="server.js" />
@mitchdenny
mitchdenny / server.js
Created March 15, 2013 04:32
Some code that shows how to implement background execution in Node running on Windows Azure (or iisnode generally).
var status = {
started: Date.now(),
heartbeat: Date.now(),
runtime: null
};
var heartbeater = function() {
status.heartbeat = Date.now();
status.runtime = status.heartbeat - status.started;
setTimeout(heartbeater, 1000);
@mitchdenny
mitchdenny / Program.cs
Created June 15, 2016 20:59
Executing a WIQL Query
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace FlatQuerySample