Skip to content

Instantly share code, notes, and snippets.

View natalie-o-perret's full-sized avatar
🐈
F#-ing

Natalie Perret natalie-o-perret

🐈
F#-ing
View GitHub Profile
@akhansari
akhansari / EsBankAccount.ts
Last active April 8, 2024 12:40
TypeScript prototype of the Decider pattern. (F# version: https://github.com/akhansari/EsBankAccount)
import * as assert from "assert";
/** Decider Pattern **/
type Transaction = {
amount: number
date: Date
}
type Deposited = Transaction & {

The OAuth Bible

I tried to make this as understandable as possible for any party reading it which means that the wording, references, and terminology used may not reflect that of a technical paper or resource. Excuse me if you may for I wish all to understand this, and not just those with a degree in understanding legal or technical jargon.

Created with love by Nijikokun @ Mashape, the team behing the OSS API management layer Kong, and Mashape Analytics for visualizing and monitoring API traffic.


Hey! Interested in simplifying the process to consume OAuth services like twitter, facebook, github, and thousands more? Check out Guardian, it was built with simplicity, security, and ease of use in mind, allowing you to consume OAuth in a single request.

@michaeloyer
michaeloyer / srtp.fsx
Last active February 29, 2024 19:52
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:
@akhansari
akhansari / event-sourced-user.fsx
Last active December 16, 2022 00:09
F# : Event Sourcing in a nutshell
// ========= Event Sourcing in a nutshell
(*
FriendlyName: string
Aggregate friendly name.
Initial: 'State
Initial (empty) state we will start with.
Decide: 'Command -> 'State -> 'Event list
@emcake
emcake / applicative-builders.fs
Last active February 15, 2021 15:10
Applicative builders in F# by abusing For and IsLikeZip
type ListBuilder() =
/// map
member x.For(l,f) =
List.map f l
/// id
member x.Yield(v) =
v
@fivemoreminix
fivemoreminix / main.rs
Last active January 14, 2021 16:43
Simple Brainfuck to C compiler written in Rust.
// "Hello, world!"
static PROGRAM: &'static str = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
fn main() {
let tokens = tokenize(PROGRAM);
//println!("{:?}", tokens);
let generated_code = generate(&tokens);
println!("{}", generated_code);
}
@AnthonyDGreen
AnthonyDGreen / homeward-bound.md
Last active November 15, 2018 00:05
(Former) Program Manager for Visual Basic details why he's leaving Redmond and moving back to Chicago.

This is my family tree:

22136890_558639237233_2226452117892069088_o

I drew this diagram from memory (it's not complete) on the whiteboard in my office last year to illustrate a point to a colleague: family is everything to me. Those shapes aren't just entries in a historical record, they're people who I've known and who have surrounded me my entire life. Not being near to them is as unnatural to me as not including my middle initial/name in my signature*. The shapes inside the circle are all in Chicago. And it's for that reason that I've always known my time at Microsoft and in Seattle could never be forever.

Since arriving in Seattle 8-years ago I've flown across the country (and to Canada once) for weddings, birthdays, graduations, almost every major US holiday (can you imagine having to call all those people if you miss Christmas?), a couple of drivers tests, and for one particular relation for

@SeanSobey
SeanSobey / portainer.md
Last active June 12, 2024 07:40
Portainer Setup on Windows 10

Portainer on Windows 10

Here I have 2 methods for running portainer on windows, a quick, preferred method only requiring a fairly recent version of docker, or a more complicated method to try if that does not work.

Using host.docker.internal

This setup will let you run Portainer on windows by using the host.docker.internal endpoint (docker.for.win.localhost is depricated since docker version 3.2.1, but older versions may use this instead).

Please note:

@martincooper
martincooper / TryMonad.fs
Created June 29, 2016 15:51
F# Try Exception Monad
namespace Exceptions
open System
module ExceptionTypes =
// TryResult, used to pass results or exception as values.
type TryResult<'r, 'e> =
| Result of 'r
| Error of 'e :> Exception
@valyala
valyala / README.md
Last active June 3, 2024 17:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data: