Skip to content

Instantly share code, notes, and snippets.

View BenFausch's full-sized avatar

Ben Fausch BenFausch

View GitHub Profile
@BenFausch
BenFausch / inactivity.js
Created March 11, 2019 22:10
detect inactive tabs with 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
BenFausch / promiseChain.html
Created March 5, 2019 21:46
Simplest implementation of a promise chain
<!doctype html>
<html>
<head>
<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">
</head>
<body>
@BenFausch
BenFausch / .htaccess
Created February 21, 2019 22:49
.htaccess for wp multisite
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
BenFausch / setup.sh
Created February 5, 2019 19:11
Apache/wordpress setup for virtual hosts
follow instructions here for mojave:
https://getgrav.org/blog/macos-mojave-apache-mysql-vhost-apc
//httpd conf file is here:
/usr/local/etc/httpd/httpd.conf
//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
BenFausch / upload.sh
Created January 23, 2019 17:35
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
BenFausch / wipe.sh
Last active January 16, 2019 22:50
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
#ref: http://osxdaily.com/2016/04/28/erase-free-space-mac-command-line/
diskutil secureErase freespace (level 0-4) /Volumes/(Drive Name)
@BenFausch
BenFausch / divs.html
Created December 18, 2018 17:31
50% div side by side
<!--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>
</div>
@BenFausch
BenFausch / darkslack.sh
Created November 26, 2018 22:42
Slack dark mode script to run when slack updates
#!/bin/bash
#don't forget chmod+x darkslack.sh
echo "document.addEventListener('DOMContentLoaded', function() {
$.ajax({
url: 'https://raw.githubusercontent.com/laCour/slack-night-mode/master/css/raw/black.css',
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
BenFausch / banner.js
Last active October 30, 2018 19:40
Sailthru Ad Banner Scheduler
//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
BenFausch / bannerperf.php
Last active October 25, 2018 16:37
Pull banner performance from sailthru to CSV file, by month
<?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']);