Skip to content

Instantly share code, notes, and snippets.

@ajhsu
ajhsu / index.md
Created December 5, 2018 07:21
Bundled file size comparison when you only need debounce and throttle from Lodash.

Metrics

Without lodash
-rw-r--r--  1 ajhsu  staff    96K 12  5 14:41 app.bundle.js

Bundled with independent lodash.debounce && lodash.throttle package
-rw-r--r--  1 ajhsu  staff   106K 12  5 14:58 app.bundle.js

Bundled with `import lodash from 'lodash/function'`
@ajhsu
ajhsu / keybindings.json
Created November 7, 2018 02:45
Shortcut to insert `console.log();` in VSCode
[
{
"key": "cmd+'",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log(${TM_SELECTED_TEXT}$1)$0;"
}
}
]
@ajhsu
ajhsu / .tmux.conf
Created November 3, 2018 06:22 — forked from jikkujose/.tmux.conf
Change prefix key in tmux to back-tick and still type back-ticks
unbind C-b
set-option -g prefix `
bind ` send-prefix
@ajhsu
ajhsu / inject-inline-styles.js
Last active October 26, 2018 03:45
Dynamically injects an inline stylesheet into a web page
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
body {
background-color: yellow;
}
`;
document.querySelector('head').appendChild(style);
@ajhsu
ajhsu / memorySizeOfObject.js
Last active October 23, 2018 02:44 — forked from dohoons/memorySizeOfObject.js
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
let bytes = 0;
function sizeOf(obj) {
if (obj !== null && obj !== undefined) {
switch (typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@ajhsu
ajhsu / diff-pdf-files.md
Last active September 6, 2018 10:42 — forked from thbar/how-to-diff-pdf-files-with-git-and-diffpdf.md
How to diff PDF files with Git

One can use MD5 or plain text diff to see differences in PDF files. If that's not enough, here's how to use diffpdf which knows how to diff based on appearance or words:

  • brew install diff-pdf
  • edit your ~/.gitconfig to add this:
[difftool "diffpdf"]
  cmd = diff-pdf \"$LOCAL\" \"$REMOTE\"
@ajhsu
ajhsu / adb-commands
Last active August 16, 2018 06:28 — forked from Pulimet/AdbCommands
adb useful commands list
## Adb Server
adb kill-server
adb start-server
## Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
## Shell
@ajhsu
ajhsu / index.js
Last active January 28, 2023 15:33
document.createElement proxy function
var __createElement__ = document.createElement;
document.createElement = function(tagName, options){
console.log(`Element <${tagName}> created.`);
return __createElement__.call(this, tagName, options);
};
@ajhsu
ajhsu / remove_node_modules.sh
Created July 11, 2018 05:13
Remove node_modules folders recursively
find . -name "nodemodules" -type d -prune -exec rm -rf '{}' +
@ajhsu
ajhsu / userscript.js
Last active June 1, 2018 07:46
Temporary fixes slash issue on GitLab's WebIDE
// ==UserScript==
// @name Fix GitLab's WebIDE slash issue
// @version 0.1
// @author ajhsu
// @match https://gitlab.yourdomain.com/-/ide/project/*
// ==/UserScript==
/**
* Attach event handler for history.pushState
*/