Skip to content

Instantly share code, notes, and snippets.

View realvictorprm's full-sized avatar
😼
Fighting the bugs!

Victor Peter Rouven Müller realvictorprm

😼
Fighting the bugs!
  • VPR Mueller Software Solutions
  • Switzerland
  • 13:26 (UTC +01:00)
  • X @realvictorprm
View GitHub Profile
@realvictorprm
realvictorprm / Didact.fsx
Last active February 6, 2022 15:08
F# port of the "Build your own react - Didact" tutorial
(*
F# port of https://github.com/pomber/didact
Copyright © 2022 Victor Peter Rouven Müller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FRO
@realvictorprm
realvictorprm / classic-typeclasses.hs
Last active February 11, 2021 18:15
Example implementation of the classic typeclasses Functor, Applicative & Monad for a simple newtype
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
newtype Bag a = Bag {content :: a}
deriving (Eq, Show)
instance Functor Bag where
fmap fn Bag {content} = Bag {content = fn content}
@realvictorprm
realvictorprm / cnn.fsx
Last active January 8, 2021 17:30
Proof of concept implementation of a simple CNN consisting of 1 convolution layer, 1 pooling layer, and variable amounts of classic neuronal network layers.
#r "nuget: MathNet.Numerics"
#r "nuget: MathNet.Numerics.FSharp"
open System.Runtime.CompilerServices
open Checked
open MathNet.Numerics
open MathNet.Numerics.LinearAlgebra.Double
open MathNet.Numerics.LinearAlgebra
@realvictorprm
realvictorprm / Feck.scala
Last active August 22, 2020 09:21
Attempt to create an sync IO for bukkit
object Bukkit {
import scala.concurrent.ExecutionContext
implicit val cs: ContextShift[IO] = IO.contextShift(ExecutionContext.global)
def scheduler: BukkitScheduler = JBukkit.getScheduler
def runTask(task: IO[Unit])(implicit plugin: JavaPlugin): BukkitTask = scheduler.runTask(plugin, Utils.mkRunnable(task.unsafeRunSync()))
@realvictorprm
realvictorprm / Snake.fsx
Last active November 22, 2020 18:00
Snake implementation in F#
module Elmish.Snake
(**
Timer as a source of events with an SVG clock, by Zaid Ajaj.
You can find more info about Emish architecture and samples at https://elmish.github.io/
*)
open System
open Fable.Import
open Fable.Helpers.React
enum HeadMovement{
case Left, Right, Keep
}
type TuringMachineTransitionTable[BandElement, AlphabetElement, State] =
Map[(State, BandElement), (State, AlphabetElement, HeadMovement)]
class InfiniteBand[BandElement, Alphabet](band:Map[Int, BandElement | Alphabet],
neutralElement: (BandElement | Alphabet)) {
var pos = 0
@realvictorprm
realvictorprm / PaketDependencyManagementMadeEasy.fsx
Last active June 12, 2018 19:41
A must have for your script file to ease spreading a small proof of concept with dependencies!
open System
open System.IO
open System.Diagnostics
let downloadDependencies deps =
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
if not (File.Exists "paket.exe") then
async {
let url = "http://fsprojects.github.io/Paket/stable"
@realvictorprm
realvictorprm / API_Reference_Opener.fsx
Last active March 3, 2018 20:09
Provides the class ReferenceHelper with which one can simply open the documentation to a bash command through calling `helper.[commandyousearch]`
open System
open System.Net
open System.Text.RegularExpressions
open System.Collections.Generic
// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' "project"
// for more guidance on F# programming.
module Option =
let inline defaultMap value f option = match option with | None -> value | Some value -> f value
@realvictorprm
realvictorprm / FsharpAllocationTraps.fsx
Created September 28, 2017 15:32
Those cases here show when allocations happen without being want.
type WhoDesignedThisAnyway =
{ Field: string }
/// allocates two functions, and a tuple each time this is called.
static member Lens = (fun x -> x.Field), (fun v x -> {x with Field = v })
module WhoDesignedThisAnyway =
/// doesn't allocate
@realvictorprm
realvictorprm / FsharpGeneratorUsingglTFSpecificationFiles.fs
Last active September 13, 2017 16:41
Creates a abstract generator class which provides all methods for visiting the specified glTF specification
open System.IO
// Weitere Informationen zu F# unter "http://fsharp.org".
// Weitere Hilfe finden Sie im Projekt "F#-Tutorial".
module Generator =
open System.IO
open System
open System.Text.RegularExpressions
open System.CodeDom.Compiler