Skip to content

Instantly share code, notes, and snippets.

@serefarikan
serefarikan / print_tree.fsx
Created August 7, 2024 16:44 — forked from lamg/print_tree.fsx
Print a tree
type Branch<'a, 'b> =
{ value: 'a
children: Tree<'a, 'b> seq }
and Tree<'a, 'b> =
| Branch of Branch<'a, 'b>
| Leaf of 'b
type PrinterContext<'a, 'b> =
abstract member branchToString: 'a -> string
@serefarikan
serefarikan / README.md
Created August 1, 2024 13:16 — forked from andyvanee/README.md
GoDaddy + LetsEncrypt Certificate Installation

GoDaddy + LetsEncrypt Certificate Installation

Valid as of September 2020

note: if you have shell access and want to automatically renew, follow the steps on this page instead

Much of the current documentation on this from LetsEncryt and Godaddy suggests that this is a very hard thing to do - but I'm okay with spending 10 minutes every 2-3 months for a free, quality SSL certificate. If you are too, here's how I do it.

@serefarikan
serefarikan / on-tail-recursion.md
Created July 18, 2024 07:24 — forked from mrange/on-tail-recursion.md
On the topic of tail calls in .NET

On the topic of tail calls in .NET

Let's say you have implemented a small data pipeline library to replace LINQ.

module TrivialStream =
  type Receiver<'T> = 'T            -> unit
  type Stream<'T>   = Receiver<'T>  -> unit

  module Details =
@serefarikan
serefarikan / GADTMotivation.fs
Created January 8, 2024 09:06 — forked from Savelenko/GADTMotivation.fs
Motivated simulation of GADTs in F#, quite motivational
module GADTMotivation
(*
Here is a simple motivational example for GADTs and their usefulness for library design and domain modeling. Suppose we
need to work with settings which can be displayed and adjusted in a GUI. The set of possible setting "types" is fixed
and known in advance: integers, strings and booleans (check-boxes).
The GUI should show an example value for each possible setting type, e.g. 1337 for an integer setting and "Hello" for a
string setting. How can we model this small domain of setting types and computing example values?
*)
@serefarikan
serefarikan / srtp.fsx
Created December 24, 2023 07:23 — forked from michaeloyer/srtp.fsx
F# SRTP Example
// SRTP: Statically Resolved Type Parameters
// https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters
// SRTP Allows for pulling members out of types that where the member is named and typed the same
// In this example SRTP will be used to pull out the 'First: string' and 'Last: string' members
// from different types
// One example of SRTP in the F# Base Class Library is the (+) operator.
// You'll see that it has this type signature:
@serefarikan
serefarikan / private_fork.md
Created December 8, 2023 09:18 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@serefarikan
serefarikan / esm-package.md
Created September 27, 2023 05:09 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@serefarikan
serefarikan / srtp_net6.fs
Created April 20, 2023 20:44 — forked from lukaszkrzywizna/srtp_net6.fs
SRTP F# .Net 6
type MyType =
| MyCase
static member statFun x = match x with MyCase -> "I'm static member function!"
static member statFunUnit () = "I'm static member function with unit param!"
static member statFunGeneric (x, y) =
match x with MyCase -> $"I'm static member function with generic param with value = %O{y}!"
static member statProp = "I'm static member property!"
member this.objProp = match this with MyCase -> "I'm object member property!"
member this.objFunGen x = match this with MyCase -> $"I'm object member function with param with value = %O{x}!"
member this.objFunUnit () = match this with MyCase -> "I'm object member function with unit param!"
Edit '/etc/sysconfig/jenkins' and add 'prefix=/jenkins' to 'JENKINS_ARGS'
**************************************************************************
JENKINS_ARGS="--prefix=/jenkins"
Comment out the default server config in '/etc/nginx/nginx.conf'
and create following file
'/etc/nginx/conf.d/domain.conf'
*************************************************
@serefarikan
serefarikan / how-to-install-graalvm-linux.md
Created March 11, 2021 18:04 — forked from ricardozanini/how-to-install-graalvm-linux.md
How to install GraalVM on Linux with alternatives

How to Install GraalVM Community Edition on Linux

Note: Tested on Fedora only

  1. Download the new release of GraalVM and unpack it anywhere in your filesystem:
$ tar -xvzf graalvm-ce-1.0.0-rc14-linux-amd64.tar.gz