Skip to content

Instantly share code, notes, and snippets.

Avatar
💯
Product Designer Interactive Storyteller

Scott C. Krause neodigm

💯
Product Designer Interactive Storyteller
View GitHub Profile
@neodigm
neodigm / isKB.js
Created Aug 1, 2021
A11y | Is keyboard navigation
View isKB.js
// Change display attributes if the page is beiing navigated via kb
// I think this was an IEFE back in the day
// Useage:
/*
body:not([data-is-kb]) .h-vs__hidden,
body[data-is-kb="false"] .h-vs__hidden{ visibility: hidden; }
*/
"isKeyb": function( _bMode ){ // User navigation mode state
if( typeof _bMode !== "undefined" ){
@neodigm
neodigm / JavaScript_save_as_pdf.js
Created Jul 22, 2021
Save HTML contents as a PDF file.
View JavaScript_save_as_pdf.js
var doc = new jsPDF();
function saveDiv(id, title) {
doc.fromHTML(`<html><head><title>${title}</title></head><body>` + document.getElementById(id).innerHTML + `</body></html>`);
doc.save(title + '.pdf');
}
@neodigm
neodigm / gulpfile.js
Created Jul 12, 2021
Automated image compression with Gulp and JavaScript
View gulpfile.js
// ltd_auto_image
// SCK 20160503 | Gulp script QA Product AND Static images (55k)
// Notes: NODE 5.10.0 | GULP 3.9.x
//. 🌑🌒🌓🌔🌕🌖🌗🌘🌑
var del = require('del'),
vinylPaths = require('vinyl-paths'),
gulp = require("gulp"),
debug = require("gulp-debug"),
imagemin = require("gulp-imagemin"),
View because_vuex_is_too_much.js
// Dive into DOM to access Vuex array from mixin
export function getFeatureDOM(feature) {
// Return Feature Flag if it exists for current user
const features = document.querySelector('DIV#app').__vue__.$store.state.auth
.currentUser.activeFeatures
return features ? features.filter((fe) => fe === feature)[0] : null
}
@neodigm
neodigm / URL_in_BrainF_ck.bf
Created Jun 29, 2021
URL in the BrainF_ck language
View URL_in_BrainF_ck.bf
++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>++++++++++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>--.++<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>>>>>.<<<<<<<<<<<<<>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<>>>>>>>>>>+++.---<<<<<<<<<<>>>>>>>>>>>>+++.---<<<<<<<<<<<<>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>+++.---<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<<<<<<>>>>>>>>>>>>+.-<<<<<<<<<<<<>>>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<<<>>>>>>>>>>>>>>+++.---<<<<<<<<<<<<<<>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<>>>>>>--.++<<<<<<>>>>>>>>>>>>+++.---<<<<<<<<<<<<>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<>>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<<.
View vanilla_js_redirect_timout.html
<!DOCTYPE html>
<!-- Display a 10 second countdown then client redirect to home page -->
<html>
<head>
<title>Expired Redirect</title>
</head>
<body>
<style>
.exp--p {
font-family: sans-serif;
View find_cytoscape_data.js
// This snippet will log a url for each obs, so that you can eaisly find an OBS with event data
console.clear()
var aObs = document.querySelector( 'DIV#app' ).__vue__.$store.state.obsSys.obsList
var aHref = document.location.href.split("/")
aHref = aHref.slice(0,3).join("/")
var aTD = [ ... document.querySelectorAll("#app > div main tbody tr td:nth-child(1)")]
@neodigm
neodigm / mock-axios.js
Created May 23, 2021 — forked from cowboy/mock-axios.js
axios mocking via interceptors
View mock-axios.js
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
@neodigm
neodigm / fetch_overload.js
Created May 17, 2021
window fetch overload
View fetch_overload.js
const {fetch: origFetch} = window;
window.fetch = async (...args) => {
console.log("fetch called with args:", args);
const response = await origFetch(...args);
/* work with the cloned response in a separate promise
chain -- could use the same chain with `await`. */
response
.clone()
View overload_xhr.js
var RealXMLHttpRequest = window.XMLHttpRequest;
window.XMLHttpRequest = function(){
var ajax = new RealXMLHttpRequest();
var realOpen = ajax.open;
// steal the OPEN method | Has to be open to send header
ajax.open = function(method, url){
realOpen.apply(ajax, arguments);