This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <silent> <A-j> :m .+1<CR>== | |
nnoremap <silent> <A-k> :m .-2<CR>== | |
inoremap <silent> <A-j> <Esc>:m .+1<CR>==gi | |
inoremap <silent> <A-k> <Esc>:m .-2<CR>==gi | |
vnoremap <silent> <A-j> :m '>+1<CR>gv=gv | |
vnoremap <silent> <A-k> :m '<-2<CR>gv=gv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tweet: https://twitter.com/AnsonH_/status/1435189821740175363?s=20 */ | |
/* Example 1 */ | |
(() => { | |
console.log("Hello!"); | |
})(); | |
// Equivalent to... | |
(function() { | |
console.log("Hello!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tweet: https://twitter.com/AnsonH_/status/1435562848399228936?s=20 */ | |
const student = { name: "Tom", age: 20, gender: "male" }; | |
// Method 1: for-in loop | |
for (const key in student) { | |
console.log(key + ": " + student[key]); | |
} | |
// Method 2: Object.keys() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tweet: https://twitter.com/AnsonH_/status/1436669886055415816?s=20 */ | |
function slowFunction() { | |
for (let i = 0; i < 999999999; ++i) { | |
// do something... | |
} | |
} | |
/***** Browser example *****/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
"blocks": [ | |
{ | |
"alignment": "left", | |
"newline": true, | |
"segments": [ | |
{ | |
"foreground": "lightYellow", | |
"style": "plain", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"vim.smartRelativeLine": true, | |
"editor.cursorSurroundingLines": 8, | |
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?", | |
"vim.leader": "<space>", | |
"vim.normalModeKeyBindings": [ | |
{ | |
"before": ["<leader>", "e"], | |
"commands": ["workbench.view.explorer"] | |
}, |
OlderNewer