Skip to content

Instantly share code, notes, and snippets.

View markheath's full-sized avatar

Mark Heath markheath

View GitHub Profile
@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 / 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 / sfmesh-example-voting-app.json
Created October 24, 2018 13:57
Service Fabric Mesh voting app.
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"voteReplicaCount":{
"defaultValue": "1",
"type": "string",
"metadata": {
"description": "The number of service replicas for the vote service."
}
@markheath
markheath / LinqPerformance.cs
Created May 6, 2016 20:47
Simple PLINQ and LINQ Optimizer performance test
var listSize = 10000000;
var stopwatch = new Stopwatch();
stopwatch.Restart();
var s = Enumerable.Range(1, listSize)
.Select(n => n * 2)
.Select(n => Math.Sin((2 * Math.PI * n)/1000))
.Select(n => Math.Pow(n,2))
.Sum();
stopwatch.Stop();
Console.WriteLine("LINQ {0} items in {1}ms", listSize, stopwatch.ElapsedMilliseconds);
@markheath
markheath / Azure ServiceBus Filtered Subscriptions.linq
Last active August 2, 2019 10:32
Using filtered subscriptions in Azure Service Bus
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.Serialization.dll</Reference>
<NuGetReference>WindowsAzure.ServiceBus</NuGetReference>
<Namespace>Microsoft.ServiceBus</Namespace>
<Namespace>Microsoft.ServiceBus.Messaging</Namespace>
</Query>
void Main()
{
string connectionString = Util.GetPassword("Test Azure Service Bus Connection String");
@markheath
markheath / run-from-package.ps1
Created January 14, 2019 16:57
Azure Web App run from package demo
$location = "West Europe"
$resGroupName = "RunFromPackageDemo"
az group create -n $resGroupName -l $location
$random = Get-Random -Minimum 10000 -Maximum 99999
$storageAccountName = "runfrompackage$random"
az storage account create -n $storageAccountName -g $resGroupName --sku "Standard_LRS"
$connectionString = az storage account show-connection-string -n $storageAccountName -g $resGroupName --query "connectionString" -o tsv
$env:AZURE_STORAGE_CONNECTION_STRING = $connectionString
@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 / 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 / index.html
Last active February 23, 2023 20:14
Flexbox simple blog layout
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container">