Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
dlidstrom / github-starter.markdown
Created Jan 11, 2011
Komma igång med GitHub
View github-starter.markdown

Hämta msysgit

Jag har version 1.7.3.1.msysgit.0. msysgit google.code

Git Alias

Sätt upp git med ditt namn och några alias:

C:\Users\Daniel>git config --global --list
user.name=Daniel Lidstrom
user.email=dlidstrom@gmail.com
alias.co=checkout
@dlidstrom
dlidstrom / Result.fs
Last active Sep 20, 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 =
@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 / Program.cs
Created Feb 4, 2014
Castle Windsor typed app settings
View Program.cs
[AppSettings("smtp:")]
public interface SmtpConfiguration
{
string Name { get; set; }
int Port { get; set; }
string Username { get; set; }
}
@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) {
@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 RowPolymorphism.ps
module Main where
import Prelude
type Student = {
first :: String,
last :: String,
class :: String
}
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 / commandBuffer-es6.js
Last active Jan 16, 2017
Command buffer service for AngularJS used to manage asynchronous calls in a synchronized fashion.
View commandBuffer-es6.js
/**
* This service is used to serialize asynchronous events.
* It uses a buffering solution: http://ricostacruz.com/backbone-patterns/animation-buffer.html
* To use it, put your asynchronous actions (animations/ajax) inside an anonymous function
* to be passed into add().
* Be sure to trigger next() when done.
*
* Example:
* commandBuffer.add(next => {
* somePromise.done(next);