Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View olivertappin's full-sized avatar
😁

Oliver Tappin olivertappin

😁
View GitHub Profile
var navIsSticky = false,
stickyNavOffset = 50;
$(window).scroll(function() {
if (!navIsSticky && $(window).scrollTop() >= stickyNavOffset) {
$('.nav').addClass('nav--sticky');
navIsSticky = true;
} else if (navIsSticky && $(window).scrollTop() < stickyNavOffset) {
$('.nav').removeClass('nav--sticky');
navIsSticky = false;
}
@olivertappin
olivertappin / maintenance.html
Created May 16, 2016 15:26
Generic placeholder/maintenance page
<!DOCTYPE html>
<html>
<head>
<title>Site Maintenance</title>
<style type="text/css">
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
@olivertappin
olivertappin / .htaccess-maintenance
Created May 16, 2016 15:27
Maintenance page .htaccess
# Maintenance page
RewriteCond %{REMOTE_ADDR} !^000\.000\.000\.000
RewriteCond %{REQUEST_URI} !^/maintenance\.php$
RewriteCond %{REQUEST_URI} !^/company-logo.png$
RewriteRule ^(.*)$ https://www.domain.com/maintenance.php [R=307,L]
@olivertappin
olivertappin / resize.js
Created May 28, 2016 14:42
Screen resize function with interval
$(window).resize(function() {
if (this.resizeTo) clearTimeout(this.resizeTo);
this.resizeTo = setTimeout(function() {
$(this).trigger('resizeEvent');
}, 500);
});
$(window).bind('resizeEvent', function() {
// Rezize events
});
@olivertappin
olivertappin / gist:10d02bacdbd7c15c41829ce0f8fb200c
Created June 1, 2016 13:05
Redirects traffic to a static page (great for serving static files files via Nginx as a pretty URL)
RewriteRule ^/?test/.* /my-static-content/test.html [L]
@olivertappin
olivertappin / errors.sh
Created June 10, 2016 08:07
Concats all error_log files into one file
for file in $(find public_html/ -name error_log); do cat $file >> ~/error_logs; done
@olivertappin
olivertappin / update.sh
Last active June 22, 2016 14:49
Updating PHP 5.5 to PHP 5.6 in Homebrew
# Unlink your existing php installation
brew unlink php55
# Install the version you need
brew install php56
# Check for errors
# If you get: "Error: Directory not empty - /usr/local/opt/php56"
# Simply remove the directory with
sudo rm -rf /usr/local/opt/php56
@olivertappin
olivertappin / loop-over-posts.php
Created September 24, 2016 21:26
Loop over WordPress posts using PHP
<?php
require_once '../../../../wp-load.php';
$page = 0;
do {
$news = get_posts( [
'posts_per_page' => 50,
'paged' => $page
@olivertappin
olivertappin / Strings.php
Created October 10, 2016 12:46
Generate a random string in PHP 5.6 using mt_rand
<?php
class Strings
{
/**
* Generate a secure random string
*
* @param $length
* @param string $characters
* @param string $encoding
@olivertappin
olivertappin / gist:188a623a486ce8376b17392efeccb712
Created October 26, 2016 14:46
Get the actual file size of all the directories in the current directory
du -hcs ./*/