Skip to content

Instantly share code, notes, and snippets.

@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),
];
@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 }
templateKey path title
about-page
/about
About our values

Hello

@nwingt
nwingt / TestApp.md
Last active September 27, 2019 17:40
Test App

Keybase proof

I hereby claim:

  • I am nwingt on github.
  • I am nwingt (https://keybase.io/nwingt) on keybase.
  • I have a public key ASBfYgY74f7HSM96VH_T025-dVXPiHde--4Fv2nTrGSe6Ao

To claim this, I am signing this object:

$base-width: 320;
@function px-vw($value) {
@return $value / $base-width * 100vw;
}
.like-button {
font-size: px-vw(16);
}
@nwingt
nwingt / example.js
Created June 9, 2017 03:17
Popup Issue
var popupWindow = window.open("http://www.nlcitychurch.org.hk");
popupWindow.onunload = function () {
console.log("do something when the pop up closes");
}
@nwingt
nwingt / sort_character_fgimages.md
Last active May 11, 2017 07:30
oice_SQL_snippet

Sort Character FG Images

Replace the {CHARACTER_ID} by the character id you want to order

SELECT A.id, 
       A.`name_en`
FROM   `asset` AS A 
       JOIN `character_fgimages` CA 
         ON CA.`asset_id` = A.`id` 
WHERE CA.`character_id` = {CHARACTER_ID}