https://github.com/xgqfrms/vscode
Shift + Alt + A === Block Commnets
Ctrl + / === line Commnets
tst with dynamic testcases for leetcode
{
"TypeScript Template": {
"prefix": "tst",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2023-02-1$1",
" * @modified ",
" * ",
" * @description ",
" * @description ",
" * @difficulty Easy",
" * @difficulty Medium",
" * @difficulty Hard",
" * @ime_complexity O(n)",
" * @space_complexity O(n)",
" * @augments ",
" * @example ",
" * @link https://leetcode.com/problems/$2/",
" * @link https://leetcode.cn/problems/$2/",
" * @solutions ",
" * ",
" * @best_solutions ",
" * ",
" */",
"",
"export {};",
"",
"const log = console.log;",
"",
"// ",
"",
"",
"",
"/*",
"",
"class TreeNode {",
" val: number;",
" left: TreeNode | null;",
" right: TreeNode | null;",
" constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {",
" this.val = (val === undefined ? 0 : val);",
" this.left = (left === undefined ? null : left);",
" this.right = (right === undefined ? null : right);",
" }",
"}",
"",
"// LeetCode tree test case",
"// δΊεζ ηζεηοΌιε½δΎζ¬‘ιεοΌε·¦=>ε³οΌοΌιε° null θΏε (β
null ει’δΈθ½ζεθηΉδΊ)",
"const BinaryTreeGenerator = (arr:number[] = [], i = 0): (TreeNode | null) => {",
" if(arr.length === 0 || i > arr.length - 1 || arr[i] === null) {",
" return null;",
" }",
" const node = new TreeNode(arr[i]);",
" // ε
ε·¦εε³οΌ δΎζ¬‘ιε",
" node.left = BinaryTreeGenerator(arr, 2 * i + 1);",
" node.right = BinaryTreeGenerator(arr, 2 * i + 2);",
" return node;",
"}",
"*/",
"",
"/*",
"",
"// ζ΅θ―η¨δΎ test cases",
"const testCases = [",
" {",
" inputs: [],",
" input: '4193 with words ',",
" result: 4193,",
" desc: 'value equal to 4193',",
" },",
"];",
"",
"for (const [i, testCase] of testCases.entries()) {",
" const tree = BinaryTreeGenerator(testCase.input);",
" const result = invertTree(tree);",
" const treeResult = BinaryTreeGenerator(testCase.result);",
" log(`test case \\${i} result: `, JSON.stringify(result) === JSON.stringify(treeResult) ? `β
passed` : `β failed`, testCase.result);",
"",
" const [first, second] = testCase.inputs;",
" const result = $4(first, second);",
" log(`test case \\${i} result: `, JSON.stringify(result) === JSON.stringify(testCase.result) ? `β
passed` : `β failed`, result);",
" const result = $4(testCase.input);",
" log(`test case \\${i} result: `, result === testCase.result ? `β
passed` : `β failed`, result);",
" // log(`test case ${i} =`, testCase);",
"}",
"",
"*/",
"",
"",
"// $ npx ts-node ./$3\\ $2.ts",
"",
"/*",
"",
"",
"",
"*/",
""
],
"description": "TypeScript Template & code snippets!"
}
}
js6r with dynamic test cases
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2022-03-0$1",
" * @modified ",
" * ",
" * @description ",
" * @description ",
" * @difficulty Easy Medium Hard",
" * @complexity O(n)",
" * @time O(n)",
" * @augments ",
" * @example ",
" * @link https://leetcode.com/problems/$2/",
" * @link https://leetcode-cn.com/problems/$2/",
" * @solutions ",
" * ",
" * @best_solutions ",
" * ",
" */",
"",
"const log = console.log;",
"",
"// Generator",
"const $3 = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"export default $3;",
"export {",
" $3,",
"};",
"",
"/*",
"",
"",
"// ζ΅θ―η¨δΎ test cases",
"const testCases = [",
" {",
" input: '4193 with words ',",
" result: 4193,",
" desc: 'value equal to 4193',",
" },",
"];",
"for (const [i, testCase] of testCases.entries()) {",
" const result = $3(testCase.input);",
" log(`test case ${i} result: `, result === testCase.result ? `β
passed` : `β failed`, result);",
" // log(`test case ${i} result:\n\t\t`, result === testCase.result ? `passed β
` : `failed β`, result);",
" // log(`test case ${i} =`, testCase);",
"}",
"",
"",
"*/",
"",
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
js6r (with test cases)
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2022-03-0$1",
" * @modified ",
" * ",
" * @description $2",
" * @description $2",
" * @difficulty Easy Medium Hard",
" * @complexity O(n)",
" * @time O(n)",
" * @augments ",
" * @example ",
" * @link https://leetcode.com/problems/???/",
" * @link https://leetcode-cn.com/problems/???/",
" * @solutions ",
" * ",
" * @best_solutions ",
" * ",
" */",
"",
"const log = console.log;",
"",
"// Generator",
"const $3 = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"export default $3;",
"export {",
" $3,",
"};",
"",
"/*",
"",
"",
"// ζ΅θ―η¨δΎ",
"// test cases",
"const tests = [",
" '4193 with words ',",
" ' -42',",
" '12345657890 bigint',",
"];",
"for (const [i, test] of tests.entries()) {",
" const result = $3(test);",
" if(typeof result === 'boolean') {",
" log(`test${i} =`, result ? `β
` : `β`);",
" } else {",
" log(`test${i} =`, result);",
" }",
"}",
"",
"",
"*/",
"",
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
test
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2022-03-0$1",
" * @modified ",
" * ",
" * @description $2",
" * @description $2",
" * @difficulty Easy Medium Hard",
" * @complexity O(n)",
" * @time O(n)",
" * @augments ",
" * @example ",
" * @link https://leetcode.com/problems/???/",
" * @link https://leetcode-cn.com/problems/???/",
" * @solutions ",
" * ",
" * @best_solutions ",
" * ",
" */",
"",
"const log = console.log;",
"",
"// Generator",
"const $3 = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"export default $3;",
"export {",
" $3,",
"};",
"",
"/*",
"",
"// error",
"const test1 = isValid(`((}}`);",
"// ok",
"const test2 = isValid(`()[]{}`);",
"",
"log(`βtest =`, test1 ? `β
` : `β`);",
"log(`β
test ok =`, test2 ? `β
` : `β`);",
"",
"// test cases",
"// ζ΅θ―η¨δΎ",
"const tests = [",
" '4193 with words ',",
" ' -42',",
" '12345657890 bigint',",
"];",
"for (const [i, test] of tests.entries()) {",
" const result = $3(test);",
" log(`test${i} =`, result, result ? `β
` : `β`);",
"}",
"",
"",
"*/",
"",
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
js6r
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2019-08-$1",
" * ",
" * @description $2",
" * @augments $3",
" * @example $4",
" * @link $5",
" * ",
" */",
"",
"const log = console.log;",
"",
"const $2Generator = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"",
"export default $2;",
"",
"export {",
" $2,",
"};",
"",
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
js6r
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2020-01-0$1",
" * ",
" * @description $2",
" * @augments $3",
" * @example $4",
" * @link $5",
" * ",
" */",
"",
"const log = console.log;",
"",
"const $2Generator = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"",
"export default $2;",
"",
"export {",
" $2,",
"};",
""
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
ts6r
{
"TypeScript ES6 React Template": {
"prefix": "ts6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2019.0$1.0$2",
" * ",
" * @description $3",
" * @augments ",
" * @example ",
" * @link $4",
" * ",
" */",
"",
"const $3Generator = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $6result;",
"};",
"",
"",
"",
"export default $3;",
"",
"export {",
" $3,",
"};",
""
],
"description": "TypeScript ES6 React Template & code snippets!"
}
}
p3y
{
"Python3 Template": {
"prefix": "py3",
"body": [
"# coding: utf8",
"",
"__author__ = 'xgqfrms'",
"",
"\"\"\"",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2020-01-0$1",
" * ",
" * @description $2",
" * @augments $3",
" * @example $4",
" * @link $5",
" * ",
" */",
"",
"\"\"\""
],
"description": "Python3 Template & code snippets!"
}
}
js6r οΌnew versionοΌ
{
"JavaScript ES6 React Template": {
"prefix": "js6r",
"body": [
"\"use strict\";",
"",
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2020-08-0$1",
" * @modified ",
" * ",
" * @description $2",
" * @difficulty Easy Medium Hard",
" * @complexity O(n)",
" * @augments ",
" * @example ",
" * @link ",
" * @solutions ",
" * ",
" */",
"",
"const log = console.log;",
"",
"// Generator",
"const $3 = ($5datas = [], debug = false) => {",
" let result = ``;",
" // do something...",
" return $7result;",
"};",
"",
"",
"",
"export default $3;",
"",
"export {",
" $3,",
"};",
"",
],
"description": "JavaScript ES6 React Template & code snippets!"
}
}
got
{
"Go Template": {
"prefix": "got",
"body": [
"/**",
" * ",
" * @author xgqfrms",
" * @license MIT",
" * @copyright xgqfrms",
" * @created 2020-01-0$1",
" * ",
" * @description $2",
" * @augments $3",
" * @example $4",
" * @link $5",
" * ",
" */",
"",
"package main",
"",
"// import \"fmt\"",
"// import (\"fmt\")",
"import (",
" \"fmt\"",
" \"strings\"",
" \"time\"",
" \"math/rand\"",
" \"testing\"",
" \"bytes\"",
" \"encoding/base64\"",
" \"image\"",
" \"image/png\"",
")",
"",
"func main() {",
" fmt.Println(\"Hello, Go\")",
"}",
"",
""
],
"description": "Go Template & code snippets!"
}
}
VSCode useful Extensions All In One
vscode & code snippets