Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block giuliohome

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AdventOfCodeDay3bis.fs
open System
open System.IO
open System.Diagnostics
// my first part was 3247
//Found min cross at steps 48054 X 4537 and Y 4955
//done in (101) ms !
type Point = {X:int; Y:int; Steps: int} with
override this.ToString() = sprintf "(%d,%d,%d)" this.X this.Y this.Steps
View AdventOfCodeDay2bis.fs
open System
open System.IO
let readInts (path:string) : int [] =
use sw = new StreamReader (path)
|> Int32.Parse
type Status = {memory:int[]; position: int; finished: bool;}
type Cmd = {opcode: int; op1:int ; op2: int; dest:int}
View AdventOfCodeDay1bis.fs
open System
open System.IO
let readInts (path:string) =
use sw = new StreamReader (path)
while (not sw.EndOfStream) do
yield sw.ReadLine() |> Int32.Parse
giuliohome /
Created Sep 29, 2019
My Open Twitter Search integrated also with Slack channel, posting as bot
package org.new_year2018;
import android.os.AsyncTask;
import java.util.ArrayList;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
giuliohome / WebSharperLens2DB.fs
Created Aug 27, 2019
V for Lens with Async DB retrieval
View WebSharperLens2DB.fs
// online snippet:
// gitter ref:
// intellifactory blog:
namespace Samples
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI
open WebSharper.UI.Html
open WebSharper.UI.Client
View CleanDatePicker.fs
// 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)
giuliohome / OpenDetails.fs
Last active Jul 30, 2019
Create a form to post a request with parameter for a new detail tab and render it into html, all typesafe, from f# to javascript
View OpenDetails.fs
let (|==>) (param_name, param_id) (safe_url:EndPoint) =
let router = Router.Infer()
let url = router.Link(safe_url)
form [ "_blank"; attr.action url; ("form" + param_id); attr.method "POST" ] [
a [ (fun el ev ->
let frm = JS.Document.GetElementById ("form" + param_id) |> As<HTMLFormElement>
) ] [text param_id]
input [attr.``type`` "hidden"; param_name; attr.value param_id] []
giuliohome / app_offline.htm
Created May 14, 2019 — forked from robert-claypool/app_offline.htm
A simple "app offline" template for ASP.NET
View app_offline.htm
<!DOCTYPE html>
<meta charset="UTF-8">
<body style="margin:3em;font-family:sans-serif">
<p>This site is offline for maintenance.</p>
View TimeIt.cs
//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
View SFTPdownload.fs
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)
You can’t perform that action at this time.