Instantly share code, notes, and snippets.

# Liam McLennan liammclennan

Last active Aug 29, 2015
Pitch frequency code puzzle
View gist:aa1b3a5e74eb3ff01898
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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
Created May 27, 2015
Partitioning events with Akka.net (linqpad - reference akka.net and Rx-main)
View gist:542cb1264305f525c70b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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();
Created May 15, 2015
Scoping Workshop
View gist:11033b3c5a19f2b1e14c

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)

Last active Apr 17, 2020
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.

Created Apr 28, 2015
Observable Stream Processing
View gist:c8c23313da3da1ab9e4e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 void Main() { Topology.Run(new RxDelta(), Steps.CountUp, Steps.CountDown, Steps.Mod7, Steps.Product, Steps.SlidingAverage, Steps.Printer );
Created Apr 28, 2015
Stream processing via redis
View result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 void Main() { var sub = Topology.Run("192.168.85.128"/* redis address*/, new Action [] { Topology.SplitToWords, Topology.WordCounter }); var data = new List { "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
Created Apr 13, 2015
Mars Rover problem in F#
View gist:160dc400a2a9629a2f5a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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
Created Mar 11, 2015
Euclid usage
View gist:50d58f366b99f38f5926
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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(), {}]; });
Created Feb 12, 2015
Mapping serialized tuples (F#) to JavaScript objects
View gist:8c642478f6e39c1303d2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // 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) {
Last active Aug 29, 2015
View Developer.md

#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