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
<template> | |
<!-- 42 is a string --> | |
<Everything answer="42"></Everything> | |
<!-- 42 is a number --> | |
<Everything :answer="42"></Everything> | |
</template> |
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
<template> | |
<time v-bind:datetime="dateObject | toISODate"> | |
{{ dateObject | toPrettyDate }} | |
</time> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { |
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 LIKE_FN_NAME = "getTurtleVideo"; | |
const anObject = { | |
[LIKE_FN_NAME]() { | |
return "https://youtu.be/CMNry4PE93Y"; | |
}, | |
}; | |
anObject[LIKE_FN_NAME](); |
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
[ | |
{ | |
"key": "ctrl+shift+`", | |
"command": "terminal.focus", | |
"when": "!terminalFocus" | |
}, | |
{ | |
"key": "ctrl+shift+`", | |
"command": "workbench.action.focusActiveEditorGroup", | |
"when": "terminalFocus" |
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
/** @jsx jsx */ | |
import React from "react"; | |
import TeX from "@matejmazur/react-katex"; | |
import { jsx } from "theme-ui"; | |
const CodeBlock: React.FC<IProps> = ({ | |
children, | |
title, | |
...props | |
}) => { |
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 validOptions = ["corgi", "beagle", "dachshund"]; | |
const string1 = "The labrador jumped"; | |
const string2 = "The corgi jumped"; | |
validOptions.some((option) => string1.includes(option)); // false | |
validOptions.some((option) => string2.includes(option)); // true |
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
// adding one item to an iterator by calling .chain() with an argument that implements IntoIterator | |
pub fn build_proverb(list: &[&str]) -> String { | |
match list.is_empty() { | |
true => String::new(), | |
false => list | |
.windows(2) | |
.map(|window| format!("For want of a {} the {} was lost.", window[0], window[1])) | |
.chain( | |
// first() returns an Option which implements IntoIterator and can be .chain()ed to an other iterator | |
list.first() |
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
async function getReleaseInfo({ track = "", artist = "" }) { | |
let url = new URL("https://api.discogs.com/database/search"); | |
let searchParams = new URLSearchParams(); | |
searchParams.append("key", process.env.DISCOGS_CONSUMER_KEY); | |
searchParams.append("secret", process.env.DISCOGS_CONSUMER_SECRET); | |
searchParams.append("per_page", 10); | |
if (artist.length) { | |
searchParams.append("artist", artist); | |
} | |
if (track.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
pub fn is_armstrong_number(num: u32) -> bool { | |
let digits: Vec<_> = num | |
.to_string() | |
.chars() | |
.filter_map(|n| n.to_digit(10)) | |
.collect(); | |
let num_digits = digits.len() as u32; | |
num == digits.iter().map(|n| n.pow(num_digits)).sum() | |
} |
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
/// Determines whether the supplied string is a valid ISBN number | |
pub fn is_valid_isbn(isbn: &str) -> bool { | |
let numbers: Vec<u32> = isbn | |
.chars() | |
.filter_map(|c| match c { | |
'X' if Some('X') == isbn.chars().last() => Some(10), | |
_ => c.to_digit(10), | |
}) | |
.collect(); | |
if numbers.len() != 10 { |