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
<!-- JUST ADD JS --> | |
<html> | |
<head> | |
<style> | |
/*! CSS Used from: https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700|Material+Icons */ | |
.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:'liga';-webkit-font-smoothing:antialiased;} | |
/*! CSS Used from: https://www.gstatic.com/devrel-devsite/prod/v4d5d232859440be8edf63a1095b80ebe5c19605e99f3b348a30c4b0140c2eb88/cloud/css/app.css */ | |
devsite-code{clear:both;direction:ltr!important;display:block;margin:16px 0;overflow:hidden;position:relative;} | |
devsite-code .devsite-code-buttons-container{position:absolute;right:0;top:0;} | |
devsite-code .devsite-code-buttons-container button{-webkit-box-align:center;-webkit-align-items:center;align-items:center;background:0;border:0;-webkit-border-radius |
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
let url = "https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/"; | |
let kwparse = (url.replace('https://','').replace('http://','').replace('www','').replace('com','').split('-').join().split('/').join().split('.')).join(',').replace(/^,/, '') | |
let kwuniq = [...new Set(kwparse.split(','))].filter(function(e){return e}); | |
console.log(kwuniq) | |
// ["amazon", "SanDisk", "128GB", "microSDXC", "Memory", "Adapter", "dp", "B073JYC4XM"] | |
// Hat Tip - Find a cleaner version at https://gist.github.com/dsottimano/52060e6a43d96804f33c59366c472305 |
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
var myurl = "journey?reference=123&line=A&destination=China&operator=Belbo&departure=1043&vehicle=ARC"; | |
var keyval = myurl.split('?')[1].split('&'); | |
for(var x=0,y=keyval.length; x<y; x+=1) | |
console.log(keyval[x], keyval[x].split('=')[0], keyval[x].split('=')[1]); | |
/* | |
reference=123 reference 123 | |
line=A line A | |
destination=China destination China | |
operator=Belbo operator Belbo |
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
let url = "https://test.com/現役軍人轉公職-警察有哪些方法-補助5萬如何申請-4db7c0fd81b0" | |
const english = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?^[ -~]+$/; | |
if (english.test(url)) { | |
console.log("URL IS ENGLISH-most likely") | |
} |
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
// Inspired by https://towardsdatascience.com/quickly-extract-all-links-from-a-web-page-using-javascript-and-the-browser-console-49bb6f48127b | |
var atags = document.querySelectorAll("a"); | |
let links = []; | |
let hashes = {}; | |
for await (atag of atags){ | |
var anchor = atag.textContent.replace(/\s+/g, ' ').trim(); | |
var link = atag.href.replace(/\/$/, ""); // remove trailing slash | |
var rel = atag.rel; | |
var hash = md5(link) |
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
const data = [ | |
{ "name": "John", "time": new Date().toISOString(), "age": "old" }, | |
{ | |
"name": "Jeff", "time": new Date().toISOString(), "age": "older" | |
} | |
] | |
const header = Object.keys(data[0]).map(_ => JSON.stringify(_)).join(';') + '\n' | |
const outData = data.reduce((acc, row) => { | |
return acc + Object.values(row).map(_ => JSON.stringify(_)).join(';') + '\n' |
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
/* | |
This was inspired by https://twitter.com/saksters/status/1319018185744650240 as a better way to extract vehicle make and model from a url | |
*/ | |
// This should be in some database you have - array of makes and all of their models | |
const db = [{ | |
"make": "Renault", | |
"models": ["Captur", "Clio", "Clio Grandtour", "Espace", "Express", "Fluence", "Grand Espace", "Grand Modus", "Grand Scenic", "Kadjar", "Kangoo", "Kangoo Express", "Koleos", "Laguna", "Laguna Grandtour", "Latitude", "Mascott", "Mégane", "Mégane CC", "Mégane Combi", "Mégane Grandtour", "Mégane Coupé", "Mégane Scénic", "Scénic", "Talisman", "Talisman Grandtour", "Thalia", "Twingo", "Wind", "Zoé"] | |
}, | |
{ |
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
// open https://moz.com/mozcast | |
// open console and paste | |
let w = JSON.parse(JSON.stringify(document.querySelector('#metrics').__vue__.weather)) | |
console.table(w) |
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 json2Table(json) { | |
let cols = Object.keys(json[0]); | |
//Map over columns, make headers,join into string | |
let headerRow = cols | |
.map(col => `<th>${col}</th>`) | |
.join(""); | |
//map over array of json objs, for each row(obj) map over column values, |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=device-width,initial-scale=1"> | |
<head> | |
<title>CSV Upload/Parse</title> |