Skip to content

Instantly share code, notes, and snippets.

Ben Fausch BenFausch

Block or report user

Report or block BenFausch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@BenFausch
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
BenFausch / promiseChain.html
Created Mar 5, 2019
Simplest implementation of a promise chain
View promiseChain.html
<!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 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
BenFausch / setup.sh
Created Feb 5, 2019
Apache/wordpress setup for virtual hosts
View setup.sh
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 Jan 23, 2019
how to upload a new wordpress plugin version via svn
View upload.sh
#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 Jan 16, 2019
Wipe free space - mojave
View wipe.sh
#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 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>
</div>
@BenFausch
BenFausch / darkslack.sh
Created Nov 26, 2018
Slack dark mode script to run when slack updates
View darkslack.sh
#!/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 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
BenFausch / bannerperf.php
Last active Oct 25, 2018
Pull banner performance from sailthru to CSV file, by month
View bannerperf.php
<?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.