Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / hangman.hs
Last active September 28, 2019 15:25
A haskell implementation of the hangman game
import Control.Monad (when)
import Data.Char (toLower)
import Data.List (transpose)
import System.Random (randomIO)
wordsPath :: FilePath
wordsPath = "words.txt"-- "/usr/share/dict/words"
data GameState = GameState
{ _wordToGuess :: String
@ToJans
ToJans / histogram.exs
Last active May 8, 2019 11:51
To run, > elixir histogram.exs
defmodule Lab05 do
@doc """
My take on [the histogram exercise]
(http://computing.southern.edu/halterman/Courses/Fall2013/124/Labs/lab05_F13.html)
mentioned in [this newsgroup post]
(https://groups.google.com/d/msg/elixir-lang-talk/TTSjV0iy9yA/hpiGDZOk6DkJ)
"""
def main(), do: parse_pars(System.argv, nil)
defp parse_pars([],nil), do: histogram()
@ToJans
ToJans / anagram.cs
Last active April 30, 2018 14:44
Anagram in golang vs anagram in elixir-lang ; am I missing something obvious here?
using System.IO;
using System;
using System.Linq;
public class Anagram
{
// I am aware about, but have no intention on using
// `string.Equals(a, b, StringComparison.OrdinalIgnoreCase)`
// as that is longer
public static string[] Detect(string subject, string[] Candidates)

The story behind Virtual Sales Lab

The initial seed of the idea

The initial spark for Virtual Sales Lab was conceived during a late-night dinner with one of my business mentors.

Margareta's The exquisit but now defunct restaurant Margaretha's in Oudenaarde/Belgium was where it all happened

class MyConverter : Newtonsoft.Json.Converters.CustomCreationConverter<IDictionary<string, object>>
{
public override IDictionary<string, object> Create(Type objectType)
{
return new Dictionary<string, object>();
}
public override bool CanConvert(Type objectType)
{
// in addition to handling IDictionary<string, object>

A quick brain dump of the current techradar for Virtual Sales Lab

Hold

A gazillion things TBH....

Assess

  • Haskell
  • PureScript
@ToJans
ToJans / Tests.Veranda.fs
Last active October 20, 2016 11:53
canopy and fsharp to test the happy path for Virtual Sales Lab
module Tests
open canopy
open Utils
open System
let veranda (rootPath) = (rootPath + ": Veranda") &&& fun () ->
let clickNext expected fn =
click ".verandawizard.selected input[type=submit]"
@ToJans
ToJans / interfaces.cs
Last active October 11, 2016 09:50
Functor, applicative and monad interfaces
// In C# we can't enforce generic classes in interfaces, so we can't use interfaces to define the contract.
// I can only give examples of the minimal code it needs to implement.
class FunctorImpl<T> {
FunctorImpl<T> Pure(T val);
FunctorImpl<S> Apply<S>(Func<T, S> fn);
// Requirement: Pure(val).Apply(x=>x) == Pure(val)
}
class ApplicativeImpl<T> where {
@ToJans
ToJans / 00 Old specs.txt
Created November 15, 2011 09:02
Uniqueness in CQRS
When a user registers with a unique username
Then that registration should be approved
Given a user registration with a certain username was approved
When a new user registers with the same username
Then that registration should be rejected
@ToJans
ToJans / main.hs
Last active January 4, 2016 19:50
Zalora task
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Web.Scotty
import Network.Wai.Middleware.RequestLogger(logStdoutDev)
import Data.Aeson ( (.:),(.:?),decode,FromJSON(..),Value(..))
import Data.Text.Lazy (pack)
import Control.Applicative ((<$>), (<*>))
import qualified Data.ByteString.Lazy.Char8 as BS