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 Timer | |
open System.Diagnostics | |
type TimeInfo = | |
{ TotalElapsed: float | |
Delta: float } | |
let start () = | |
let last = |
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 System.ComponentModel | |
open System.Configuration | |
open System.Runtime.InteropServices | |
open System.Security.Permissions | |
open System.Security.Principal | |
[<AutoOpen>] | |
module private Helpers = | |
[<DllImport("advapi32.dll", SetLastError = true)>] |
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
mod.controller("MyController", | |
[ | |
"$scope", "$http", | |
($scope: any, $http: ng.IHttpService) => { | |
var queueChecker = setInterval(() => { | |
var url = "/foo/count"; | |
$http.get(url, { params: { cacheBuster: new Date().getMilliseconds() } }) | |
.success((data: any) => { | |
$scope.QueueView = data; | |
$scope.QueueView.lastUpdated = new Date(); |
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
// --Snip-- | |
let getEntity id = | |
use conn = EntityContext.GetDataContext() | |
query { for t1 in conn.Table_1 do | |
join t2 in conn.Table_2 on (t1.id = t2.table_1_id) | |
where (t1.id = id) | |
select t2 | |
headOrDefault } |> function | |
| null -> Unchecked.defaultof<_> | |
| t2 -> { Id = t2.id; Value = t2.value } |
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 Counter = | |
type State = { Value: int } | |
static member Zero = { Value: 0 } | |
type Command = | |
| Incremement | |
| Decrement | |
type Event = | |
| Incremented |
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
[<RequireQualifiedAccess>] | |
module Authentication | |
open System | |
open System.Collections.Generic | |
open Simple.Web | |
open Simple.Web.Http | |
open Simple.Web.Authentication | |
type Payload = { UserId: Guid; Name: string; Expires: int64 } |
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
[<RequireQualifiedAccess>] | |
module Authentication | |
open System | |
open System.Collections.Generic | |
open Simple.Web | |
open Simple.Web.Http | |
open Simple.Web.Authentication | |
type Payload = { UserId: Guid; Name: string; Expires: int64 } |
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.Web.Hosting | |
open Simple.Web.Helpers | |
type PathUtility() = | |
interface IPathUtility with | |
member __.MapPath virtualPath = | |
virtualPath |> HostingEnvironment.MapPath |
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 CommandBus = | |
let createCommandRouter handlers = | |
let event = Event<Command>() | |
handlers |> List.iter(fun handler -> event.Publish |> Event.add handler) | |
let agent = MailboxProcessor.Start(fun inbox -> | |
let loop() = async { | |
let! cmd = inbox.Receive() | |
cmd |> event.Trigger | |
return! loop() } |
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
namespace Helpers | |
{ | |
// Used like: | |
// public override int GetHashCode() { | |
// return 17.CombineHashWith(foo).CombineHashWith(bar).CombineHashWith(GetType()); | |
// } | |
public static int CombineHashWith<T>(this int initialHash, T other) | |
{ | |
var otherHash = other == null ? 0 : other.GetHashCode(); | |
return initialHash + initialHash * 23 + otherHash; |
NewerOlder