Skip to content

Instantly share code, notes, and snippets.

View kMutagene's full-sized avatar

Kevin Schneider kMutagene

View GitHub Profile
@kMutagene
kMutagene / dash-stock-ticker-less-loc.fs
Last active February 14, 2022 07:42
Dash stonks ticker App to pluck into an asp.netcore app via DashApp.toHttpHandler.
open Dash.NET; open Plotly.NET; open FSharp.Data; open Deedle; open System; open System.IO; open System.Text; open System.Text.RegularExpressions
let req = Http.Request("https://finance.yahoo.com/quote/AMZN/history?p=AMZN",httpMethod=HttpMethod.Get)
let body = match req.Body with | HttpResponseBody.Text b -> b
let crumb = Regex("CrumbStore\":{\"crumb\":\"(?<crumb>.+?)\"}").Match(body).Groups.["crumb"].Value
let cookie = req.Cookies.["B"]
let getDf ticker : Frame<System.DateTime,string> =
let response =
Http.RequestString(
#r "paket:
nuget BlackFox.Fake.BuildTask
nuget Fake.Core.Target
nuget Fake.Core.Process
nuget Fake.Core.ReleaseNotes
nuget Fake.IO.FileSystem
nuget Fake.DotNet.Cli
nuget Fake.DotNet.MSBuild
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.DotNet.Paket
@kMutagene
kMutagene / Steps.md
Last active September 2, 2020 14:35
Create minimal F# project

0.a Ensure newest dotnet SDK version

0.b Init repo with appropriate license and gitignore (e.g. Visual Studio)

0.c Clone repo

  1. Install Fake template : dotnet new -i "fake-template::*"

  2. In the repo root:

    • dotnet new fake (creates basic build script)
@kMutagene
kMutagene / Kaleido.FSharp.fsx
Created July 5, 2020 19:29
Kaleido.FSharp POC
//Use F#5 preview to use "#r:nuget..."
#r "nuget:FSharp.Plotly,Version=2.0.0-alpha"
#r "nuget:Fake.Core.Process"
open System
open System.Diagnostics
open Fake.IO
open FSharp.Plotly
open Newtonsoft.Json
@kMutagene
kMutagene / DeedleExtensions.fsx
Created June 25, 2020 06:43
Current Deedle extensions (will be a proper library soon)
open Deedle.Vectors
open Deedle.Indices
open Deedle.Indices.Linear
open FSharpAux
//open FSharpAux.Collections
[<AutoOpen>]
module Frame =
let dropColIfExists (col:'C) (frame:Frame<'R,'C>) =
#r "nuget: System.Runtime.InteropServices.RuntimeInformation"
///Choose process to open plots with depending on OS. Thanks to @zyzhu for hinting at a solution (https://github.com/muehlhaus/FSharp.Plotly/issues/31)
let openOsSpecificFile path =
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then
let psi = new System.Diagnostics.ProcessStartInfo(FileName = path, UseShellExecute = true)
System.Diagnostics.Process.Start(psi) |> ignore
elif RuntimeInformation.IsOSPlatform(OSPlatform.Linux) then
System.Diagnostics.Process.Start("xdg-open", path) |> ignore
elif RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then
@kMutagene
kMutagene / PuppeteerRenderPlotly.fsx
Last active May 25, 2020 07:05
POC of PuppeteerSharp rendering a FSharp.Plotly plot
//#r "nuget: ..." is a preview feature of F#5, make sure to adapt if you dont use it.
#r "nuget: PuppeteerSharp"
#r "nuget: FSharp.Plotly"
open PuppeteerSharp
open FSharp.Plotly
[(1,2);(2,4);(3,5)]
|> Chart.Line
|> Chart.SaveHtmlAs "your/path/here"
@kMutagene
kMutagene / manifest.xml
Last active April 30, 2020 08:30
Manifest and validate dump for SO question
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<Id>5d6f5462-3401-48ec-9406-d12882e9ad83</Id>
<Version>1.0.0.0</Version>
<ProviderName>Computational Systems Biology</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="CSBAnnotator"/>
<Description DefaultValue="Utility functions to annotate data in a fast and safe way"/>
<IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-80.png"/>