This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let activeEffect | |
class Dep { | |
subscribers = new Set() | |
depend() { | |
if (activeEffect) this.subscribers.add(activeEffect) | |
} | |
notify() { | |
this.subscribers.forEach((sub) => sub()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
* { | |
user-select: none; | |
} | |
body { | |
margin: 0; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
} | |
#app { | |
height: 100vh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
your_collection.find({ | |
your_date_field: { | |
$gte: ISODate('2020-07-01T00:00:00.000Z'), // From | |
$lt: ISODate('2020-07-31T23:59:00.000Z'), // Until | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an addition to my Vue.js Global 2020 talk about Vue 3 Reactivity. | |
Some people asked for the slides. You can find them here: | |
https://marcbackes.com/d8qaLT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { computed, ref, effect } = require('@vue/reactivity') | |
let users = ref([]) | |
let onlineUsers = computed(() => { | |
return users.value.filter((user) => user.status === 'online') | |
}) | |
effect(() => { | |
console.log('# of online users changed', onlineUsers.value.length) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toRandom = c => Math.random() > 0.5 ? c.toUpperCase() : c.toLowerCase() | |
const toSarcasm = text => text.split('').map(c => toRandom(c)).join('') | |
console.log(toSarcasm('This is a sarcastic message')); //ThIS Is A SarcAstiC mesSAgE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ "$*" == "whiskey" || "$*" == "whiskey wednesday" ]]; then | |
MESSAGE="Whiskey and coding, what can go wrong? Cheers! 🙌" | |
PREFIX='🥃' | |
elif [[ "$*" == "beer" || "$*" == "happy hour" ]]; then | |
MESSAGE='Cheers 🍻' | |
PREFIX='🍺' | |
elif [[ "$*" == "frontend" || "$*" == "fe" ]]; then | |
MESSAGE='' | |
PREFIX='🎨' | |
elif [[ "$*" == "backend" || "$*" == "be" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################# | |
# Marc's LAZY code-related aliases (some might require oh-my-zsh) | |
################################################################# | |
# For lazy commits | |
alias c="git commit -m" | |
# Lazy access to yarn | |
alias y="yarn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleepSort = arr => { | |
arr.forEach(n => { | |
setTimeout(() => console.log(n), n * 1000) | |
}) | |
} | |
sleepSort([5, 7, 1, 2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Standalone, dependency-free version of rock paper scissors | |
// Author: Marc Backes (@themarcba) | |
// Available choices and it's associated values | |
const choiceMap = { r: 'rock', p: 'paper', s: 'scissors' } | |
// Request an input from the user | |
const getInput = query => { | |
return new Promise((resolve, reject) => { | |
const readline = require('readline').createInterface({ |