Skip to content

Instantly share code, notes, and snippets.

View AlexCuse's full-sized avatar

Alex Ullrich AlexCuse

View GitHub Profile
@AlexCuse
AlexCuse / Membership.cs
Created October 1, 2010 01:11
NHibernate based Membership Provider - I found this on the code project. Modified it to use a single session, and maybe a few other things. Need to change references around, supply own user. But it's definitely come in handy
/*
//Software usage License : Fluent Nhibernate membership and role provider
//--------------------------------------------------
//Copyright (c) 2010, Suhel Shah (suhel.shah@gmail.com)
//All rights reserved.
//Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
//2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
@AlexCuse
AlexCuse / gist:894707
Created March 30, 2011 16:17
euler repl
#light
module ProjectEuler.Program
open System;
open System.Diagnostics;
open System.Reflection;
let dynamicExecute prob =
let probNum = prob.ToString()
let ass = Assembly.GetExecutingAssembly()
let modul = ass.GetType("ProjectEuler.Problem" + probNum)
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry()))
let write<'T> item =
async {
ObjectFactory.GetAllInstances<Indexer<'T>>()
|> Seq.iter (fun idxr -> idxr.Index item)
}
let itemsToIndex<'T when 'T:null and 'T:not struct and 'T:equality> =
let p = QueueProvider<'T>.Create()
@AlexCuse
AlexCuse / gist:1008510
Created June 5, 2011 00:02
Seq.concat wasn't working right (was only checking the recipe queue). Async wasn't working either but this seems to do ok.
module Program
#light
open System.Threading
open StructureMap
open BrewTelligence.Domain
open BrewTelligence.Search.Indexing
open BrewTelligence.ApplicationServices
open BrewTelligence.ApplicationServices.Messaging
@AlexCuse
AlexCuse / gist:1009694
Created June 6, 2011 03:33
may need some stability improvements but this seems like a step in the right direction
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry()))
let write<'T> item =
ObjectFactory.GetAllInstances<Indexer<'T>>()
|> Seq.iter (fun idxr -> idxr.Index item)
let itemsToIndex<'T when 'T:null and 'T:not struct and 'T:equality> =
let p = QueueProvider<'T>.Create()
seq {
while true do
@AlexCuse
AlexCuse / gist:1011592
Created June 7, 2011 02:40
Attempting Sequence 'merge' - look at LazyList in F# power pack for other possibilities
module Seq
#light
let rec merge s1 s2 =
seq {
yield s1 |> Seq.head
yield s2 |> Seq.head
yield! merge s1 s2
}
module Seq
#light
let merge (s1:seq<'a>) (s2:seq<'a>) =
let rec innerMerge s1 s2 =
seq {
match s1, s2 with
| LazyList.Cons(h1, t1), LazyList.Cons(h2, t2) ->
yield h1
@AlexCuse
AlexCuse / gist:1012647
Created June 7, 2011 16:51
Seq option merge
#light
open System
module Seq =
let merge (s1:seq<option<'a>>) (s2:seq<option<'a>>) =
let rec innerMerge s1 s2 =
seq {
match s1, s2 with
| LazyList.Cons(h1, t1), LazyList.Cons(h2, t2) ->
yield h1
@AlexCuse
AlexCuse / gist:1013392
Created June 7, 2011 23:00
parallel still not working for some reason
module Program
#light
open System.Threading
open StructureMap
open BrewTelligence.Domain
open BrewTelligence.Search.Indexing
open BrewTelligence.ApplicationServices
open BrewTelligence.ApplicationServices.Messaging
type Service = //snip
member this.Run() =
let mutable retryCount = 0
while retryCount < 10 do
//what to do on mono? Maybe setting up local log better
let errorCallback =
function(ex:System.Exception) -> this.EventLog.WriteEntry("error in BrewTelligence Indexing Service:\n\n" + ex.Message + "\n\n" + ex.StackTrace)
try