Skip to content

Instantly share code, notes, and snippets.

@jhkueh
jhkueh / Git_helpful_commands.md
Created March 22, 2021 09:54
Useful Git commands

How to Revert a Single File

git checkout [commit ID] -- path/to/file

@jhkueh
jhkueh / function_destructuring.js
Created May 29, 2020 03:52
function destructuring assigned parameters were not passed by reference
var a = { a: 1, b: 2, c:3 };
var b = { d: 4, e:5 };
function d1(obj) {
obj.a = 5;
}
d1(a)
// a = { a: 5, b: 2, c: 3 }
@jhkueh
jhkueh / dev-note-2018-04-16.md
Last active April 16, 2018 03:38
Testing custom datetime on Chrome, when can't change OS' datetime.
// From https://stackoverflow.com/a/39909754
/**
 * Overwrite Date constructor with configurable current time
 * @param {object} Date         - The native Date object
 * @param {Number} year         - Optional. Default year to this.
 * @param {Number} month        - Optional. Default month to this.
 * @param {Number} hour         - Optional. Default hour to this.
 * @param {Number} day          - Optional. Default day to this.
 * @param {Number} minute       - Optional. Default minute to this.
@jhkueh
jhkueh / vuex-deep-nested-objects.md
Created February 9, 2018 04:49
vuex deep nested objects

Vuex and Deep Nested Objects


Vue.js provides a good example for working with deep nested objects or tree data structures. But, how about when Vuex is involved?

Fortunately, Evan You (Vue.js' creator) gives us a hint:

...Or, you can use the same flat structure and use ids to reference nested items, and use a Vuex getter in each tree item component to retrieve its children.

So, how do we go about doing that? After a few attempts getting nested objects' reactivity to work, here is what I did.

Web CSS Tips


Crisp typography

body {
  font-family: Open Sans, Segoe UI, sans-serif;
 text-rendering: optimizeLegibility;
@jhkueh
jhkueh / dev-note-2017-10-17.md
Last active October 18, 2017 08:23
Foundation Tabs: Each `<a>` link in `<li>` SHOULD & MUST have a `href` that match the ID of a tab

Foundation Tabs: Each <a> link in <li> SHOULD & MUST have a href that match the ID of a tab.


Failure to do so will result in JS error.

E.g. The code below is invalid:

<ul class="tabs" data-tabs id="example-tabs">
@jhkueh
jhkueh / dev-note-2017-09-16.md
Last active September 16, 2017 10:02
Use document.querySelector() instead of document.getElementById() or document.getElementsByClassName()

Web browsers now support jQuery-like query selectors using document.querySelector().


For the jQuery code $('.sample#test'), the conventional vanilla JS way to do it might be:

var divById = document.getElementById('#test');

// or