Skip to content

Instantly share code, notes, and snippets.

Avatar
🥃
Slàinte

Gabriel Lebec glebec

🥃
Slàinte
View GitHub Profile
@glebec
glebec / lambda-talk-qa.md
Created Oct 18, 2019
Smartly.io DevTalks - Lambda Calculus post-talk Q&A
View lambda-talk-qa.md

Lambda Calculus Q&A

These are my responses to some of the questions asked at the end of my Lambda Calculus talk, held on 2019-10-15 at Smartly.io's DevTalks in Helsinki. I've grouped similar questions together.

Books and Resources

  • What's the one encompassing book you would recommend to read on this very interesting topic?
  • Can you recommend a book (or books) that cover some of the history you shared in more detail?
  • So what IS the book to read to get into understanding all of this?
View absurd-haskell.hs
module Absurd where
import Data.Void
-- Void is an empty type; there are values of type Void.
-- Example with incomplete pattern matching, which we should avoid on principle, and which
-- we can configure the compiler to yell about:
missingCase :: Either Void x -> x
missingCase eVR = case eVR of
View module-030-Thunks.md

Thunks

Needs Statement

Thunks are a popular way to avoid directly causing side effects in our actions, action creators, or components, thus allowing us to keep the rest of our application pure (easier to test, reason about, re-use). Thunks are the simplest way to deal with AJAX requests in a redux application.

Objectives

High-Level

  • Students will understand the need to isolate side-effects to a particular stage of the redux cycle.
@glebec
glebec / scott-encoding.js
Last active Aug 16, 2019
Scott Encoding
View scott-encoding.js
/**
* -- Haskell `Maybe` type:
* data Maybe a = Nothing | Just a
*/
// JS Scott-Encoding-inspired `Maybe` definition
// (NB, true Scott encoding uses closures rather than a record – see gist comment)
const Maybe = {
Nothing: whatToDoInEachCase => {
@glebec
glebec / lenses.js
Last active Jan 25, 2019
Lenses in JS
View lenses.js
/**
* Van Laarhoven Lenses in JavaScript
* by Gabriel Lebec (https://github.com/glebec)
*
* Based on https://www.codewars.com/kata/lensmaker
* See also https://github.com/ekmett/lens/wiki/History-of-Lenses
*/
/**
* Composition and Combinators
@glebec
glebec / monadic-parser.js
Last active Jun 1, 2019
Monadic Parser demo
View monadic-parser.js
/**
* Minimal demo of parser combinators, possibly as a target for recent
* JS web dev graduates to implement as an exercise.
*
* Huge credit to Hutton, Meijer, and Swierstra for their papers
* on the subject.
*/
class Parser {
@glebec
glebec / travis-build-from-dev.md
Created Mar 1, 2018
Fast Travis deployment with build from dev dependencies
View travis-build-from-dev.md

Fast Travis Build & Heroku Deployment

Below is a sample .travis.yml which:

  • Uses dist: trusty + sudo: false to enable fast Docker containers
  • Uses npm ci to install quickly before testing
  • Builds from modules in devDependencies
  • Includes the build in the deployment
  • Omits node_modules (smaller tarball & no Heroku warning)
@glebec
glebec / books.md
Last active Aug 3, 2020 — forked from joedotjs/gist:2807153d0d6dcdfde00d
Books and Resources
View books.md
View debugging.md

Debugging JavaScript Applications

A practical distillation for Fullstack Academy students

Faults in computer problems were theorized as far back as 1843, when Ada Lovelace noted of Babbage's Analytical Engine, "Granted that the actual mechanism is unerring in its processes, the cards may give it wrong orders." Almost 160 years later, NIST reported that software errors cost the US $59 billion annually. Clearly, some of the cards are wrong. However, unlike Grace Hopper's famous moth, most of the time the culprit is ourselves.

Debugging is a sanitization procedure consisting of:

  • Preventing bugs in the first place, through good practices and assistive tooling.
  • Detecting bugs when they first arise, through proper error handling and testing.
View custom-psql-prompt.sql
\set QUIET 1
\set VERBOSITY verbose
\set COMP_KEYWORD_CASE upper
\timing
\x auto
\pset linestyle unicode
\pset border 2
\pset format wrapped
\pset null ''
\set PROMPT1 '\n%[%033[1;34;40m%]psql %[%033[;30;45m%] %M:%> %[%033[;35;40m%] %[%033[36m%]%n %# %[%033[35m%]%~ %[%033[37m%]%x%[%033[;30;49m%]%[%033[0m%] '
You can’t perform that action at this time.