This file contains hidden or 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
@echo off | |
cls | |
"NuGet.exe" "Install" "FAKE" "-OutputDirectory" "packages" "-ExcludeVersion" | |
"packages\FAKE\tools\Fake.exe" build.fsx %* | |
pause |
This file contains hidden or 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
namespace Money | |
{ | |
public class Money<TCurrency> where TCurrency : ICurrency | |
{ | |
private readonly decimal _value; | |
public Money(decimal value) | |
{ | |
_value = value; | |
} |
This file contains hidden or 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 Person | |
{ | |
private readonly PersonState _state; | |
public Person(string name) | |
{ | |
_state = new PersonState(name); | |
} | |
public string GetName() |
This file contains hidden or 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 Person = | |
open System | |
type PersonState = private { id: Guid; name: string; age: int} | |
let createPerson id name age = {id = id; name = name; age = age} | |
let changeName name personState = {personState with name = name} | |
let changeAge age personState = | |
// some crazy business rule involving age | |
{personState with age = age} | |
module SomeOtherModule = |
This file contains hidden or 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
// Implemented Jimmy Bogard's https://github.com/jbogard/presentations/tree/master/WickedDomainModels/After in F# | |
namespace FSharp.Wicked | |
open System | |
module Types = | |
type Id = Id of Guid | |
type Entity<'T> = Id * 'T | |
let createEntity state = Guid.NewGuid(), state |
This file contains hidden or 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
#r "./FSharp.Data.2.2.0/lib/net40/FSharp.Data.dll" | |
open FSharp.Data | |
open System | |
let rnd = Random() |
This file contains hidden or 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 CustomDirectRouteProvider : DefaultDirectRouteProvider | |
{ | |
protected override IReadOnlyList<IDirectRouteFactory> GetActionRouteFactories(HttpActionDescriptor actionDescriptor) | |
{ | |
return actionDescriptor.GetCustomAttributes<IDirectRouteFactory> | |
(inherit: true); | |
} | |
protected override string GetRoutePrefix(HttpControllerDescriptor controllerDescriptor) | |
{ |
This file contains hidden or 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 CharSpec = {Char:char; SndOffset: int} | |
type DiamondSpec = CharSpec list | |
let printDiamondRow charSpec = | |
match charSpec with | |
| {Char = x; SndOffset = 0} -> sprintf "%c" x | |
| {Char = x; SndOffset = y} -> sprintf "%c%s%c" x (String(' ', (y-1))) x | |
let padRow size (row:string) = |
This file contains hidden or 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 | |
let toDecStr = sprintf "%i" | |
let toOctStr = sprintf "%o" | |
let revStr (x:string) = String(x.ToCharArray() |> Array.rev) | |
let isPalindrom x = x = (revStr x) | |
let numPalCheck conv x = x |> conv |> isPalindrom | |
let decCheck = numPalCheck toDecStr | |
let octCheck = numPalCheck toOctStr | |
let checker x = (octCheck x) && (decCheck x) | |
let result = [1..1000000] |> Seq.filter checker |> Seq.length |
This file contains hidden or 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
$setupExe = "c:/files/SQLEXPRWT_x64_ENU.exe" | |
$adminsGroupName = (New-Object Security.Principal.SecurityIdentifier 'S-1-5-32-544').Translate([Security.Principal.NTAccount]).Value | |
Install-ChocolateyPackage 'SqlServer2012Express' 'exe' "/Q /INDICATEPROGRESS /ACTION=Install /FEATURES=SQL,Tools /TCPENABLED=1 /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /SQLSYSADMINACCOUNTS=`"$adminsGroupName`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /IACCEPTSQLSERVERLICENSETERMS " $setupExe -validExitcodes @(0,3010) | |
#The exe referenced is the official for SQL Express 2012, http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPRWT_x64_ENU.exe |