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 / vuejs_provide_inject_reactive.js
Last active September 6, 2021 16:03
Vuejs Provide Inject Reactive Component Communication
//. Parent Component
provide() {
return {
cyRef: this.cytoRef,
obsId: this.obsId,
hostname: () => this.reactiveHostname
}
}
//. Child Component
@neodigm
neodigm / previous_month.js
Last active August 22, 2021 03:49
JavaScript get first and last date of the previous month (week?)
function previousMonth(originalDate) {
let f = new Date(originalDate)
let l = new Date(originalDate)
l.setDate(0) // set to last day of previous month
f.setDate(0)
f.setDate(1) // set to the first day of that month
return [f, l]
}
function previousWeek(originalDate) {
watch: {. //. Hydrate the Vuetify Pagination object to persist the Sort colunm and Number of Pages.
pagination(val) {
const lsKey = this?.$route?.path || 'lsKey'
localStorage.setItem(lsKey, JSON.stringify(val, null))
}
},
mounted() {
const lsKey = this?.$route?.path || 'lsKey'
if (localStorage.getItem(lsKey)) {
this.pagination = JSON.parse(localStorage.getItem(lsKey))
@neodigm
neodigm / isKB.js
Last active December 28, 2021 02:30
A11y | Is keyboard navigation
// Change display attributes if the page is being 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 July 22, 2021 17:02
Save HTML contents as a PDF file.
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 July 12, 2021 12:43
Automated image compression with Gulp and JavaScript
// 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"),
// 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 June 29, 2021 18:03
URL in the BrainF_ck language
++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>++++++++++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<<>>>>>>--.++<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>>>>>.<<<<<<<<<<<<<>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<>>>>>>>>>>+++.---<<<<<<<<<<>>>>>>>>>>>>+++.---<<<<<<<<<<<<>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>----.++++<<<<<<<<<<<<<<<>>>>>>>>>+++.---<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<<<<<<>>>>>>>>>>>>+.-<<<<<<<<<<<<>>>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<<<>>>>>>>>>>>>>>+++.---<<<<<<<<<<<<<<>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<>>>>>>--.++<<<<<<>>>>>>>>>>>>+++.---<<<<<<<<<<<<>>>>>>>>>>>>>>-.+<<<<<<<<<<<<<<>>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<<.
<!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;
// 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)")]