Skip to content

Instantly share code, notes, and snippets.

View getdave's full-sized avatar

Dave Smith getdave

View GitHub Profile
@chrisjacob
chrisjacob / index.php
Created July 13, 2011 07:41
Date Of Birth (DOB) Validation - PHP & JS pulled from a project - these snippets have not been tested on their own.
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="/js/jquery.validate.additional.js"></script>
<style>
li.error, label.error, p.error{color:#F00;}
#entryForm ol{list-style-type:none;}
#entryForm label{display:block; margin-top:6px;}
#entryForm label.error{margin-top:0px;}
</style>
@cballou
cballou / wordpress-multi-env-configphp-setup.php
Created August 15, 2011 13:54
Wordpress Multi-Environment wp-config.php Setup
<?php
/**
* This code is intended to be added to your wp-config.php file just below the top comment block.
* It should replace the existing define('DB_*') statements. You can add or remove sections
* depending on the number of environments you intend to setup. You should change all values of
* DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST for each environment, making them all distinct
* for security purposes.
*/
// determine the current environment
@mikejolley
mikejolley / gist:2044101
Last active October 28, 2024 06:14
WooCommerce - Show number of items in cart and total
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@necolas
necolas / _mixin-better.scss
Created April 13, 2012 15:52
Sass grid construction
// Still need to work out how to combine rules for numbers
// that share a greatest common factor without the unit-builder
// actually containing the fraction to which they can both be
// reduced.
// Calculate the greatest common factor of two integers
@function gcf($a, $b) {
@if $b == 0 {
@return $a;
}
@wpscholar
wpscholar / functions.php
Last active October 20, 2024 14:01
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@hubgit
hubgit / app.js
Last active December 16, 2015 21:39
Postcode -> Location lookup using Ordnance Survey Linked Data APIs
$(function() {
var form = $("form");
var button = form.find("button[type=submit]");
var input = form.find("input[name=postcode]");
var output = form.find("output[name=location]");
var map = L.mapbox.map("map", "hubbox.map-u557d78b").setView([54, 0], 6);
var failed = function(data) {
button.html("Failed");
@justintadlock
justintadlock / register-post-type.php
Last active October 20, 2024 13:47
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@getdave
getdave / pre-commit.sh
Created September 25, 2013 16:15
Git Pre-Commit hook bash script to stop people committing directly to the master branch. Typically useful in a GitFlow based workflow. Installation would be as simple as ```` ln -s ../../pre-commit.sh .git/hooks/pre-commit ````
git branch | grep "* master" && echo 'COMMIT REJECTED - you are not allowed to commit directly to the master branch you fool!'
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active November 11, 2024 22:46
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@corradomatt
corradomatt / SSL and WooCommerce Exclude for Migrate DB Pro
Last active November 23, 2020 18:39
The settings for Migrate-DB-Pro plugin to exclude Better WordPress Security, WooCommerce SSL and WooCommerce Plugin Activation settings when pushing or pulling your database. This code DOES NOT work as a stand-alone gist. You will need to utilize it within this code - https://github.com/deliciousbrains/wp-migrate-db-pro-tweaks/
/**
* Exclude certain WordPress database settings from being migrated when pushing or pulling
* with Migrate-DB-Pro
*
* Useful when developing locally and wanting to push or pull database settings between envirnments
* USE CAUTION! - Must be used with https://github.com/deliciousbrains/wp-migrate-db-pro-tweaks/
*/
function preserved_options( $options ) {
$options[] = 'blog_public'; // discourage search engines setting
$options[] = 'bit51_bwps'; // Better WordPress Security Settings