xgqfrms / vscode

:cn: :rocket: Visual Studio Code & VSCode Code Snippets All in One 🎉
https://vscode.xgqfrms.xyz
MIT License
3 stars 1 forks source link
code-snippets dart go html5 javascript leetcode php python react sql swift typescript vscode vue webassembly xgqfrms

VSCode All In One

https://vscode.xgqfrms.xyz/

https://github.com/xgqfrms/vscode

VSCode (shortcuts)

Shift + Alt + A === Block Commnets

Ctrl + / === line Commnets

VSCode Code Snippets

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!"
  }
}

want more

VSCode useful Extensions All In One

VSCode useful Extensions All In One

refs

vscode & code snippets

https://www.cnblogs.com/xgqfrms/p/9226993.html