Skip to content

Instantly share code, notes, and snippets.

@liammclennan
liammclennan / gist:aa1b3a5e74eb3ff01898
Last active August 29, 2015 14:27
Pitch frequency code puzzle
Write a function that calculates the number of semitones between two musical notes.
The notes are [A;ASharp;B;C;CSharp;D;DSharp;E;F;FSharp;G;GSharp].
The distance between each is 1 semitone. E.g. ASharp -> E = 6 semitones.
Twist: The notes can be in 3 different octaves. E.g. ASharp (octave 1) -> E (octave 2) = 18 semitones.
Extra credit: If A (octave 1) is 220Hz write a function that calculates the frequency of a note in an octave.
E.g. Frequency(A, 1) == 220, Frequency(A,2) == 440 etc
@liammclennan
liammclennan / gist:542cb1264305f525c70b
Created May 27, 2015 10:37
Partitioning events with Akka.net (linqpad - reference akka.net and Rx-main)
void Main()
{
var system = ActorSystem.Create("MySystem");
var greeters = system.ActorOf(Props.Create(() => new DeviceSplitter()));
var r = new System.Random();
var measures = Enumerable.Repeat(new [] {"a","b","c","d"}, 250000)
.SelectMany(c => c)
.Select (id => new Measure(id,r.Next()));
foreach (var m in measures) greeters.Tell(m);
Console.ReadLine();

A simple format for a scoping workshop

  1. Summarize goal / purpose of product. What is the vision? What is the anticipated value? (reduced cost, increased revenue, social benefit)

  2. What is the expected lifecycle of the product?

  3. Identify stakeholders / categories of users

  4. Map process (current state or desired)

@liammclennan
liammclennan / README.md
Last active April 17, 2020 18:29
RedisMQ

RedisMQ

Many people use Redis for a simple message broker. RedisMQ is a trivial layer on Redis and StackExchange.Redis that probably does not work. It provides two simple messaging patterns:

Publish / subscribe

A publisher publishes messages. 0, 1 or more consumers subscribe to the messages.

@liammclennan
liammclennan / gist:c8c23313da3da1ab9e4e
Created April 28, 2015 10:11
Observable Stream Processing
void Main()
{
Topology.Run(new RxDelta(),
Steps.CountUp,
Steps.CountDown,
Steps.Mod7,
Steps.Product,
Steps.SlidingAverage,
Steps.Printer
);
@liammclennan
liammclennan / result.txt
Created April 28, 2015 00:05
Stream processing via redis
void Main()
{
var sub = Topology.Run("192.168.85.128"/* redis address*/, new Action<StreamSource,StreamSink> [] {
Topology.SplitToWords, Topology.WordCounter
});
var data = new List<string> {
"You can also send events to an Event Hub asynchronously. Sending asynchronously can increase the rate at which a client is able to send events. Both the Send and SendBatch methods are available in asynchronous versions that return a Task object. While this technique can increase throughput, it can also cause the client to continue to send events even while it is being throttled by the Event Hubs service and can result in the client experiencing failures or lost messages if not properly implemented. In addition, you can use the RetryPolicy property on the client to control client retry options.",
"Although it is most common to send events to an Event Hub with a partition key, in some cases you might want to send events directly to a given partition. For example",
"Event Hubs has two primary models for event co
@liammclennan
liammclennan / gist:160dc400a2a9629a2f5a
Created April 13, 2015 22:41
Mars Rover problem in F#
type Direction = N | E | S | W
type Rover = {x:int;y:int;direction:Direction}
type Action = L | R | M
type Instruction = {rover:Rover; actions:Action list}
type Initialization = { upperRightX: int; upperRightY: int; instructions: Instruction list}
let testInput = "5 5
1 2 N
LMLMLMLMM
3 3 E
euclid.start([{
title: 'Home',
entry: function () {
return server.getDecks().then(function (decks) {
loginChanges();
var data = {decks: decks};
return [components.Home(data), data];
}, function () {
return [components.NotAuthenticated(), {}];
});
@liammclennan
liammclennan / gist:8c642478f6e39c1303d2
Created February 12, 2015 07:04
Mapping serialized tuples (F#) to JavaScript objects
// response from server
// "[{"item1":{"id":"ce957038-fed0-4c09-8594-5475efcac4d3","name":"https://github.com/liammcl..."},"item2":3}, ...]"
doSomethingAjaxing().then(mapSerializedTuples.bind(null, ['deck', 'count']));
// after mapping
// "[{"deck":{"id":"ce957038-fed0-4c09-8594-5475efcac4d3","name":"https://github.com/liammcl..."},"count":3}, ...]"
function mapSerializedTuple(keyNames) {
return function (tuple) {

#What is even Developer?#

#What skills differntiate me from the unwashed masses?#

  • Enthusiastic
  • Hunger for knowledge and learnings
  • I can right unit tests alright
  • I'm a team player