Skip to content

Instantly share code, notes, and snippets.

View johnmurch's full-sized avatar

John Murch johnmurch

View GitHub Profile
@johnmurch
johnmurch / diff.sh
Created August 25, 2022 16:27
Get Diff between 2 files
#!/bin/bash
sort file1 file2 | uniq -c | awk '$1 == 1 {print $2}'
ls -d */
@johnmurch
johnmurch / linksubstringmatch.js
Created May 5, 2022 17:38
Find String in ALL the links
Array.from(document.getElementsByTagName('a')).map((a) => a.href).map((l) => l.includes("keyword") ? l : '').filter(Boolean)
@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,