Skip to content

Instantly share code, notes, and snippets.

View getdave's full-sized avatar

Dave Smith getdave

View GitHub Profile
@getdave
getdave / gist:9605519
Created March 17, 2014 18:38
Regex search and replace for Compass/Bourbon SASS mixin.
@include border-radius\(([0-9]+px)+\);
@getdave
getdave / Pretty Git changelog between 2 commits
Last active December 24, 2015 21:59
Generate a list of changed files between two git commit SHA's.
git log --name-only --pretty=oneline --full-index SHA1..SHA2 | grep -vE '^[0-9a-f]{40} ' | sort | uniq
@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!'
@getdave
getdave / Rename files with suffix before extension
Last active December 20, 2015 12:39
Rename a bunch of files and append a suffix before the file extension. Particularly useful for anyone using Grunticon's filename-based colour manipulation. https://github.com/filamentgroup/grunticon/issues/57
for f in *.svg; do mv $f `basename $f .svg`.colors-white.svg; done;
@getdave
getdave / gist:4578295
Last active January 30, 2024 06:34
Gravity Forms - custom field validation function for checkboxes. Ensures all checkboxes have been checked.
// Replace 7 with the ID of your form and 13 with the ID of the field you want to force "all required"
// http://www.gravityhelp.com/documentation/page/Gform_field_validation
add_filter("gform_field_validation_7_13", 'validate_tcs', 10, 4);
function validate_tcs($result, $value, $form, $field) {
// Convert the checkbox input name value (returned as part of "field")
// into the "underscored" ID version which is found in the $_POST
foreach ($field['inputs'] as $input) {
$input_post_value = 'input_' . str_replace('.', '_', $input['id']);