Skip to content

Instantly share code, notes, and snippets.

public static class SystemTime
{
private static readonly ThreadLocal<Func<DateTime>> _Now = new ThreadLocal<Func<DateTime>>(() => () => DateTime.Now);
public static DateTime Now
{
get { return _Now.Value(); }
}
public static ResetSystemTime Set(DateTime executionTime)
@ryanohs
ryanohs / choropleth.htm
Last active August 29, 2015 13:57
Presentation examples for Nebraska Code Camp.
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script src="us-states.js"></script>
</head>
<body>
<div id="map" style="height: 580px"></div>
<script>
using System;
using System.IO;
public class LogSearcher
{
public static int DateLength = "2013-12-29 17:37:56".Length;
public void Search(string path, DateTime start, DateTime end, TextWriter results)
{
using (var file = File.Open(path, FileMode.Open))
@ryanohs
ryanohs / gist:2048500
Created March 16, 2012 04:24
Merge Sort - CoffeeScript
mergesort = (input) ->
n = input.length
if n == 1
return input
pivot = Math.floor n/2
a = mergesort input[0...pivot] # coffee script does not include the last element in a slice
b = mergesort input[pivot...n]
merge(a, b)
merge = (a, b) ->
@ryanohs
ryanohs / gist:2048499
Created March 16, 2012 04:24
Merge Sort - C++
int* mergesort(int input[], size_t length)
{
if(length == 1)
{
return input;
}
int pivot = length/2;
size_t a_length = pivot;
size_t b_length = length-pivot;
int *a = mergesort(input, a_length);
@ryanohs
ryanohs / gist:844100
Created February 25, 2011 17:09
DDD update sample
public class TradeController
{
private readonly IRepository<Trade> _Trades;
public TradeController(IRepository<Trade> trades)
{
_Trades = trades;
}
[ValidationExceptionFilter]