Skip to content

Instantly share code, notes, and snippets.

View Krzysztof-Cieslak's full-sized avatar
#BlackLivesMatter

Krzysztof Cieślak Krzysztof-Cieslak

#BlackLivesMatter
View GitHub Profile
@Krzysztof-Cieslak
Krzysztof-Cieslak / ApplicationManifest.xml
Created March 18, 2016 12:18 — forked from andersosthus/ApplicationManifest.xml
Describes how to secure your OWIN/ASP.NET 5 endpoints in ServiceFabric without having to log on to each VM and do stuff.
<ApplicationManifest>
...
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="SERVICENAME" ServiceManifestVersion="1.0.0" />
<Policies>
<EndpointBindingPolicy CertificateRef="MyCertificateName" EndpointRef="ServiceEndpoint" />
</Policies>
</ServiceManifestImport>
...
<Certificates>
This file has been truncated, but you can view the full file.
'FsAutoComplete.Suave.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'FsAutoComplete.Suave.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'D:\Programowanie\Projekty\Ionide\FsAutoComplete\src\FsAutoComplete.Suave\bin\Debug\FsAutoComplete.Suave.exe'. Symbols loaded.
'FsAutoComplete.Suave.exe' (CLR v4.0.30319: FsAutoComplete.Suave.exe): Loaded 'D:\Programowanie\Projekty\Ionide\FsAutoComplete\src\FsAutoComplete.Suave\bin\Debug\FSharp.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'FsAutoComplete.Suave.exe' (CLR v4.0.30319: FsAutoComplete.Suave.exe): Loaded 'D:\Programowanie\Projekty\Ionide\FsAutoComplete\src\FsAutoComplete.Suave\bin\Debug\Suave.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'FsAutoComplete.Suave.ex
@Krzysztof-Cieslak
Krzysztof-Cieslak / Program.fs
Last active August 3, 2018 22:08
Gists for "Using OAuth with Saturn" blog posts
module Server
open Saturn
open Config
let endpointPipe = pipeline {
plug head
plug requestId
}
@Krzysztof-Cieslak
Krzysztof-Cieslak / Users.fs
Created August 3, 2018 22:08
Gists for "Using OAuth with Saturn" blog posts
module Users
open Saturn
open Giraffe
open System.Security.Claims
let matchUpUsers : HttpHandler = fun next ctx ->
// A real implementation would match up user identities with something stored in a database
let isAdmin =
ctx.User.Claims |> Seq.exists (fun claim ->
@Krzysztof-Cieslak
Krzysztof-Cieslak / Router.fs
Last active August 3, 2018 22:21
Gists for "Using OAuth with Saturn" blog posts
module Router
open Saturn
open Giraffe.Core
open Giraffe.ResponseWriters
open Users
let browser = pipeline {
plug acceptHtml
@Krzysztof-Cieslak
Krzysztof-Cieslak / UserView.fs
Created August 3, 2018 22:30
Gists for "Using OAuth with Saturn" blog posts
module UserViews
open Giraffe.GiraffeViewEngine
module AdminPage =
let view = [
h1 [] [rawText "I'm admin"]
]
let layout = App.layout view
@Krzysztof-Cieslak
Krzysztof-Cieslak / gist:34c2a43c52119fde8d55315c7831244d
Created September 14, 2018 19:23
Run function for any member call
let rec visitExpr memberCallHandler (e:FSharpExpr) =
match e with
| BasicPatterns.AddressOf(lvalueExpr) ->
visitExpr memberCallHandler lvalueExpr
| BasicPatterns.AddressSet(lvalueExpr, rvalueExpr) ->
visitExpr memberCallHandler lvalueExpr; visitExpr memberCallHandler rvalueExpr
| BasicPatterns.Application(funcExpr, typeArgs, argExprs) ->
visitExpr memberCallHandler funcExpr; visitExprs memberCallHandler argExprs
| BasicPatterns.Call(objExprOpt, memberOrFunc, typeArgs1, typeArgs2, argExprs) ->
memberCallHandler e.Range memberOrFunc
@Krzysztof-Cieslak
Krzysztof-Cieslak / analyzer.fs
Created September 14, 2018 19:29
Option Analyzer
[<Analyzer>]
let optionValueAnalyzer : Analyzer =
fun ctx ->
let state = ResizeArray<range>()
let handler (range: range) (m: FSharpMemberOrFunctionOrValue) =
let name = String.Join(".", m.DeclaringEntity.Value.FullName, m.DisplayName)
if name = "Microsoft.FSharp.Core.FSharpOption`1.Value" then
state.Add range
ctx.TypedTree.Declarations |> List.iter (visitDeclaration handler)
state
@Krzysztof-Cieslak
Krzysztof-Cieslak / paket.dependencies
Created September 14, 2018 19:49
Sample paket.dependencies for Analyzers
// [ Analyzers Group ]
group Analyzers
source https://api.nuget.org/v3/index.json
nuget FSharp.Analyzers.Sample 1.0.1
@Krzysztof-Cieslak
Krzysztof-Cieslak / Sample.fs
Created September 14, 2018 19:54
Sample usage of analyzer
// Learn more about F# at http://fsharp.org
open System
let x = None
[<EntryPoint>]
let main argv =
x.Value
printfn "Hello World from F#!"