Skip to content

Instantly share code, notes, and snippets.

View lubien's full-sized avatar
💭
Teaching people 🔥🦩 LiveView 🔥🦩

Lubien lubien

💭
Teaching people 🔥🦩 LiveView 🔥🦩
View GitHub Profile
@lubien
lubien / dance.3.gif
Last active June 4, 2019 02:12
Wind
dance.3.gif
@lubien
lubien / dance.5.gif
Last active June 4, 2019 02:12
Dance
dance.5.gif
@lubien
lubien / dance.1.gif
Last active June 4, 2019 02:11
Part 5
dance.1.gif
@lubien
lubien / dance.0.gif
Last active June 4, 2019 02:11 — forked from urielfcampos/foo
JoJo
dance.0.gif
@lubien
lubien / foo
Last active June 4, 2019 01:49
Test
bar
@lubien
lubien / fcc-count.js
Last active February 1, 2018 20:22
FreeCodeCamp count. Count how many stuff you'd have to do on FreeCodeCamp (wrote on devtools, inb4: clean code)
JSON.stringify(Array.from(document.querySelectorAll('#accordion > *')).map((node, i, items) => {
if (node.nodeName !== 'H2') return false
const next = items[i + 1]
return {
title: node.querySelector('a').innerText.trim(),
items: Array.from(next.querySelectorAll('#nested > *')).map((node, i, items) => {
if (node.nodeName !== 'H3') return false
const next = items[i + 1]
return {
async function someHellComputation(initialData) {
const a = await fnA(initialData).catch(() => { throw 'errored on A' })
const b = await fnB(a).catch(() => { throw 'errored on B' })
return await fnC(b).catch(() => { throw 'errored on C' })
}
someHellComputation(10)
.then(console.log)
.catch(console.error)
const databaseGetUser = id =>
id === 'not-exists'
? Promise.reject('some weird database error')
: Promise.resolve({id, username: 'username'})
const databaseGetPosts = user =>
user.id === 'fail-to-get-posts'
? Promise.reject('some weird database error for posts')
: Promise.resolve([{title: 'A'}, {title: 'B'}])
const databaseGetUser = id =>
id === 'not-exists'
? Promise.reject('some weird database error')
: Promise.resolve({id, username: 'username'})
const databaseGetPosts = user =>
user.id === 'fail-to-get-posts'
? Promise.reject('some weird database error')
: Promise.resolve([{title: 'A'}, {title: 'B'}])
const databaseGetUser = id =>
id === 'not-exists'
? Promise.reject('some weird database error')
: Promise.resolve({id, username: 'username'})
function getUser(id) {
return databaseGetUser(id)
.catch(err => { throw 'user doesn\'t exists' })
}