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
// ==================== | |
// = OBJECT HELPERS = | |
// ==================== | |
export const set = (obj, prop, val) => { | |
obj[prop] = val | |
return obj | |
} | |
export const extractObj = (obj, prop) => | |
Object.keys(obj).map(key => |
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
[alias] | |
# List all aliases | |
aliases = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ / | |
# Edit your git configuration (cfg) | |
cfg = config -e --global | |
# Show the (last) commit | |
last = log -1 | |
# last = show HEAD |
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
// References | |
// | |
// - https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type | |
// - http://unicode.org/reports/tr15/#Norm_Forms | |
// - http://unicode.org/faq/normalization.html#7 (What is the difference is between W3C normalization and Unicode normalization?) | |
// - https://developer.mozilla.org/en-US/docs/Web/API/DOMParser | |
// | |
// Resources | |
// | |
// - http://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript |
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
// Resources | |
// | |
// - http://exploringjs.com/es6/ch_proxies.html | |
// - https://github.com/tvcutsem/harmony-reflect/issues/41 | |
// - https://esdiscuss.org/topic/proxies-stratifying-tostring-valueof | |
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy | |
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive | |
// - https://console.spec.whatwg.org/#inspection | |
// NOTE: When Chrome logs "Symbol(Symbol.toPrimitive)", that corisponds to |
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
// http://www.ecma-international.org/ecma-262/6.0/#sec-symbol.toprimitive | |
let base = { | |
[Symbol.toPrimitive] : hint => { | |
console.log(`toPrimitive hint: ${hint}`) | |
return 1; | |
}, | |
valueOf: () => 2, | |
toString: () => '3', | |
}; |
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
(function exposeNgUtil(target = window) { | |
if (!angular) { | |
console.error(`ERROR: ng-util cannot initialize because "angular" was not found!`); | |
return null; | |
} | |
getScope = el => angular.element( (el || document.getElementsByClassName('ng-scope')[0]) ) | |
let ngUtils = { | |
// Use Angular.js' DI system to retrieve a provider. |
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
let sourceObject = { foo: { bar: { baz: { qux: { value: "Hit!" } } } } }; | |
sourceObject.foo[Symbol.for('symbol')] = 'symbol value'; | |
function lookup(object, path) { | |
path = Array.isArray(path) ? path : path.split('.'); | |
for(let i = 0; i < path.length; i++) { | |
object = object[path[i]]; | |
if (!object) break; |
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
var sourceObject = { foo: { bar: { baz: { qux: { value: "Hit!" } } } } }; | |
function lookup(targetObject, targetPath) { | |
const name = 'o'; | |
const properties = []; | |
const segments = targetPath.split('.'); | |
for (let i = 1; i <= segments.length; i++) { | |
const current = `${name}.${segments.slice(0, i).join('.')}`; | |
properties.push(current); |
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
javascript: { | |
/* Adjust voice speed. Default = 1 */ | |
var speed = 2.5; | |
if (window.runTTS === undefined) { | |
/* Text to Speech function. Adjust the value of msg.rate to increase/decrease the playback speed. */ | |
window.runTTS = () => { | |
const text = window.getSelection().toString(); | |
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
// == PARENT =================================================================== | |
// CONSTRUCTOR | |
// For this demo we'll be inheriting from the Parent class | |
function Parent() {} | |
// METHODS | |
Parent.prototype.foo = function foo() { | |
return 'FOO'; | |
} |