Skip to content

Instantly share code, notes, and snippets.

View neodigm's full-sized avatar
💯
Product Designer ⚡ Interactive Storyteller

Scott C. Krause neodigm

💯
Product Designer ⚡ Interactive Storyteller
View GitHub Profile
@neodigm
neodigm / isJSON.js
Created April 6, 2024 17:18
Is it valid JSON test
isJSON( sIn ){
let isVal = false
try { isVal = typeof (JSON.parse( sIn )) } catch ( er ) { }
return ( isVal == "object" )
}
@neodigm
neodigm / shallowDelta_object_diff.js
Created February 26, 2024 21:54
Return the difference between two JavaScript objects (shallow compare)
shallowDelta(newObj, oldObj){
if (Object.keys(oldObj).length == 0
&& Object.keys(newObj).length > 0)
return newObj;
let diff = {};
for (const key in oldObj) {
if (newObj[key] && oldObj[key] != newObj[key] ) {
diff[key] = newObj[key];
}
}
@neodigm
neodigm / neodigm_date_pretty.js
Created February 20, 2024 19:16
New Extended Date Pretty - With Time this time
const prettyTimeExt = ( sDt ) => {
return new Date( sDt ).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute:"2-digit", second:"2-digit" } );
}
@neodigm
neodigm / lorum_ipsum.js
Created February 16, 2024 21:48
JavaScript Generate Lorum Ipsum from original Latin De finibus
const genLorumIpsum = ( Sentences=1 )=>{ // Generate Lorum Ipsum | Orig Latin De finibus
if( Sentences == -1 ) Sentences = Math.floor(Math.random() * 5) + 1 // If -1 gen rnd num sentences 1-5
const aLI = "lorem ipsum a ab accusamus accusantium ad adipiscing alias aliquam aliquid amet animi aperiam architecto asperiores aspernatur assumenda at atque aut autem beatae blanditiis commodi consectetur consequatur consequuntur corporis corrupti culpa cum cumque cupiditate debitis delectus deleniti deserunt dicta dignissimos distinctio do dolor dolore dolorem doloremque dolores doloribus dolorum dquis ducimus ea eaque earum eius eligendi enim eos error ert esse est et eum eveniet ex excepturi exercitationem expedita explicabo facere facilis fuga fugiat fugit harum hic id illo illum impedit in incididunt inventore ipsa ipsam irure iste itaque iusto labore laboriosam laborum laudantium libero magnam magni maiores maxime minima minus modi molestiae molestias mollitia nam natus necessitatibus nemo neque nesciunt
const oResp = fetch("/uri/", {
"body": "IPOID=" + formData.IPOID + "&ProjectID=" + formData.ProjectID,
"headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" },
"method": "POST", "mode": "cors", "credentials": "include"
})
.then( ( resp )=>{
if( !resp.ok ) throw new Error( resp.status )
return resp.arrayBuffer();
} )
.then( ( buffer )=>{
@neodigm
neodigm / flick_aria_patch.js
Last active March 27, 2024 16:48
Flick Carousel ARIA-HIDDEN observer
class FlickPatch { // Flick Carousel ARIA-HIDDEN observer
constructor(_d, _sQ) {
this._d = _d; this._sQ = _sQ;
this.aF = []; this.aObs = [];
}
init() { //
this.aF = Array.from( this._d.querySelectorAll( this._sQ ))
if( this.aF.length ){
this.aObs = []
this.aF.forEach( ( eF )=>{
@neodigm
neodigm / collection_no_images.js
Last active June 15, 2023 19:47
Shopify custom collection of products without images
import fetch from 'node-fetch';
// import util from "util";
import jProds from "./json/chps_shpy_prods_images.json" assert { type: "json" };
let oHeaders = {'Content-Type': 'application/json', 'X-shopify-Access-Token': 'qqq'}
const SBASE = "https://qqq.myshopify.com/admin/api/2023-04/"
const SNOIMAGECOL = "449524269336"
let aTick = [];
let oZipup = (function( _d, _q ){ // Author: Scott C. Krause
let elZInp = _d.querySelector("#service_location")
let elZbtn = _d.querySelector("#get_services")
let sZip = ""
let jExcp = [ ["60010", "IL-Others", "/business/"], ["60119", "IL-Others", "/business/"] ]
return {
"init": function(){
if( elZInp && elZbtn ){
setInterval( oZipup.tick, 800 )
elZbtn.addEventListener( "click", oZipup.click )
const fs = require("fs")
const jSmall = require("./json/rics_updated_product_list_small.json"); //
const jClasses = require("./json/rics_export_classes.json"); //
const jSkus = require("./json/rics_export_skus.json"); //
let aOut = []
let sOut = ""
jSmall.forEach(function( sProd ){
let aItems = sProd.split(",")
// Get all combinations of a multi-select control
const getAllSubsets = aPowerSet => aPowerSet.reduce( (subsets, value) => subsets.concat( subsets.map(set => [value,...set]) ), [[]] );
// usage
getAllSubsets(["sun","mon","tue","wed","thr","fri","sat"])