Skip to content

Instantly share code, notes, and snippets.

View mikehadlow's full-sized avatar

Mike Hadlow mikehadlow

View GitHub Profile
@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;
@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;
@mikehadlow
mikehadlow / ManyWaysToStartAThread.cs
Last active December 24, 2015 13:49
The many ways to start a thread in .NET. Can you think of any more?
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Mike.Spikes.Threading
{
public class ManyWaysToStartAThread
{
public void WithThread()
{
@mikehadlow
mikehadlow / Astrology Smackdown
Created October 15, 2013 15:27
Somebody in the office was defending astrology. Their argument went something like this: You concede that the Moon is known to effect natural phenomena on Earth. Jupiter is a far larger body, although granted it is further away, so it must have some effect as well.
Newton's law of universal gravitation:
http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
F = G(m1 * m2)/r^2
Mass of the Earth: 5.97219 × 10^24 kg
Mass of the Moon: 7.3477 × 10^22 kg
Distance to the Moon (average): 384,400 km
@mikehadlow
mikehadlow / IBus.cs
Created November 15, 2013 14:49
EasyNetQ's proposed new send/receive API. This is for sending messages explicitly to a named destination queue via the default exchange. The Receive call creates a consumer for the specified message type. Further calls to Receive with the same queue, but a different message type will add additional message handlers to the same consumer.
/// <summary>
/// Send a message directly to a queue
/// </summary>
/// <typeparam name="T">The type of message to send</typeparam>
/// <param name="queue">The queue to send to</param>
/// <param name="message">The message</param>
void Send<T>(string queue, T message);
/// <summary>
/// Receive messages from a queue.
FROM nornagon/postgres
MAINTAINER mike@suteki.co.uk
ADD sql sql
ADD create_db.sh /src/
USER postgres
RUN /src/create_db.sh
@mikehadlow
mikehadlow / README.md
Last active August 29, 2015 14:02
Segment Clock

A little D3js demo of a clock based on circle segments, more normally used for creating pie charts. I've speeded up time to 1 second == 1 hour to make it a little more visually interesting.

@mikehadlow
mikehadlow / README.md
Last active August 29, 2015 14:02
Predict Your Awesomeness

The results of playing with building graphs using D3js. This doesn't really predict your awesomeness over the next 100 days, it's entirely random, so if you don't like the results, just hit refresh to see if you get a better prediction :)

@mikehadlow
mikehadlow / README.md
Last active July 25, 2023 08:55
D3js Graph with X and Y crosshairs, and a threshold line.

Example of a D3js time series graph with X,Y crosshairs and a threshold line. Just copy the drawLineGraph function and call it with your data. The data shoud be an array of two element arrays. Something like:

var data = [
    [new Date(2014, 01, 10), 404],
    [new Date(2014, 01, 11), 123],
    [new Date(2014, 01, 12), 666]
    ];
    
var warnLine = { lineValue: 200, label: 'my important threshold' };