Skip to content

Instantly share code, notes, and snippets.

😃
Enjoying GitHub!

Daniel Lidström dlidstrom

😃
Enjoying GitHub!
Block or report user

Report or block dlidstrom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dlidstrom
dlidstrom / Main.elm
Last active Aug 15, 2019
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
dlidstrom / Result.fs
Last active Jun 7, 2019
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 =
View RowPolymorphism.ps
module Main where
import Prelude
type Student = {
first :: String,
last :: String,
class :: String
}
@dlidstrom
dlidstrom / keybindings.json
Last active Dec 17, 2018
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);
writer.Write(output);
}
@dlidstrom
dlidstrom / Teachers.cs
Last active Oct 25, 2018
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
dlidstrom / angular-deps.js
Last active Jan 21, 2019
Outputs all dependencies in the Angular module in a graphviz friendly format
View angular-deps.js
includeList = {
// put desired module names here
};
skipList = {};
handledList = {};
handleModule(window.app);
function handleModule(module) {
View LoggingAndMetaTests.md

Logging & Meta Tests

Logging

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("dlidstrom@gmail.com"));
var sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("x2"));
}
@dlidstrom
dlidstrom / watch.ps1
Created Jun 15, 2016
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
param($BatFile)
if (($BatFile -eq $null) -or (-not (Test-Path -Path $Batfile)))
{
"Specify bat file to run continuously."
exit
}
You can’t perform that action at this time.