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
# count all `index.html` and `index.md` files in the current directory recursively. | |
find . -iname 'index.html' -o -iname 'index.md' | wc -l |
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
// https://nationalkitty.com/cat-ancestry-where-do-cats-come-from/ | |
const pantherinae = { | |
roar: function () { | |
console.log(`${this.name} is roaring!`); | |
}, | |
domesticated: false, | |
size: "large", | |
sound: "roar", | |
}; |
This file has been truncated, but you can view the full file.
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
{ | |
"/files/en-us/games/anatomy/index.md": { | |
"title": "Anatomy of a video game", | |
"slug": "Games/Anatomy", | |
"tags": ["Games", "JavaScript", "Main Loop", "requestAnimationFrame"] | |
}, | |
"/files/en-us/games/examples/index.md": { | |
"title": "Examples", | |
"slug": "Games/Examples", | |
"tags": ["Demos", "Example", "Games", "Web"] |
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
'use strict' | |
const { pipeline } = require('stream') | |
const { join } = require('path') | |
const { createReadStream, createWriteStream } = require('fs') | |
// this is highly performant for large files | |
// as the read and write happens in small chunks | |
pipeline( | |
createReadStream(__filename), | |
createWriteStream(join(__dirname, 'out.txt')), |
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
function binarySearch(id, array) { | |
const mid = Math.floor(array.length / 2); | |
if (array[mid].id === id) { | |
return array[mid]; | |
} else if (array[mid].id < id) { | |
return binarySearch(id, array.slice(mid)); | |
} else { | |
return binarySearch(id, array.slice(0, mid)); | |
} |
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
function calculateMealPrice(mealCost, tipPercent, taxPercent) { | |
const tipAmount = (tipPercent / 100) * mealCost; | |
const taxAmount = (taxPercent / 100) * mealCost; | |
return Number.parseInt(Math.round(mealCost + tipAmount + taxAmount), 10); | |
} | |
calculateMealPrice(12.00, 20, 8); |
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 fs = require("fs"); | |
const { update } = require("./util"); | |
const entries = ["one", "two"]; | |
function doUpdate() { | |
let fileContents = fs.readFileSync("./sample.json", "utf8"); | |
fileContents = update(fileContents, entries); | |
console.log(entries); // what will this output? | |
} |
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
{ | |
"Font face": { | |
"scope": "css, scss", | |
"prefix": "fontface", | |
"body": [ | |
"@font-face {", | |
" font-family: \"$1\";", | |
" font-display: swap;", | |
" src: url(\"$2\") format(\"woff2\"),", | |
" url(\"$3\") format(\"woff\");", |
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
{ | |
"describe block": { | |
"prefix": "describe", | |
"body": [ | |
"describe('$1', () => {", | |
"", | |
" it('$2', () => {", | |
" $3", | |
" expect(data).toBe('{}');", | |
" });", |
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
backend: | |
name: git-gateway | |
branch: netlify-published-content | |
media_folder: "static/images/uploads" # Media files will be stored in the repo under static/images/uploads | |
public_folder: "/images/uploads" # The src attribute for uploaded media will begin with /images/uploads | |
collections: | |
- name: "homepage" # Used in routes, e.g., /admin/collections/blog | |
label: "Homepage" # Used in the UI |