Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Arnold ambercouch

View GitHub Profile
@ambercouch
ambercouch / axio-snippet.js
Last active Feb 18, 2020
Fix Shopify slate and browsersync issue and axio issue
View axio-snippet.js
return axios('https://v.shopify.com/slate/track', axiosConfig).catch(() => {});
View bbd-geo-ip.html
<script type="text/javascript">
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
@ambercouch
ambercouch / conditional.php
Last active May 22, 2019
Wordpress widget logic contidional code to use in widgets
View conditional.php
<?php
//Paste the code below into the widget logic field of you widget and edit the page IDs as needed
//The code below will display your widget on pages 8,9 and 10 and any page that is a child of page 8
global $post; return (is_page(array(8,9,10)) || in_array($post->post_parent, array(8)));
//The code below will display you widget on pages that us the faq-page.php template file
global $post; return (get_page_template_slug( $post->ID ) == 'page-templates/faq-page.php');
@ambercouch
ambercouch / gist:6dfa83826724aa76006373b859574d3a
Last active Sep 26, 2019
Install Composer On Webfaction
View gist:6dfa83826724aa76006373b859574d3a
ln -s `which php72` ~/bin/php
export PATH=$HOME/bin:$PATH
cd bin
curl -sS https://getcomposer.org/installer | php72
echo -e "\n# Composer\nalias composer=\"php72 \$HOME/bin/composer.phar\"" >> $HOME/.bash_profile
source $HOME/.bash_profile
@ambercouch
ambercouch / functions.php
Created Aug 14, 2018
Remove all the style sheets from a wordpress theme except $styles_to_keep
View functions.php
// add the action
add_action('wp_print_styles', 'ac_remove_default_styles');
function ac_remove_default_styles ()
{
// get all styles data
global $wp_styles;
$styles_to_keep = array('admin-menu');
@ambercouch
ambercouch / functions.php
Last active Aug 14, 2018
Output all the enqeued stylesheet use in the current wordpress theme to the javascript console.
View functions.php
function ac_inspect_scripts() {
global $wp_styles;
echo '<script id="ac_inspect_scripts">';
foreach( $wp_styles->queue as $handle ) :
echo 'console.log("' . $handle . '");';
endforeach;
echo '</script>';
}
add_action( 'wp_print_scripts', 'ac_inspect_scripts' );
@ambercouch
ambercouch / fix-missing-command-prompt.txt
Created Apr 4, 2018
Fix Vagrant ssh missing command prompt
View fix-missing-command-prompt.txt
#Run this in terminal before starting vagrant ssh
export VAGRANT_PREFER_SYSTEM_BIN=1
@ambercouch
ambercouch / Vagrantfile
Created Apr 2, 2018
Fix Scotch Box Authentication Failure
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.25"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
config.vm.provision :shell, path: "phpmyadmin.sh"
@ambercouch
ambercouch / ac_bc.js
Created Mar 21, 2018
Added breadcrumbs from the url path with javascript
View ac_bc.js
function titleCase(str) {
str = str.toLowerCase().split(' ');
for (var i = 0; i < str.length; i++) {
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join(' ');
}
var bcElements = document.querySelectorAll('[data-breadcrumbs]');
var currentPath = window.location.pathname;
@ambercouch
ambercouch / refreshat.js
Last active Mar 21, 2018
Refresh the browser and a specific time (23:00:00)
View refreshat.js
function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if(now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
You can’t perform that action at this time.