Skip to content

Instantly share code, notes, and snippets.

View mikehadlow's full-sized avatar

Mike Hadlow mikehadlow

View GitHub Profile
@mikehadlow
mikehadlow / Geolocation.htm
Created November 17, 2010 10:35
HTML5 / Google maps api, Get the long name of the current user's coujntry
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Geolocation Demo</title>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="Geolocation.js" type="text/javascript"></script>
<style type="text/css">
body
@mikehadlow
mikehadlow / Suteki.TestRunner.js
Created January 20, 2011 12:22
A little javascript test runner for node.js
// run unit tests in node like this:
// node Suteki.TestRunner.js
//
// Unit tests should be named like this:
// Suteki.<name target>.Tests.js
//
// A test looks like this:
//
// (function(){
//
@mikehadlow
mikehadlow / UserTypeSpike.cs
Created February 7, 2011 10:08
Fluent NHibernate failing test (can insert into FluentNHibernate.Testing and run)
using System;
using System.Data;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Conventions;
using FluentNHibernate.Mapping;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.SqlTypes;
using NHibernate.Tool.hbm2ddl;
@mikehadlow
mikehadlow / IoC.cs
Created February 8, 2011 10:05
My common service locator replacement
using System;
namespace Suteki.Common.Windsor
{
public class IoC
{
private static Func<Type, object> resolve;
private static Action<object> release;
public static T Resolve<T>()
@mikehadlow
mikehadlow / WindsorExtensions.cs
Created May 27, 2011 14:09
A Windsor registration checking extension method
using System.Linq;
using Castle.Windsor;
namespace Suteki.Common.Windsor
{
public static class WindsorExtensions
{
public static void CheckRegistration<TService, TImplementation>(this IWindsorContainer container)
{
var handlers = container.Kernel.GetHandlers(typeof(TService));
@mikehadlow
mikehadlow / Euler.hs
Created June 9, 2011 08:19
Project Euler 1 to 10 in Haskell
import List
import Control.Applicative
euler1 = sum $ nub $ [3,6..999] ++ [5,10..999]
fib = let fib' a b = a : fib' b (a+b) in fib' 0 1
euler2 = sum . (filter even) . takeWhile (<4000000) $ fib
factor n = [x|x <- [2..(floor(sqrt(fromInteger n)))], n `mod` x == 0]
@mikehadlow
mikehadlow / CameraOutput.cs
Created August 1, 2012 09:49
Attempting to capture iSight camera output
// from the QTRecorder sample application in the MonoMac source
// In QTRDocument contructor ....
// ---- Add image capture output
var decompressedVideoOuput = new QTCaptureDecompressedVideoOutput();
NSError error2;
decompressedVideoOuput.DidOutputVideoFrame += (sender, e) =>
{
// var frame = e.SampleBuffer;
using System;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace MyProject.Tests
{
public class AsyncNamingConventionTests
{
[Fact]
@mikehadlow
mikehadlow / SshWrapperTsets.fs
Created May 15, 2013 16:00
Rather pleased with my monadic SSH.NET wrapper
[<Test>]
[<Explicit>]
let ``get hostname`` () =
ssh (print <!> hostname)
[<Test>]
[<Explicit>]
let ``should be able to put a file on the nginx server`` () =
scp (putFile testFileName content)
ssh (reader {
@mikehadlow
mikehadlow / ClientCommandDispatcherTests.cs
Created October 1, 2013 11:30
Some tests for EasyNetQ's new ClientCommandDispatcher.
// ReSharper disable InconsistentNaming
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EasyNetQ.ConnectionString;
using EasyNetQ.Loggers;
using EasyNetQ.Producer;