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 Database.HDBC | |
import Database.HDBC.ODBC | |
data Person = Person | |
{ id :: Int | |
, name :: [Char] } | |
deriving Show | |
convRow :: [SqlValue] -> Person | |
convRow [sqlId, sqlDesc] = |
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 Renci.SshNet | |
open System.IO | |
open System.Configuration | |
open System | |
let config = ConfigurationManager.AppSettings | |
let timestamp = "sftp_log_" + DateTime.UtcNow.Date.ToString("yyyy_MM_dd") + ".txt" | |
let logPath = Path.Combine(config.["SharedFolder"],timestamp) | |
let sw = new StreamWriter(logPath,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
//usage: | |
//TimeIt(() => Extract(sql_trades, "03_Trade_Valid_" + timestamp + ".csv"), "Trade Extract"); | |
static bool Retry(int count, Action action, Action<int> startCallback, Func<Exception, int, bool> exceptionCallback) | |
{ | |
if (count <= 0) { return false; } else | |
{ | |
try | |
{ | |
startCallback(count); | |
action(); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Offline</title> | |
</head> | |
<body style="margin:3em;font-family:sans-serif"> | |
<h2>Offline</h2> | |
<p>This site is offline for maintenance.</p> | |
<!-- |
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 (|==>) (param_name, param_id) (safe_url:EndPoint) = | |
let router = Router.Infer() | |
let url = router.Link(safe_url) | |
form [attr.target "_blank"; attr.action url; attr.id ("form" + param_id); attr.method "POST" ] [ | |
a [ on.click (fun el ev -> | |
let frm = JS.Document.GetElementById ("form" + param_id) |> As<HTMLFormElement> | |
frm.Submit() | |
) ] [text param_id] | |
input [attr.``type`` "hidden"; attr.name param_name; attr.value param_id] [] | |
] |
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
// from IE datepicker to F#: you tried Globalization, ParseExact, etc... without luck | |
// and this does the trick ;-) | |
let filterDate (str:string) : string = | |
new string (str.ToCharArray() | |
|> Array.filter(fun c -> int c < 128)) | |
// used for example in | |
let dateFrom = DateTime.Parse(filterDate dateFromStr) |
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
// online snippet: https://try.websharper.com/snippet/user3383/0000Oy | |
// gitter ref: https://gitter.im/intellifactory/websharper?at=5d650521f2821072aa20f412 | |
// intellifactory blog: https://www.intellifactory.com/blog/5508/clear-and-simple-reactive-code-with-websharper-ui-s-v | |
namespace Samples | |
open WebSharper | |
open WebSharper.JavaScript | |
open WebSharper.UI | |
open WebSharper.UI.Html | |
open WebSharper.UI.Client |
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
package org.new_year2018; | |
import android.os.AsyncTask; | |
import java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.util.ArrayList; | |
import org.apache.http.NameValuePair; | |
import org.apache.http.client.ClientProtocolException; |
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.IO | |
let readInts (path:string) = | |
[| | |
use sw = new StreamReader (path) | |
while (not sw.EndOfStream) do | |
yield sw.ReadLine() |> Int32.Parse | |
|] |
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.IO | |
let readInts (path:string) : int [] = | |
use sw = new StreamReader (path) | |
sw.ReadToEnd().Split(",") | |
|> Array.map Int32.Parse | |
type Status = {memory:int[]; position: int; finished: bool;} | |
type Cmd = {opcode: int; op1:int ; op2: int; dest:int} |