Skip to content

Instantly share code, notes, and snippets.

View AnsonH's full-sized avatar
👾
Doing great

Anson Heung AnsonH

👾
Doing great
View GitHub Profile
[
// Tabs - Reorder with "Shift + Left/Right"
{
"key": "shift+left",
"command": "-cursorColumnSelectLeft",
"when": "editorColumnSelection && textInputFocus"
},
{
"key": "shift+left",
"command": "-cursorLeftSelect",
{
"vim.leader": "<space>",
"vim.normalModeKeyBindings": [
// Tabs
{
"before": ["H"], // Focus previous tab at the left
"commands": ["workbench.action.previousEditor"]
},
{
"before": ["L"], // Focus next tab at the right
[
{
"key": "h",
"command": "editor.action.scrollLeftHover",
"when": "editorHoverFocused"
},
{
"key": "j",
"command": "editor.action.scrollDownHover",
"when": "editorHoverFocused"
{
"vim.smartRelativeLine": true,
"editor.cursorSurroundingLines": 8,
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?",
"vim.leader": "<space>",
"vim.normalModeKeyBindings": [
{
"before": ["<leader>", "e"],
"commands": ["workbench.view.explorer"]
},
@AnsonH
AnsonH / pipsize.py
Created March 5, 2022 04:20
Lists size of pip packages
# Run `python pipsize.py` in Terminal to show size of pip packages
# Credits: https://stackoverflow.com/a/67914559/11067496
sort_in_descending = True # Show packages in descending order
import os
import pkg_resources
def calc_container(path):
total_size = 0
@AnsonH
AnsonH / p10k_classic.omp.json
Last active September 27, 2024 17:45
p10k_classic - Custom Oh My Posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "lightYellow",
"style": "plain",
@AnsonH
AnsonH / js-tip6.js
Last active September 19, 2021 11:08
Javascript Tip #6 - Rest parameters
/* Tweet: https://twitter.com/AnsonH_/status/1439546876718551049?s=20 */
/* First photo */
function myFunc(a, b, ...args) {
// Remaining arguments are stored in `args` array
console.log("a: ", a);
console.log("b: ", b);
console.log("args: ", args); // This is an array!
}
@AnsonH
AnsonH / js-tip5.js
Last active September 13, 2021 12:52
Javascript Tip #5 - Sleep
/* Tweet: https://twitter.com/AnsonH_/status/1437398568055181314?s=20 */
/* Sleep function */
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
/* Example */
async function takeNap() {
@AnsonH
AnsonH / js-tip4.js
Last active September 11, 2021 12:36
Javascript Tip #4 - Measure function execution time
/* Tweet: https://twitter.com/AnsonH_/status/1436669886055415816?s=20 */
function slowFunction() {
for (let i = 0; i < 999999999; ++i) {
// do something...
}
}
/***** Browser example *****/
@AnsonH
AnsonH / js-tip3.js
Last active September 9, 2021 12:38
Javascript Tip #3 - Class private properties and methods
/* Tweet: https://twitter.com/AnsonH_/status/1435945599367479303 */
class Student {
#gpa; // 1. Declare private property using the # sign
constructor(gpa) {
this.#gpa = gpa; // 2. Add this private property to class instance
}
// Private method