Skip to content

Instantly share code, notes, and snippets.

View therealkevinard's full-sized avatar
🎯
Focusing

Kevin Ard therealkevinard

🎯
Focusing
View GitHub Profile
@therealkevinard
therealkevinard / mirror.sh
Created August 24, 2018 14:04
Wget: Pull static mirror of production site (for etl, migration, etc)
#!/usr/bin/env bash
site="https://www.site.com/"
wget -e robots=off --wait 0.25 --mirror --convert-links --adjust-extension --page-requisites --no-parent ${site}
//-- blech
var is_blech = false;
var blech_init = function () {
var css_str = "@keyframes strobe { 50% {background: purple;color: #00ee00;} } .strobe {animation-play-state: running;animation-duration: 100ms;} .strobe > a {animation-play-state: running;animation: strobe 100ms steps(1, end) infinite;}";
var css_node = document.createElement('style');
css_node.appendChild(document.createTextNode(css_str));
document.head.appendChild(css_node);
is_blech = true;
}
@therealkevinard
therealkevinard / index.js
Created January 25, 2018 16:27
Open all external links in new tab
jQuery('a').map(function (i, el) {
var elem = $(el);
var href = elem.attr('href');
var host = window.location.host;
if (href.indexOf(host) < 0 && href.indexOf('http') > -1) {
elem.attr('target', '_blank');
}
})
@therealkevinard
therealkevinard / gist:f794b228498a812a7bbbf6eb5bd6705c
Created January 24, 2018 17:19
Woocommerce: when you have 221 variants that were mistakenly disabled.
/*--------------------------
Usage: Plunk this in the browser's js console.
- run checkUnchecked() to check all the unchecked things.
- run reportUnchecked() to see if anything isn't checked (useful to circle-back after going through 15 pages: wrap it in setInterval and flip back through
*/
window.collectCheckboxes = function () {
return Array.from(
jQuery('[name*="variable_enabled"]')
);
}
@therealkevinard
therealkevinard / index.js
Created January 19, 2018 20:59
Resize Imgs... the easy way.
const imagemin = require('imagemin');
const ImageminGm = require('imagemin-gm');
const Imagemin_jpgMoz = require('imagemin-mozjpeg');
const imagemin_gm = new ImageminGm();
const imPlugins = [
imagemin_gm.resize({
width: 700,
gravity: 'Center'
@therealkevinard
therealkevinard / timeMetrics.js
Last active January 17, 2018 22:14
Use detailed report view in toggl to find your avg focus-time for the day (or whatever range the report is showing)
/**
* I just paste this in my browser console when I'm curious. Nothing fancy ;)
* it doesn't account for paging, which.... if it was that serious, I'd use the Toggl Api.
*/
window.timeMetrics = (function(){
//-- get seconds worked from total (at the top of detailed report, at least)
var parts = document.querySelector('.total-sum .duration')
.outerText
.split(':');
//-- [hours, minutes, seconds]
@therealkevinard
therealkevinard / recap_sizer.js
Last active November 10, 2017 20:19
Make google recaptcha v2 responsive. ...sort of
/**
Still an IIFE, so it's still a drop-in; but this version accounts for a lot more edge cases and portability issues.
*/
(function (breakpoint, horizontalOffset, period) {
// var breakpoint = 500;
// var horizontalOffset = "-5rem";
var isOffset = false;
var hasNatural = false;
var horizontalNatural = {left: 0, right: 0};
var frames, jotscriptwrapper;
@therealkevinard
therealkevinard / updaterepos-find.sh
Last active May 27, 2017 20:42
I changed my github username. This sh helped find all my local workspace repos and fix the remote url (and https auth, if necessary)
#!/usr/bin/env bash
# MIT License: *especially* the warranty\liability limitations.
# Please be responsible when using bash to recursively alter git repos.
#
# usage ./updaterepos-find.sh
# where to start find.
base="/home/me/workspaces"
# github username mapping