Skip to content

Instantly share code, notes, and snippets.

View BenFausch's full-sized avatar

Ben Fausch BenFausch

View GitHub Profile
@BenFausch
BenFausch / detectSwipe.js
Created May 25, 2018 17:07
swipe detection in Vanilla
let touchstartX = 0;
let touchstartY = 0;
let touchendX = 0;
let touchendY = 0;
const gestureZone = document.getElementById('gestureZone');
gestureZone.addEventListener('touchstart', function(event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
@BenFausch
BenFausch / run.sh
Created June 11, 2018 20:50
webfaction letsencrypt
#REF:
#https://github.com/will-in-wi/letsencrypt-webfaction
#To install letsencrypt on webfaction
GEM_HOME=$HOME/.letsencrypt_webfaction/gems RUBYLIB=$GEM_HOME/lib gem2.2 install letsencrypt_webfaction
#Edit $HOME/.bash_profile to add the function below:
function letsencrypt_webfaction {
@BenFausch
BenFausch / breadcrumbs.php
Created June 20, 2018 15:39
Generates wordpress breadcrumbs
/**
* Generate Breadcrumbs
*/
function the_breadcrumb() {
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = ' | '; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
@BenFausch
BenFausch / notes.txt
Created June 27, 2018 18:48
Notes for dealing with emails
GENERAL:
- every element must be in a html tag with inline styles
- complex/responsive designs will break
- tables are best as they are supported and handle fluid layout across almost all email clients
- images and containers require html style attrs align="", width="", and height="" to keep design
- use padding instead of margin as some clients ignore margins
Outlook 2007/2013
html tags override sizes, i.e. if you want a 48px <h6> it won't work, so use tags for sizing
user's security settings will define whether or not images load
@BenFausch
BenFausch / dynamicCarousel.js
Created June 27, 2018 18:50
Dynamic carousel
//uses hammer.js to detect swipe and trigger next/prev buttons
//counts numbers of child items to handle carousel and add bullets in mobile view
eventSlider: function() {
var marginArray = [];
var i = 0;
var length = jQuery('.home--2-col-events--right--slider-slide').length;
//set container and child widths
jQuery('.home--2-col-events--right--slider-container').css(
'width', ((length * 100) + 1) + '%'
@BenFausch
BenFausch / update.sh
Created August 2, 2018 15:56
Update Homebrew SQL Password
#for a specific mysql version:
$(brew --prefix mysql@5.7)/bin/mysqladmin -u root -p password NEWPASS
#for generic
$(brew --prefix mysql)/bin/mysqladmin -u root -p password NEWPASS
#may or may not need -p, depending on if you know the pass or not
@BenFausch
BenFausch / convert.js
Created August 22, 2018 21:27
Vanilla JS Convert time object to readable AM/PM elements
//where startTime ==== new Date(timestamp);
var hours = startTime.getHours();
var minutes = startTime.getMinutes();
var amPm = hours > 11 ? 'pm' : 'am';
hours > 12 ? hours = hours - 12 : hours;
minutes < 10 ? minutes = '0' + minutes : minutes;
var display = hours + ':' + minutes + ' ' + amPm;
@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 / 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 / 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>