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 / isWebGL.js
Created October 9, 2020 14:41
Detect WebGL 2 browser support
var isWebGL2Available = function () { // Does this browser support WebGL 2?
try {
var canvas = document.createElement('canvas')
return !!(window.WebGL2RenderingContext && canvas.getContext('webgl2'))
} catch (e) {
return false
}
}
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active April 19, 2024 02:40
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) { /*ms*/ }
@dinh
dinh / html_data_attrib_2_javascript_dataset.js
Created July 12, 2020 07:33 — forked from neodigm/html_data_attrib_2_javascript_dataset.js
Convert HTML data attribute name to JS dataset name in camel case
function data2prop( sDset ){ // Convert HTML data attrib name to JS dataset name
sDset = sDset.replace("data-", "").toLowerCase();
let aDset = sDset.split(""), aDret = [], bUpper = false;
aDset.forEach( (sVal, nIx) => {
if( sVal == "-" ){
bUpper = true;
}else{
aDret.push( ( bUpper ) ? sVal.toUpperCase() : sVal );
bUpper = false;
}
@neodigm
neodigm / music-ad-blocker.js
Last active October 26, 2023 22:30
Automatically mute the Music player when Ads are playing and unmute when they are done (in Chrome).
let spotADify = ( (_d, _q, _t) => {
let eS = _d.querySelector( _q ), bS = true;
if( eS ){ // 🏖️ Play your Jams! 🎶
bS = ( eS.getAttribute("aria-label") == "Mute" );
setInterval( () => {spotADify.tick();}, _t);
return {
"tick": () => {
if((_d.title.indexOf("Adve") != -1) || (_d.title.indexOf("Spoti") != -1)){
if( bS ){ eS.click(); bS=!true; }
}else{
"use strict";
/*
Created an airport geo-proximity microservice that could answer the questions, like; “What are the three closest airports to me right now?”.
*/
var system_output = {
"airports": {
"ASE": {
"additionalInfo": null,
"cityName": "ASPEN",
"code": "ASE",
@neodigm
neodigm / dom_remove_all_tabindex_gt_0.js
Last active July 15, 2020 16:01
JavaScript | Remove ALL positive tabIndex on the entire page | ES5 | A11y Testing
// Remove ALL tabIndex on the entire page - Thats a fun thing to do. ES5
// From the entire document remove tabIndex if its value is greater than 0
[].slice.call( document.querySelectorAll("[tabIndex]") ).filter(function(el){ // Neodigm 2020
console.log("-- | " + el.tabIndex );
if( el.tabIndex >= 1 ){
el.tabIndex = "";
}
});
// From the entire document add a tabIndex="0" attrib if an A has no href
[].slice.call( document.querySelectorAll("A") ).filter(function(el){
-- ███████  ██████  ██ 
-- ██      ██    ██ ██ 
-- ███████ ██  ██ ██ 
--      ██ ██ ▄▄ ██ ██ 
-- ███████  ██████  ███████  Relational ⚡ Transactional
--             ▀▀           
CREATE OR REPLACE PACKAGE BODY ADD_ORS.ADD_UE AS
--
// Automotive Dealership stock photo gallery components (Adobe ActionScript 3.0)
import com.mosesSupposes.fuse.*;
import flash.external.*;
ZigoEngine.simpleSetup(Shortcuts, PennerEasing);
ZigoEngine.EASING = 'easeOutExpo';
ZigoEngine.DURATION = 5;
ZigoEngine.OUTPUT_LEVEL = 9;
@sumitpore
sumitpore / chrome-local-storage-api.js
Last active February 9, 2024 05:19
Chrome's Local StorageArea API in Synchronous way for use in Chrome extensions. Replace 'chrome.storage.local' by 'chrome.storage.sync' if you want to use Sync StorageArea
/**
* Retrieve object from Chrome's Local StorageArea
* @param {string} key
*/
const getObjectFromLocalStorage = async function(key) {
return new Promise((resolve, reject) => {
try {
chrome.storage.local.get(key, function(value) {
resolve(value[key]);
});