This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module OptionTypeConverter | |
open System | |
open Microsoft.FSharp.Reflection | |
open Newtonsoft.Json | |
// http://gorodinski.com/blog/2013/01/05/json-dot-net-type-converters-for-f-option-list-tuple/ | |
type OptionTypeConverter() = | |
inherit JsonConverter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open Newtonsoft.Json | |
open OptionTypeConverter | |
let jsonSettings = JsonSerializerSettings() | |
jsonSettings.NullValueHandling <- NullValueHandling.Ignore | |
jsonSettings.Converters.Add(OptionTypeConverter()) | |
let serialize obj = JsonConvert.SerializeObject obj | |
let serialize' obj = JsonConvert.SerializeObject(obj, jsonSettings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type Message = | |
| Default | |
| Custom of string | |
type Person = { | |
name : string | |
age : int | |
} | |
let person name age = {name = name; age = age } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Comparer<T> : IEqualityComparer<T> | |
{ | |
private readonly Func<T, int> _getHashCode; | |
private readonly Func<T, T, bool> _equals; | |
public Comparer(Func<T, T, bool> equals) : this(equals, null) | |
{ | |
} | |
public Comparer(Func<T, int> getHashCode) : this(null, getHashCode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14) | |
gci *.ttf | %{ $fonts.CopyHere($_.fullname) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContentType : Enumeration<int, ContentType> | |
{ | |
public static readonly ContentType Json = new ContentType(1, "Json", "application/json"); | |
public static readonly ContentType Pdf = new ContentType(2, "PDF", "application/pdf"); | |
public static readonly ContentType Text = new ContentType(3, "Text", "text/plain"); | |
public string HeaderValue { get; private set; } | |
private ContentType(int key, string displayName, string headerValue) : base(key, displayName) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Password hacking: How many possible numbers exist to hack a password with the rules below, and what are they? | |
1. Composed of the digits 1-9 | |
2. 2-9 digits in length | |
3. Digits do not repeat | |
4. Digits are in ascending order | |
Output should include a full list of possible password strings and the total count. | |
Good examples | |
29 | |
234 |