Skip to content

Instantly share code, notes, and snippets.

View glebec's full-sized avatar
🥃
Slàinte

Gabriel Lebec glebec

🥃
Slàinte
View GitHub Profile
\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%] '
@glebec
glebec / debugging.md
Last active May 31, 2023 21:18
Debugging

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.
@glebec
glebec / books.md
Last active December 6, 2021 04:09 — forked from joedotjs/gist:2807153d0d6dcdfde00d
Books and Resources
@glebec
glebec / travis-build-from-dev.md
Created March 1, 2018 05:36
Fast Travis deployment with build from dev dependencies

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 / monadic-parser.js
Last active June 2, 2021 10:22
Monadic Parser demo
/**
* 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 / lenses.js
Last active January 25, 2019 23:06
Lenses in 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 / scott-encoding.js
Last active August 16, 2019 20:07
Scott Encoding
/**
* -- 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 => {

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 / absurd-haskell.hs
Last active July 28, 2019 17:48
Absurdity
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
@glebec
glebec / lambda-talk-qa.md
Created October 18, 2019 17:27
Smartly.io DevTalks - Lambda Calculus post-talk Q&A

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?