Foreword : Inspired by excellent post
Initial task: creating notification every 20 minutes can be decomposed into two parts:
create notification scheduled launch First subtask can be solved using this trivial script.
standup.sh:
#!/bin/sh # stand up notification osascript -e 'display notification "Stand up" with title "Healthy programmer"' say "Stand up" Second subtask (scheduled launch) can be solved using: daemon and agent mechanism.
Create file: com.example.stand.up.plist and place it into ~/Library/LaunchAgents/.
Replicated SQLite using the Raft consensus protocol written in Go #sqlite #raft #consensus #golang
It seems, its time to start learning go
Some haskell resources recommended by @bytemyapp.
CIS 194: Introduction to Haskell (Spring 2013) NICTA course Stanford CS240h Spring 2014 Path to learning haskell
One of the popular interivew tasks…
You are given a head of a linked list. Its known list contains cycle. The goal is to determine the length of the loop.
Here is straghtforward solution in haskell
{- data Node a instance Eq a => Eq (Node a) next :: Node a -> Node a -} data Phase = TryFindLoop | FindLength deriving (Eq) loopSize :: Eq a => Node a -> Int loopSize a = slowAndFast a a 0 TryFindLoop where slowAndFast :: (Eq node) => Node node -> Node node -> Int -> Phase -> Int slowAndFast slow fast len phase = let nextSlow = next slow nextPreFast = next fast nextFast = next nextPreFast in if (slow == nextPreFast || slow == nextFast) then if (phase == FindLength) then if (nextPreFast == nextFast) then 1 else 2*(len+1) - len - (if slow == nextFast then 0 else 1) else slowAndFast nextSlow nextSlow 0 FindLength else slowAndFast nextSlow nextFast (len + 1) phase Complexity: time o(n), memory o(1)
There is nice leiningen plugin named “Ultra” which can significantly improve your clojure’s repl interaction.
Main features:
colorized output of data structures (using solarized theme) clear test output better stacktraces java object introspection.