Skip to content

Instantly share code, notes, and snippets.

View johnmurch's full-sized avatar

John Murch johnmurch

View GitHub Profile
@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 / 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 / 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 / combine.sh
Created December 20, 2021 16:02
Combine ALL the JSON
jq -n '[ inputs[] ] ' *.json >> results.json
@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 / 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)
ls -d */
@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}'
@johnmurch
johnmurch / uniq.sh
Created September 6, 2022 09:59
Get Uniques
sort file | uniq > new_file
@johnmurch
johnmurch / colr.js
Last active September 19, 2022 15:11
Get Fonts from Website
// via https://stackoverflow.com/a/39900099
function listFonts () {
let fonts = []
for (let node of document.querySelectorAll('*')) {
if (!node.style) continue
for (let pseudo of ['', ':before', ':after']) {
let fontFamily = getComputedStyle(node, pseudo).fontFamily
fonts = fonts.concat(fontFamily.split(/\n*,\n*/g))
}
}