Skip to content

Instantly share code, notes, and snippets.

View johnmurch's full-sized avatar

John Murch johnmurch

View GitHub Profile
@johnmurch
johnmurch / serp.html
Created March 26, 2022 20:24
best camera lens for portraits
This file has been truncated, but you can view the full file.
<!DOCTYPE HTML><html itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="en"><head><meta charset="UTF-8"><meta content="origin" name="referrer"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>best camera lens for portraits - Google Search</title><script src="https://apis.google.com/_/scs/abc-static/_/js/k=gapi.gapi.en.fQLVS3SAB_U.O/m=gapi_iframes,googleapis_client/rt=j/sv=1/d=1/ed=1/rs=AHpOoo9-gtqpJORJvBFDdao_eAhWe8xjHw/cb=gapi.loaded_0" nonce="" async=""></script><script nonce="">(function(){
var b=window.addEventListener;window.addEventListener=function(a,c,d){"unload"!==a&&b(a,c,d)};}).call(this);(function(){window.google={kEI:'gXU_Yuv-PMuwytMP6s6EmAo',kEXPI:'31',kBL:'XZ95'};google.sn='web';google.kHL='en';})();(function(){
var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentN
@johnmurch
johnmurch / combine.sh
Created December 20, 2021 16:02
Combine ALL the JSON
jq -n '[ inputs[] ] ' *.json >> results.json
@johnmurch
johnmurch / json2csv.sh
Last active December 3, 2021 18:06
Convert JSON to CSV via CLI
cat sample.json| jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > sample.csv
@johnmurch
johnmurch / run-python.sh
Last active October 6, 2021 15:00
Python with Environment Variables via Bash
#!/usr/bin/env bash
export API_TOKEN=12345
export ML_TOKEN=google
sudo -E python seo-hack.py --pretty
@johnmurch
johnmurch / stripHtml.js
Created August 25, 2021 03:03
Remove HTML from String
function stripHtml(html){
var temporalDivElement = document.createElement("div");
temporalDivElement.innerHTML = html;
return temporalDivElement.textContent || temporalDivElement.innerText || "";
}
// let html = "<div><p>Whatever</p><p>This is a <b>test</b></p></div>";
// console.log(stripHtml(html));
@johnmurch
johnmurch / upload.html
Created August 18, 2021 12:33
CSV Upload and Parse
<!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>
@johnmurch
johnmurch / json2table.js
Last active August 23, 2021 18:46
table2json
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,
// open https://moz.com/mozcast
// open console and paste
let w = JSON.parse(JSON.stringify(document.querySelector('#metrics').__vue__.weather))
console.table(w)
@johnmurch
johnmurch / getMakeModel.js
Last active October 22, 2020 15:13
Based on the copypasta code of a tweet, extract vehicle make/model from a url
/*
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é"]
},
{
@johnmurch
johnmurch / json2csv.js
Created October 16, 2020 20:16
json2csv quick hack
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'