Skip to content

Instantly share code, notes, and snippets.

View craigpearson's full-sized avatar

Craig Pearson craigpearson

View GitHub Profile
@craigpearson
craigpearson / gist:8842141
Created February 6, 2014 11:00
IE8 & IE9 Validate in conjunction with placeholder fix
(function($) {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
@craigpearson
craigpearson / gist:8860034
Created February 7, 2014 10:00
Roots nice search redirect - fix
function roots_nice_search_redirect() {
$valued = $_GET["post_type"];
if(!empty($valued)) { $valued = "?post_type=".$valued; };
if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) {
wp_redirect(home_url('/search/'.str_replace(array(' ','%20'),array('+', '+'),urlencode(get_query_var('s'))).$valued), 301);
exit();
}
}
.gform_wrapper ul {
@extend .list-unstyled;
}
.gform_wrapper li {
@extend .form-group;
}
.gform_wrapper form {
margin-bottom: 0;
@craigpearson
craigpearson / 0_reuse_code.js
Created September 15, 2016 23:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@craigpearson
craigpearson / gravityforms.scss
Last active September 20, 2017 23:39 — forked from JodiWarren/gravityforms.scss
Style Gravity Forms with Bootstrap 3 (SASS) - `From`: http://roots.io/style-gravity-forms-with-bootstrap/
.gform_wrapper ul {
@extend .list-unstyled;
}
.gform_wrapper li {
@extend .form-group;
}
.gform_wrapper form {
margin-bottom: 0;
}
.gform_wrapper .gfield_required {
@craigpearson
craigpearson / acf-filters.php
Last active September 20, 2017 23:43
Update ACF JSON load / save path in Sage 9 starter theme. Drop into app/filters.php or include from functions.php
/**
* Update save location for ACF JSON
*/
add_filter('acf/settings/save_json', function ( $path ) {
// Add path - Note uses get_template_directory to override any child theme JSON
$path = get_template_directory() . '/assets/acf-json';
// Create the directory in themes that don't exist
if (!is_dir($path)) {
<?php
namespace App;
add_action('after_setup_theme', function() {
$sage = sage('blade')->compiler();
/**
* Create @asset() Blade directive
*/
@craigpearson
craigpearson / Markdown Code Blocks
Created February 5, 2019 23:50
Markdown Code Blocks
actionscript3
apache
applescript
asp
brainfuck
c
cfm
clojure
cmake
coffee-script, coffeescript, coffee
@craigpearson
craigpearson / git-cheatsheet.MD
Created February 6, 2019 00:41
Git Cheatsheet

Git Cheatsheet

Cloning a repo

# Clone repo to current folder
git clone https://github.com/USERNAME/REPOSITORY.git

# Clone repo to specified folder
git clone https://github.com/USERNAME/REPOSITORY.git specified-folder
@craigpearson
craigpearson / ansible-vagrant-arguments-tags.MD
Created February 18, 2019 22:59
Passing arguments to vagrant provision with Ansible such as --tags

Option 1

Modify your Vagrantfile to pass ANSIBLE_ARGS

config.vm.provision "ansible" do |ansible|
   ansible.playbook = "dev.yml"
   # Etc
   ansible.raw_arguments = Shellwords.shellsplit(ENV['ANSIBLE_ARGS']) if ENV['ANSIBLE_ARGS']
end