Skip to content

Instantly share code, notes, and snippets.

Ben Fausch BenFausch

View GitHub Profile
BenFausch / inactivity.js
Created Mar 11, 2019
detect inactive tabs with js
View inactivity.js
//handles tab inactivity
var vis = (function() {
var stateKey, eventKey, keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
for (stateKey in keys) {
if (stateKey in document) {
BenFausch / promiseChain.html
Created Mar 5, 2019
Simplest implementation of a promise chain
View promiseChain.html
<!doctype html>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Promise Chain Example (supported by ALL browsers except IE11)</title>
<link rel="author" href="humans.txt">
BenFausch / .htaccess
Created Feb 21, 2019
.htaccess for wp multisite
View .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
BenFausch /
Created Feb 5, 2019
Apache/wordpress setup for virtual hosts
follow instructions here for mojave:
//httpd conf file is here:
//in httpd conf, the virtual hosts file is here:
sublime /usr/local/etc/httpd/extra/httpd-vhosts.conf
//if you run into root issues, all domains pointing to one page, check the following in httpd.conf:
BenFausch /
Created Jan 23, 2019
how to upload a new wordpress plugin version via svn
#First, put all your new code in the /trunk folder of your local svn repo
#use this to copy to a new tag (1.0.2):
svn cp trunk tags/1.0.2
#use this to check in
svn ci -m "tagging version 1.0.2"
#You may need to use your credentials upon submit
#if you need to delete your work to redo, use:
svn update
svn delete tags/1.0.2
BenFausch /
Last active Jan 16, 2019
Wipe free space - mojave
#replace (Drive Name), go cd / and see what the volume is named
#replace (level 0-4) with 4 for a full wipe
diskutil secureErase freespace (level 0-4) /Volumes/(Drive Name)
BenFausch / divs.html
Created Dec 18, 2018
50% div side by side
View divs.html
<!--white-space:nowrap will force divs to ignore whitespace with inline-block, be sure to reset whitespace to normal on the
child elements to keep formattting correct-->
<div style="width:100%; white-space:nowrap;">
<div style="width:50%; display:inline-block; white-space:normal">HOlA</div>
<div style="width:50%; display:inline-block; white-space:normal">MUCHACHO</div>
BenFausch /
Created Nov 26, 2018
Slack dark mode script to run when slack updates
#don't forget chmod+x
echo "document.addEventListener('DOMContentLoaded', function() {
url: '',
success: function(css) {
let overrides = 'code { background-color: #535353; color: #85c5ff; }.c-mrkdwn__pre, .c-mrkdwn__quote { background: #535353 !important; background-color: #535353 !important; }';
\$('<style></style>').appendTo('head').html(css + overrides);
BenFausch / banner.js
Last active Oct 30, 2018
Sailthru Ad Banner Scheduler
View banner.js
//This script in the console will check all visible boxes dependent on Zone name (or any other td text)
//You will have to uncheck and check 1 box to trigger the ST logic
jQuery('td').each(function() {
if (jQuery(this).text() === 'Banner') {
jQuery(this).siblings('td').each(function() {
console.log('t', jQuery(this).children())
if (jQuery(this).children().is('input')) {
console.log(this + 'is input')
jQuery(this).children().attr('checked', true)
BenFausch / bannerperf.php
Last active Oct 25, 2018
Pull banner performance from sailthru to CSV file, by month
View bannerperf.php
// create this file somewhere
include "simple_html_dom.php";
require_once __DIR__ . '/inc/sailthru.php';
//Load sailthru client
global $sailthruSettings;
$sailthru = new Sailthru_Client($sailthruSettings['key'], $sailthruSettings['secret']);
You can’t perform that action at this time.