Skip to content

Instantly share code, notes, and snippets.

View arecvlohe's full-sized avatar
🚫
End ASF Mascotry / Drop ICE

Adam Recvlohe arecvlohe

🚫
End ASF Mascotry / Drop ICE
View GitHub Profile
@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

@justinwoo
justinwoo / differences-from-elm.md
Last active December 22, 2023 17:18
This document is likely out of date. See this page for general information: https://purescript-resources.readthedocs.io/. Differences of Purescript from Elm (The resource that I wish I had when starting with Purescript, or when revisiting Elm)

Differences of Purescript from Elm

The syntax between Elm and Purescript are mostly the same, to the point where most Elm code can be converted to Purescript with copy-pasting and find-replace/multi-cursor editing.

Purpose of this document

Many people who have used Elm who are curious about/have tried/are using Purescript have asked me to put together a "differences from Elm" post to help them, and which I would also have found helpful.

Type Annotations

@apmiller108
apmiller108 / rename_phoenix_app.sh
Last active August 6, 2019 03:16
Rename a Phoenix application.
#!/bin/bash
set -e
set -o pipefail
CURRENT_OTP=$1
NEW_OTP=$2
CURRENT_NAME=""
NEW_NAME=""
@groteck
groteck / Spelling.elm
Last active February 20, 2020 18:01 — forked from evancz/Spelling.elm
Remove unused import
port module Spelling exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
import String
main =
program
{ init = init
@lencioni
lencioni / AsyncComponent.jsx
Created January 8, 2017 17:09
<AsyncComponent> at Airbnb used for Webpack code splitting
// Usage:
//
// function loader() {
// return new Promise((resolve) => {
// if (process.env.LAZY_LOAD) {
// require.ensure([], (require) => {
// resolve(require('./SomeComponent').default);
// });
// }
// });
@nuxodin
nuxodin / easy-console.js
Created December 8, 2016 15:13
Like to write to the console like this "console = xyz" instead of "console.log(xyz)" ?
!(function(){
var original = console;
Object.defineProperty(window, 'console', {
get:function(){
return original;
},
set:function(value){
original.log(value)
}
})
port module Spelling exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
main =
@chrisbuttery
chrisbuttery / Main.elm
Last active January 3, 2018 17:15
Elm 0.17. A simple Mouse.moves example
import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
@theoretick
theoretick / fml.sh
Last active August 16, 2018 17:17
just fix it, bash
#!/bin bash
function dammit_bundler() {
bundle clean
bundle install
}
function dammit_npm() {
rm -fr ./node_modules/
npm cache clean -f
@Falconerd
Falconerd / gulpfile.js
Last active April 10, 2019 17:16
Gulp + Watchify + Babelify + BrowserSync
/**
* This gulpfile will copy static libraries and a index.html file as well as
* merge, babelify and uglify the rest of the javascript project.
*
* TODO:
* - Separate media, libs and src with different watchers.
* - Media and libs should only be copied to dist if they are different sizes.
*
* The expected project is to be laid out as such:
*