Skip to content

Instantly share code, notes, and snippets.

🤗
Typing stuff on a keyboard!

Raymond Rutjes rayrutjes

🤗
Typing stuff on a keyboard!
Block or report user

Report or block rayrutjes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rayrutjes
rayrutjes / fix-broken-php-serialized-data.php
Created Jun 9, 2019
Helper to fix broken PHP serialized data. Helpful mostly on broken WordPress databases.
View fix-broken-php-serialized-data.php
<?php
$data = <<< EOF
The broken serialized data goes here.
And can expand on multiple lines.
EOF;
$data = preg_replace_callback ('!s:(\d+):"(.*?)";!', function($match) {
return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
}, $data);
@rayrutjes
rayrutjes / remove-html-tags-wordpress-algolia-plugin.php
Created Nov 20, 2018
Remove HTML tags from title - Algolia WordPress plugin
View remove-html-tags-wordpress-algolia-plugin.php
<?php
function remote_html_tags( array $shared_attributes, WP_Post $post) {
$shared_attributes['post_title'] = strip_tags( $shared_attributes['post_title'] );
return $shared_attributes;
}
add_filter( 'algolia_post_shared_attributes', 'remote_html_tags', 10, 2 );
@rayrutjes
rayrutjes / autocomplete-show-more-link-footer-dynamic.js
Created Sep 13, 2018
Dynamic show more results like algolia autocomplete
View autocomplete-show-more-link-footer-dynamic.js
@rayrutjes
rayrutjes / hide-autocomplete.php
Created Jul 23, 2018
Hide autocomplete snippet on custom condition - WordPress - Algolia
View hide-autocomplete.php
<?php
add_filter( 'algolia_autocomplete_config', function ( $config ) {
if (true) { // Replace this condition to match your needs.
// Autocomplete enabled.
return $config
}
@rayrutjes
rayrutjes / evicted-pods-cleanup.sh
Created Jul 19, 2018
Cleanup evicted pods - Kubernetes
View evicted-pods-cleanup.sh
kubectl get pod -a --all-namespaces -o json \
| jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pod \(.metadata.name) -n \(.metadata.namespace)"' \
| xargs -n 1 bash -c
@rayrutjes
rayrutjes / list-big-files.sh
Created Apr 24, 2018
List big files on your Mac
View list-big-files.sh
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
@rayrutjes
rayrutjes / hide-instantsearch.php
Created Mar 12, 2018
Programatically hide instantsearch in Algolia plugin for WordPress
View hide-instantsearch.php
<?php
add_filter( 'algolia_should_override_search_with_instantsearch', function() {
return false;
} );
@rayrutjes
rayrutjes / replace-domain-wordpress-algolia-plugin.php
Created Feb 26, 2018
Replace domain in Algolia Search plugin for WordPress
View replace-domain-wordpress-algolia-plugin.php
<?php
/**
* @version 0.1.0
* Plugin Name: Replace domain in Algolia Search plugin for WordPress
*/
function custom_post_shared_attributes( array $shared_attributes ) {
$shared_attributes['permalink'] = str_replace( 'admin.rushlimbaugh.com', 'www.rushlimbaugh.com', $shared_attributes['permalink'] );
return $shared_attributes;
}
@rayrutjes
rayrutjes / algolia-woocommerce-instantsearch.php
Created Jan 31, 2018
Display WooCommerce InstantSearch on home page Algolia
View algolia-woocommerce-instantsearch.php
<?php
// Inject instantsearch.js on every page regardless of backend config.
add_filter( 'algolia_wc_should_display_instantsearch', '__return_true' );
// This will make sure the search is displayed on load. Oterwise it waits for the query to change to be displayed.
add_filter( 'algolia_config', function( array $config ) {
$config['woocommerce']['replace_page'] = true;
@rayrutjes
rayrutjes / algolia-woocommerce-filter-facets.php
Last active Feb 14, 2018
Filter displayed facets in Algolia plugin for WooCommerce
View algolia-woocommerce-filter-facets.php
<?php
add_filter( 'algolia_wc_attributes_for_faceting', function( $attributes ) {
$only_ids = array(
15, // Main Style
13, // Main Color
49, // Sizes
23, // Brand
4, // Collection
22, // Material
You can’t perform that action at this time.