Skip to content

Instantly share code, notes, and snippets.

dlidstrom / Main.elm
Last active August 15, 2019 14:15
Elm counter sample with flags
View Main.elm
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
type alias Flags =
{ counter : Int }
type Msg = Increment | Decrement
type Model = Model Int
init : Flags -> (Model, Cmd Msg)
dlidstrom / Result.fs
Last active September 20, 2019 12:11
Mix of result and applicative
View Result.fs
module Result =
let bind f = function
| Ok x -> f x
| Error x -> Error x
let map f = function
| Ok x -> Ok(f x)
| Error err -> Error err
let apply fResult xResult =
module Main where
import Prelude
type Student = {
first :: String,
last :: String,
class :: String
dlidstrom / keybindings.json
Last active December 17, 2018 15:52
Visual Studio Code Keybindings
View keybindings.json
// Place your key bindings in this file to overwrite the defaults
"key": "ctrl+down",
"command": "editorScroll",
"args": {
"to": "down",
"by": "line",
"revealCursor": true
View MessageChecksumConverter.cs
public class MessageChecksumConverter : PatternLayoutConverter
private static readonly TraceSource Source = new TraceSource(nameof(MessageChecksumConverter));
private static readonly MD5 ChecksumGenerator = MD5.Create();
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
var output = TryGetHash(loggingEvent);
dlidstrom / Teachers.cs
Last active October 25, 2018 12:08
Plan teachers week schedule
View Teachers.cs
namespace Csp
using System;
using System.Collections.Generic;
using System.Linq;
using Decider.Csp.BaseTypes;
using Decider.Csp.Global;
using Decider.Csp.Integer;
public static class Program
dlidstrom / angular-deps.js
Last active December 25, 2022 19:44
Outputs all dependencies in the Angular module in a graphviz friendly format
View angular-deps.js
includeList = {
// put desired module names here
skipList = {};
handledList = {};
function handleModule(module) {

Logging & Meta Tests


Define the operations being done by the application as discrete units of work. Examples: commands, queries, startup, shutdown. Define explicit boundaries between units of work. This makes it easy to log the operations of the application.

  • Log startup scenario together with settings. I.e. read all settings at application startup, and only there.
  • Log commands and queries. For commands, log command type and eventual return value. For queries, log the query type and the query result.
  • Define a logging gateway with convenience methods for logging application events. Define a class that represents an application event and define all known application events in a single, static and application-specific, class. Application events are lower-level than business events. For example: ExecutingCommand, CommandResult, Starting, Started, ShuttingDown, BeginRequest, EndRequest.
  • Application events should have their own event id.
  • Build infrastructure layer that takes care of applicat
View gravatar.cs
using (var md5 = System.Security.Cryptography.MD5.Create())
var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(""));
var sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
dlidstrom / watch.ps1
Created June 15, 2016 10:12
watch a file changes in the current directory
View watch.ps1
# watch a file changes in the current directory,
# execute some command when a file is changed or renamed
if (($BatFile -eq $null) -or (-not (Test-Path -Path $Batfile)))
"Specify bat file to run continuously."