Skip to content

Instantly share code, notes, and snippets.

@nwingt
nwingt / TestApp.md
Last active September 27, 2019 17:40
Test App
templateKey path title
about-page
/about
About our values

Hello

@nwingt
nwingt / index.js
Last active April 23, 2021 05:02
POS Sample Project
// Define very hea database
const foodDatabase = {
"🍔": { id: "🍔", type: "main", price: 25 },
"🥪": { id: "🥪", type: "main", price: 20 },
"🌭": { id: "🌭", type: "main", price: 30 },
"🥗": { id: "🥗", type: "side", price: 20 },
"🍟": { id: "🍟", type: "side", price: 15 },
"🥛": { id: "🥛", type: "drink", price: 12 },
"🥤": { id: "🥤", type: "drink", price: 10 },
"🧋": { id: "🧋", type: "drink", price: 20 }
@nwingt
nwingt / shortenString.js
Created November 10, 2022 07:42
Shorten String
function shortenString(s, limit = 15, skippedReplacer = '...') {
if (!s || s.length <= limit) return s;
const trimmedLength =
Math.max(limit, skippedReplacer.length + 2) - skippedReplacer.length;
const chunkLength = Math.floor(trimmedLength / 2);
const [head, tail] = [
s.substring(0, chunkLength + (trimmedLength % 2)),
s.substring(s.length - chunkLength, s.length),
];