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 Pipelets | |
open System | |
open System.Reflection | |
open System.Collections.Concurrent | |
open FSharp.Control | |
type pipelet<'a,'b>(processor, router: seq<IPipeletInput<'b>> * 'b -> seq<IPipeletInput<'b>>, capacity, ?overflow, ?blockingTime) = | |
let buffer = BlockingQueueAgent<_> capacity | |
let routes = ref List.empty<IPipeletInput<'b>> | |
let queuedOrRunning = ref false |
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
import scala.actors.Actor | |
import scala.actors.Actor._ | |
import scala.util.Random | |
import scala.collection.{immutable, mutable} | |
val rand = new Random() | |
case class Customer(id: Int) { | |
var shorn:Boolean = false | |
} |
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
http.createServer(function (request, response) { | |
var uri = url.parse(request.url).pathname; | |
if(uri=='/pong') { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.end('PONG'); | |
} else if ((match = uri.match(/^\/echo\/(.*)$/)) != null) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.end(match[1]); |
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
let server = HttpServer((fun(headers, close, svr, sd) -> | |
let header = sprintf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 20\r\nConnection: close\r\nServer: Fracture\r\nDate: %s\r\n\r\n" (DateTime.UtcNow.ToShortDateString()) | |
let body = "Hello world.\r\nHello." | |
let encoded = System.Text.Encoding.ASCII.GetBytes(header + body) | |
do svr.Send(sd.RemoteEndPoint, encoded, true)), body = fun(body, svr, sd) -> | |
Debug.WriteLine( sprintf "%s" (Text.Encoding.ASCII.GetString(body.Array)) ) ) | |
server.Listen(6667) | |
printfn "Http Server started" | |
Console.ReadKey() |> ignore |
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
let server = new HttpServer(OnHeaders = respondHelloWorld ) ) |
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
let computeAndRoute data routes = async{data |> transform |> router <| routes} | |
let mailbox = MailboxProcessor.Start(fun inbox -> | |
let rec loop routes = async { | |
let! msg = inbox.Receive() | |
match msg with | |
| Payload(data) -> | |
ss.Release() |> ignore | |
Async.StartWithContinuations(computeAndRoute data routes, ignore, errors, ignore) | |
return! loop routes |
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
let mailbox = MailboxProcessor.Start(fun inbox -> | |
let rec loop routes = async { | |
let! msg = inbox.Receive() | |
match msg with | |
| Payload(data) -> | |
ss.Release() |> ignore | |
let result = compute data routes |> Async.Catch |> Async.RunSynchronously | |
match result with | |
| Choice1Of2 _ -> () | |
| Choice2Of2 exn -> errors exn |
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
let mailbox = MailboxProcessor.Start(fun inbox -> | |
let rec loop routes = async { | |
let! msg = inbox.Receive() | |
match msg with | |
| Payload(data) -> | |
ss.Release() |> ignore | |
let result = async{data |> transform |> router <| routes} | |
|> Async.Catch | |
|> Async.RunSynchronously | |
match result with |
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 Options | |
{ | |
public enum Style | |
{ | |
Call, | |
Put | |
} | |
public static double BlackScholes(Style callPut, double s, double x, double t, double r, double v) | |
{ |
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
let colourStyles = Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle(MonoDevelop.Ide.IdeApp.Preferences.ColorScheme) | |
let keywordColour = colourStyle.GetForeground (colourStyle.KeywordProperty) | |
let cairoToHsl (c:Cairo.Color) = HslColor.op_Implicit(c) | |
let gdkToHsl (c:Gdk.Color) = HslColor.op_Implicit(c) | |
let hslToCairo (c:HslColor) : Cairo.Color = HslColor.op_Implicit(c) | |
let hslToGdk (c:HslColor) : Gdk.Color = HslColor.op_Implicit(c) | |
let cairoToGdk = cairoToHsl >> hslToGdk |
OlderNewer