Skip to content

Instantly share code, notes, and snippets.

View felthy's full-sized avatar

Pete Feltham felthy

View GitHub Profile
@felthy
felthy / custom-search-acf-wordpress.php
Last active April 19, 2021 15:11 — forked from fiskhandlarn/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. Updated to use wpdb prepare() and esc_like().
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
[list_searcheable_acf list all the custom fields we want to include in our search query]
@return [array] [list of custom fields]
@felthy
felthy / javascript-debug-printObject-function.js
Created April 21, 2015 06:27
Recursively dump a javascript object into a string, for when you don't have a debugger
/**
* When investigating a selenium test failure on a remote headless browser that couldn't be reproduced
* locally, I wanted to add some javascript to the site under test that would dump some state to the
* page (so it could be captured by Selenium as a screenshot when the test failed). JSON.stringify()
* didn't work because the object declared a toJSON() method, and JSON.stringify() just calls that
* method if it's present. This was a Moment object, so toJSON() returned a string but I wanted to see
* the internal state of the object instead.
*
* So, this is a rough and ready function that recursively dumps any old javascript object.
*/
@felthy
felthy / routes.php
Created June 4, 2014 00:23
Use laravel-cachebuster in conjunction with Laravel's built-in PHP development web server. A slightly modified version of code by @RTC1
if (App::runningUnitTests() && is_development_server()) {
/**
* CACHE BUSTERS
*/
Route::pattern('hash', '[a-zA-Z0-9]+');
Route::pattern('allowedExtensions', '(jpg|png|gif|js|css|woff|ttf|svg|eot){1}');
Route::pattern('folders', '[a-zA-Z0-9_\/]*');
Route::pattern('fileName', '.+');
$guesser = \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser::getInstance();
@felthy
felthy / README.md
Last active December 15, 2015 15:38
Test to see what happens when you freeze an object's prototype via `Object.freeze`.

This Gist is a test to see what happens when you freeze an object's prototype via Object.freeze.

I created it because, after I upgraded my [NodeJS][1] installation to version 0.10.2 (I previously had v0.8.18), the [Pipette][2] library stopped working with this error:

Fatal error: Cannot assign to read only property 'onClose' of #<State>
TypeError: Cannot assign to read only property 'onClose' of #<State>
    at new State (node_modules/pipette/lib/sink.js:81:16)

The problem is that the library freezes the prototypes of various objects, but the objects want to override some of the