Skip to content

Instantly share code, notes, and snippets.

View layflags's full-sized avatar
💥

Lay Flags layflags

💥
View GitHub Profile
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@kritzcreek
kritzcreek / random-numbers.md
Last active May 24, 2021 18:36
Collections of random numbers in PureScript

Generating collections of random numbers in PureScript

A problem that I've seen beginners run into in Haskell or PureScript a couple of times now is how to generate a List of random numbers. It's a common requirement for little games (which make for great first projects) to generate these, and it definitely seems to be a stumbling block.

Why are random numbers hard?

Randomness is considered a side effect in purely functional languages, which means that to generate them you usually need access to Eff/IO, which in turn means we need to deal with Monads. And while generating a single random number is usually pretty easy with do-notation, the typical intuition beginners have built when going from single values to a collection is to use map, but that fails.

Type-Directed-Search to the rescue

@jfmengels
jfmengels / lodash-fp-documentation.md
Last active February 6, 2024 20:57
Generated docs for Lodash/fp. Help make them better at https://github.com/jfmengels/lodash-fp-docs

tags: markdown cheatsheet help author: admin protected: admin

Markdown Cheatsheet

{:.no_toc}

  • toc {:toc}
@layflags
layflags / df-forward-email.js
Created June 25, 2011 21:14
Creates a new e-mail forwarder for your DomainFactory (www.df.eu) account
//
// Creates a new e-mail forwarder for your DomainFactory (www.df.eu) account
//
// Sadly DomainFactory doesn't provide an API for managing "ManagedHosting"
// accounts, so I decided to write a short script for creating e-mail
// forwarders, because I like to have one e-mail address for every service
// I register for and I don't like to waste my time clicking through several
// pages to archive this ;)
//
// To run this code you need PhantomJS - http://www.phantomjs.org/ (1.0.0)