Skip to content

Instantly share code, notes, and snippets.

View r-k-b's full-sized avatar

Robert K. Bell r-k-b

View GitHub Profile
@DrBoolean
DrBoolean / reports.js
Created August 23, 2016 16:21
Curry use
// to, from are awkward here. generateReport only needs them to send an email
const generateReport = (to, from, data) =>
mungeData(data, (warnings, munged) =>
renderReport(munged, (report) => emailReport(to, from, report)))
generateReport(“info@reports.com”, “app@test.net”, {some: ‘data’})
// if emailReport was curried, we could pass in the emailer
@raine
raine / heroku-logs-with-bunyan.md
Last active August 3, 2018 19:14
Read heroku log output with bunyan

Read heroku logs output w/ bunyan

The stuff before the JSON in heroku logs output has to be cut off for bunyan to work.

$ heroku logs | sed -l 's/.*app\[web\..*\]\: //' | bunyan

Flag -l makes the output buffered by line.

@ericelliott
ericelliott / broken-instanceof.js
Created June 1, 2016 05:24
instanceof doesn't mean what you think it means...
// instanceof is a prototype identity check.
// NOT a type check.
// That means it lies across execution contexts,
// when prototypes are dynamically reassigned,
// and when you throw confusing cases like this
// at it:
function foo() {}
const bar = { a: 'a'};
module Alarm exposing (main)
import Browser
import Html exposing (Html, button, div, h2, text)
import Html.Events exposing (onClick)
{-| This is an attempt at building up a dependency between pieces of state
that can be separate and then allowing us to compose them naturally.
@evancz
evancz / font-face.md
Last active March 14, 2019 09:07
It seems really complicated to use custom fonts well. This explores some ideas of how to make it easier.

Making it easier to load fonts

I have been doing a lot of work on making Elm assets really tiny. As part of some exploratory research I did ages ago, I read this document on font loading. It is a super helpful resource, but I was confused by all the different terms: FOIT, FOUT, FOFT, etc. It reminded me of the old "how do you center things?" blog posts from before flexbox. So my instinct was that probably lots of folks are confused about how to do it well, and maybe there is a better way!

So brainstormed some some ideas to:

  1. Save even more bits.
  2. Have an ideal visual experience.
  3. Be really easy to set up.
@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

@willbroderick
willbroderick / recursive_nav_helper.liquid
Last active July 4, 2021 05:37
Generic recursive nav markup generator for Shopify, works with non-latin alphabet and to any depth.
{% comment %}
Usage: {% include 'recursive-navigation-helper' with 'main-menu' %}
{% endcomment %}
{% comment %} Sanity check to prevent infinite recursion {% endcomment %}
{% assign sanity = sanity | plus: 1 %}
{% if sanity < 10000 %}
{% if linklists[recursive-navigation-helper].links.size > 0 %}
@mordrax
mordrax / phd-elm-19-upgrade.md
Last active July 14, 2021 01:27
Upgrade to elm 0.19

This gist started Wednesday 29th August. We have until Friday 7th September to upgrade to Elm 0.19. This is a bunch of notes which I'm keeping track of to eventually turn into an article later on. Hope it helps your upgrade.

Day 1

Pre upgrade

428 Elm files.

The Why and When of Choosing Elm

What is Elm?

  • Language (and "framework") for building web frontend applications
  • Can be used in place of HTML, CSS and JavaScript
  • Compiles into the above
@lhorie
lhorie / longest-keyword-sequence.md
Last active November 14, 2022 23:21
What's the longest keyword sequence in Javascript?