This file contains hidden or 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
'use strict'; | |
/* | |
transform JSX to tagged template literals | |
history: | |
2019-01-25 initial working draft | |
available types: | |
JSX_TYPES = [ |
This file contains hidden or 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
params-conventions: | |
pagination: | |
page=0 base zero; ui can adjust as-needed; | |
pageSize=3; | |
API sets defaults and limits as-desired; | |
eg https://app.elementanalytics.com/jobs/v1/org/1061177/runs?page=0&pageSize=3 |
This file contains hidden or 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
/* | |
copy this into your devtools and run it; | |
for more info using devtools see: https://developers.google.com/web/tools/chrome-devtools/console/get-started#javascript | |
possibly save to a snippet in the devtools, or come back to the gist for updates | |
https://gist.github.com/jimmielemontgomery/ => choose "utils" | |
*/ | |
function linkFinder(...flowIds){ | |
var $layers = document.querySelector('.srd-link-layer') || {}; | |
var react = Object.entries($layers).find((it)=>{ return /react/i.test(it[0]) }) || []; | |
return !react.length ? [] : react[1]._currentElement.props.children |
This file contains hidden or 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
// perf of keys and key length, generally Object.keys vs _.keys | |
function test(o, a, b, len=10){ | |
var i = 0, name = a.name || 'run1'; | |
console.time(name); | |
while(len > i++){ | |
a(o).length; | |
} | |
console.timeEnd(name); | |
i = 0, name = b.name || 'run2'; | |
console.time(name); |
This file contains hidden or 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
https://developer.mozilla.org/en-US/docs/Web/API/URL | |
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams | |
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch | |
https://developers.google.com/web/updates/2016/01/urlsearchparams?hl=en | |
var url = new URL(location.hash.replace(/^#/,''), location.origin); | |
url.searchParams.set('x',1234) | |
url.search | |
"?x=1234" |
This file contains hidden or 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
/* | |
timeouts and other signaling | |
https://developers.google.com/web/updates/2017/09/abortable-fetch | |
basics | |
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch | |
*/ | |
function fetchr(url, req={}){ | |
const headers = Object.assign({ | |
'X-Auth-Token': localStorage.authToken || '' | |
,'X-Organization-Id': localStorage.orgId || '' |
This file contains hidden or 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
/* samples LTR and RTL; Persian, Hebrew, Arabic, Thai, English forms, Korean, Chinese, Japanese: | |
"11/2/2018, 12:03:27 PM PDT" | |
"02/11/2018, 12:03:27 GMT-7" | |
"2018. 11. 2. 오후 12시 3분 27초 GMT-7" | |
"٢/١١/٢٠١٨ ١٢:٠٣:٢٧ م غرينتش-٧" | |
"2018/11/2 GMT-7 下午12:03:27" | |
"۱۳۹۷/۸/۱۱، ۱۲:۰۳:۲۷ (−۷ گرینویچ)" | |
"30/11/2 12:03:27 GMT-7" | |
"2/11/2018 12.03.27 GMT-7" | |
"2.11.2018, 12:03:27 GMT-7" |
This file contains hidden or 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 mkjob(i, item={}){ return Object.assign({}, { | |
"id":"01539731542362","name":"0 job 1539731542362","triggerType":"USER_TRIGGERED","creator":"SYSTEM","submitDate":1539731538041,"startDate":1539731541128,"endDate":1539731542362,"status":"Completed" | |
}, item) } | |
function randomInclusive(max=1, min=0){ | |
max = Math.ceil(max); | |
min = Math.floor(min); | |
// random <= [0, 0.9999] never 1 | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function mkjobs(config={}){ |
This file contains hidden or 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
/* | |
a simple generalized example of stubbing an API response to save the effort of standing up or proxying APIs | |
for repeatable UI work prior to wiring up or staging | |
simply handle the success or fail response object, in this example it's just success | |
an object's data attribute has the desired API response body like: {data: API-response-JSON-here} | |
this specific case was derived from the jobs redux global handling and could easily be repurposed for any approach | |
note prexisting responses can be found via integration/staging/etc just | |
pretty-print app.js or whatever in dev tools, search and set breakpoints for fetch handling | |
*/ |