Skip to content

Instantly share code, notes, and snippets.

@deejaygraham
deejaygraham / SimpleMidiFileWriter.cs
Created August 13, 2014 12:18
Simple Midi File Writer using NAudio Midi
using System;
using System.Collections.Generic;
using System.Linq;
using NAudio.Midi;
class Program
{
static void Main(string[] args)
{
// typical args :
@deejaygraham
deejaygraham / RomanNumeralTest.cs
Created August 31, 2017 12:44
Example Roman Numerals Kata in c#
using NUnit.Framework;
[TestFixture]
public class RomanNumeralTest
{
[Test]
public void Zero_Returns_Empty_String()
{
Assert.AreEqual(string.Empty, RomanNumerals.ToRoman(0));
@deejaygraham
deejaygraham / asteroids.py
Created November 24, 2016 15:29
Tiny Asteroids game for Microbit
# Tiny Asteroids with exploding ship for Microbit
from microbit import *
import random
# board dimensions
pixel_width, pixel_height = 4, 4
Frame_Rate_In_Milliseconds = 500
# general game functions
@deejaygraham
deejaygraham / Replace-ConfigSecrets.ps1
Last active July 20, 2020 09:43
Powershell script to replace simple placeholder values in config file with production values
Function Replace-ConfigSecrets
{
[CmdletBinding()]
Param (
[string]$ConfigPath
)
$Replacements = @{
'##MY_CREDENTIALS_USERNAME##' = 'This is not my user name'
@deejaygraham
deejaygraham / dinosaur-detector.py
Created September 24, 2018 20:57
Microbit detects vibration in case there are T-Rexs or other dinosaurs nearby
from microbit import *
sleep_time = 200
warning_time = 5000
class Pinger:
def __init__(self):
self.direction = 1
self.x = 2
@deejaygraham
deejaygraham / still-alive.py
Created April 17, 2018 11:47
rough draft of still-alive for the microbit
from microbit import *
import speech
note_name_to_value = {
"c3" : "58",
"cs3" : "55",
"d3" : "52",
"ds3" : "49",
"e3" : "46",
"f3" : "44",
@deejaygraham
deejaygraham / ClientCode.cs
Created May 8, 2014 11:43
Unit testable implementation of HttpMessageHandler
// using the default handler sends requests to
// the interwebs...
HttpClient httpClient = new HttpClient();
var response = httpClient.GetAsync(url).Result;
@deejaygraham
deejaygraham / langtons-ant.py
Last active January 9, 2018 17:35
Microbit implementation of Langton's Ant cellular automata
# https://en.wikipedia.org/wiki/Langton's_ant
from microbit import *
import random
def create_new_ant():
return [random.randint(0, 4), random.randint(0, 4)] # start at a random place on the board
def pick_direction(compass_points):
return random.choice(compass_points)
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="SetTFSVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Name ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<!-- https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md -->
<Task>
@deejaygraham
deejaygraham / environment.targets
Created November 27, 2017 14:30
Create an environment variable in inline msbuild task
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Name ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />