Skip to content

Instantly share code, notes, and snippets.

View say2joe's full-sized avatar
🏠
Codifying my code; possibly refactoring!

Joseph J. Johnson say2joe

🏠
Codifying my code; possibly refactoring!
View GitHub Profile
@say2joe
say2joe / bookmarklets.js
Last active April 7, 2022 16:38
Bookmarklet Helpers & JavaScript One-Liners
/** Assorted 1-liners that are very useful to eliminate repetition **/
const siblings = (ele) => [].slice.call(ele.parentNode.children).filter((child) => child !== ele);
/**
CanIUse.com Helper - prompt for a keyword then display the correct caniuse.com page.
Save this as a bookmark in the Bookmark Bar for quick access to CanIUse.com pages.
NOTE: Use the minified version below for the URL of the bookmark.
**/
/** Minified:
@say2joe
say2joe / DOMCache.js
Last active April 12, 2021 03:49
DOM Cache for Application (JavaScript). Requires: jQuery and https://raw.github.com/say2joe/jquery.cache/master/jquery.cache.js
// Don't forget to include:
// https://raw.github.com/say2joe/jquery.cache/master/jquery.cache.js
var myApp = {
appInfo: {
description: "Caching paradigm for JavaScript Applications",
title: "jQuery App DOM Cache"
},
appProperty: (function(j){
return (j = jQuery.noConflict());
@say2joe
say2joe / snipLoader.js
Last active February 25, 2021 06:06
Element loading message
// Sets the html of an element with "Loading ..." and continues to print a dot up to 20 times.
// If the element is ready to be updated with actual content, simply clearInterval($el[0].interval);
// Requires: jQuery v1.4+
$el.html(function(i,html){
this.intcount = 0;
this.interval = ($.proxy(function(el){
return setInterval(function(){
if (++el.intcount < 20) el.innerHTML += '.';
else clearInterval(el.interval);
}, 500);
@say2joe
say2joe / JS-Quiz-Solutions.js
Last active February 25, 2021 05:59
My solutions to former employer's JS quiz for new employees
// Please save all your work in https://jsfiddle.net/
// Return the link to your work
// Answer five out of the seven questions
// Use test data when provided, however your functions should work with any similiarly structured data
// Use any additional libraries you like
// 1: Refactor this function to make it scalable.
var goto = function(evt, where, project, scenario, item, id){
if (evt && evt.stopPropagation){ evt.stopPropagation(); }
{"lastUpload":"2020-04-11T12:55:45.965Z","extensionVersion":"v3.4.3"}
@say2joe
say2joe / printMethod.js
Created November 2, 2012 22:18
JS Printer (for DOM Node)
{
css: "path/to/cssForPrinting.css",
print: function(DOMobj){
var winPrinter = window.open('', "SLPPrinter", "width=900,height=525,top=150,left=150,toolbars=no,scrollbars=yes,status=no,resizable=yes"),
html = (DOMobj.jquery)? DOMobj.parent().html() : (DOMobj.parentNode)? DOMobj.parentNode.innerHTML : (DOMobj.innerHTML || '');
if (document.createStyleSheet) document.createStyleSheet(this.css); else // Dynamically added CSS is different for IE.
$("head",winPrinter.document).append($("<link/>").attr({ rel: "stylesheet", type: "text/css", href: this.css }));
$("body",winPrinter.document).append(html); winPrinter.focus(); winPrinter.print(); winPrinter.close();
return DOMobj;
}
@say2joe
say2joe / enside.js
Last active January 5, 2020 03:51
Backbone Router (Controller) for iframe content. Includes bookmarking and routing support for navigating iframe content.
define(['rit','util/router','navIndicator'], function(RIT,Router) {
var $ = RIT.$, _ = RIT._, B = RIT.Backbone, Events = RIT.Events, self;
/**
* iEnside (/w enside.html) supports legacy Toyota connect and technology pages.
* Example uses include (URLs in browser's location / address bar, not iframe):
* http://local.rit.toyota.com/entune/enside.html#!/entune/learning-center/new-index.html
* http://local.rit.toyota.com/entune/enside.html#!phones (uses urls property object)
* http://local.rit.toyota.com/entune/enside.html (uses default route, "defRoute")
* @type {Router}
@say2joe
say2joe / PPA-Setup.sh
Last active October 27, 2019 17:36
Linux PPAs
sudo -s # || sudo -i
apt install apt-transport-https
add-apt-repository -y ppa:danielrichter2007/grub-customizer
add-apt-repository -y ppa:nilarimogard/webupd8 # WoeUSB
add-apt-repository -y ppa:yannubuntu/boot-repair
# Set up-to-date mirror for apt
# Check distros for errors
software-properties-gtk
@say2joe
say2joe / opkg-remove-and-clean.sh
Created March 15, 2019 14:47
OPkg: clean up from bad pkg install
#!/bin/sh
#takes one argument/parameter: the name of the package which didn't install correctly and should be removed along with its dependencies
#example: ./opkgremovepartlyinstalledpackage.sh pulseaudio-daemon
#get list of all packages that would be installed along with package x
PACKAGES=`opkg --force-space --noaction install $1 | grep "http:" | cut -f 2 -d ' ' | sed 's/\.$//'`
opkg update
for i in $PACKAGES
do
@say2joe
say2joe / RallyScrumTaskCreator.js
Last active November 21, 2018 17:57
Rally Scrum Tool: Task Creator Bookmarklet
javascript:if(!Custom)var Custom={};if(!Custom.UI)Custom.UI={};Custom.UI.TaskSelection=(function(){var userOptions={id:"rctsDD",css:"position: absolute;",options:["Implement Java code for task","Implement JS changes for task","Implement CSS changes for task","Implement XSL changes for task","Code Review (if needed) for task","JUnit Testing for task","Test Case Update for task","Test Case Review for task","Test Case Creation for task","Test Case Execution for task"]},targetId="name0";return{DropDown:(function(opts,s){s.addEventListener("keypress",function(e){if(e.keyCode==13)this.hide();},false);s.addEventListener("change",this.hide,false);for(var i=0,l=opts.options.length;i<l;i++){s.add(new Option(opts.options[i]),null);} with(s){id=opts.id;style.cssText=opts.css;style.display="none";size=1;} return document.body.appendChild(s);})(userOptions,document.createElement("select")),getTarget:function(){var el=(document.getElementById(targetId)||this.lkTarget);el.style.position="relative";return el;},getID:function(