This file contains hidden or 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 twilio = require("twilio")( | |
process.env.TWILIO_ACCOUNT_SID, | |
process.env.TWILIO_AUTH_TOKEN | |
); | |
async function sendText(body, mediaUrl) { | |
const text = await twilio.messages.create({ | |
body, | |
mediaUrl: mediaUrl ? [mediaUrl] : [], | |
from: process.env.TWILIO_PHONE_NUMBER, |
This file contains hidden or 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 got = require("got"); | |
async function getAwwPost() { | |
const response = await got( | |
"https://www.reddit.com/r/aww/top.json?t=day" | |
).json(); | |
for (const post of response.data.children) { | |
if (post.data.post_hint !== "image") { | |
continue; |
This file contains hidden or 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
hyperfine 'lua slow.lua' | |
# Benchmark #1: lua slow.lua | |
# Time (mean ± σ): 1.287 s ± 0.115 s [User: 1.120 s, System: 0.078 s] | |
# Range (min … max): 1.187 s … 1.528 s 10 runs | |
hyperfine 'lua fast.lua' | |
# Benchmark #1: lua fast.lua | |
# Time (mean ± σ): 39.3 ms ± 3.8 ms [User: 34.6 ms, System: 2.8 ms] | |
# Range (min … max): 35.3 ms … 58.3 ms 48 runs |
This file contains hidden or 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
class DatabaseError extends Error {} | |
const error = new DatabaseError("Unique constraint violation"); | |
// prints "true" | |
console.log(error instanceof Error); | |
// incorrectly prints "false" | |
console.log(error instanceof DatabaseError); |
OlderNewer