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
@animatedlew
animatedlew / patternMatch.hs
Last active February 4, 2023 12:32
Here are some examples of pattern matching in Haskell.
-- Haskell will match starting at the top, until it hits a catchall
factorial :: Int -> Int
factorial 0 = 1
factorial n = n * factorial(n - 1)
-- Haskell is able to match empty lists and x:xs patterns
head' :: [a] -> a
head' [] = error "No head available on empty lists!"
head' (x:_) = x
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions