Skip to content

Instantly share code, notes, and snippets.

View markheath's full-sized avatar

Mark Heath markheath

View GitHub Profile
@markheath
markheath / yahtzee.py
Created June 20, 2011 22:08
Yahtzee code kata in Python
import unittest
#helpers
def HighestRepeated(dice, minRepeats):
unique = set(dice)
repeats = [x for x in unique if dice.count(x) >= minRepeats]
return max(repeats) if repeats else 0
def OfAKind(dice, n):
return HighestRepeated(dice,n) * n
@markheath
markheath / XhtmlToMarkdownConverter.cs
Created February 15, 2012 19:07
Convert XLST to Markdown with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Reflection;
using System.Xml;
@markheath
markheath / MP3StreamingPanelPlugin.cs
Created August 9, 2012 07:06
NAudio Demo modified to play ShoutCast (courtesy of Stephen Cole)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NAudio.Wave;
using System.Net;
using System.Threading;
@markheath
markheath / simplequiz.html
Created October 9, 2012 15:40
Experimenting with JQuery to make a simple quiz framework
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Simple JQuery Quiz</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
@markheath
markheath / recursive-factorise-1.fs
Last active December 27, 2015 08:19
recursive factorization function in F#
let rec f n x acc =
if x = n then
x::acc
elif n % x = 0 then
f (n/x) x (x::acc)
else
f n (x+1) acc
let factorise n = f n 2 []
let factors = factorise 124782
@markheath
markheath / AudioPlaybackEngine.cs
Created February 3, 2014 13:42
FireAndForget NAudio Sample
using System;
using NAudio.Wave;
using NAudio.Wave.SampleProviders;
namespace FireAndForgetAudioSample
{
class AudioPlaybackEngine : IDisposable
{
private readonly IWavePlayer outputDevice;
private readonly MixingSampleProvider mixer;
@markheath
markheath / ButtonStackPanel.xaml
Created May 29, 2014 13:55
Example WPF Button Template
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style x:Key="MyFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<Grid Margin="3 2">
@markheath
markheath / BextChunkInfo.cs
Created September 10, 2014 14:19
Creating RF64 and BWF WAV Files with NAudio
using System;
namespace NAudioUtils
{
// https://tech.ebu.ch/docs/tech/tech3285.pdf
class BextChunkInfo
{
public BextChunkInfo()
{
//UniqueMaterialIdentifier = Guid.NewGuid().ToString();
@markheath
markheath / VerticalProgressBarStyles.xaml
Created November 6, 2014 11:27
WPF Vertical Progress Bar Styles
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style TargetType="ProgressBar" x:Key="Basic">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar" >
<Grid x:Name="Root">
<Border
@markheath
markheath / index.html
Last active November 20, 2015 05:59
Migrate from Syntax Highlighter to Highlight.js
<!DOCTYPE html>
<html lang=en-us>
<head>
<meta charset=utf-8><title>Highlight JS</title>
<meta name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1">
<link rel=stylesheet href=//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/tomorrow-night.min.css"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/languages/fsharp.min.js"></script>