Skip to content

Instantly share code, notes, and snippets.

View rayrutjes's full-sized avatar
🎸

Raymond Rutjes rayrutjes

🎸
View GitHub Profile
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
@rayrutjes
rayrutjes / Dockerfile
Created August 9, 2015 11:52
Official php dockerfile with xdebug
FROM php:5.6-fpm
RUN curl -L -o /tmp/xdebug-2.3.3.tgz http://xdebug.org/files/xdebug-2.3.3.tgz \
&& tar xfz /tmp/xdebug-2.3.3.tgz \
&& rm -r /tmp/xdebug-2.3.3.tgz \
&& mv xdebug-2.3.3 /usr/src/php/ext/xdebug \
&& docker-php-ext-install xdebug
CMD ["php-fpm"]
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@rayrutjes
rayrutjes / instantsearch.helpers.relevantContent.js
Last active July 5, 2016 13:45
Show relevant attribute instantsearch.js helper
search.templatesConfig.helpers.relevantContent = function() {
var attributes = ['content', 'title6', 'title5', 'title4', 'title3', 'title2', 'title1'];
var attribute_name;
for ( var index in attributes ) {
attribute_name = attributes[ index ];
if ( this._highlightResult[ attribute_name ].matchedWords.length > 0 ) {
return this._snippetResult[ attribute_name ].value;
}
}
@rayrutjes
rayrutjes / Page_Templates.php
Created July 7, 2016 13:20
WordPress page template from plugin
<?php
class Algolia_Page_Templates
{
/**
* The array of templates that this plugin tracks.
*/
protected $templates;
/**
@rayrutjes
rayrutjes / wordpress-curl-timeout-milliseconds.php
Created July 11, 2016 12:17
Support curl timeout in milliseconds in WordPress.
<?php
function adjust_curl_timeout( $handle, $r, $url ) {
if ( ! isset( $r['timeout'] ) ) {
return;
}
$timeout = $r['timeout'];
if( ! is_float( $timeout ) ) {
return;
@rayrutjes
rayrutjes / algolia-wp-search-on-tags.php
Created July 26, 2016 16:09
Include post tags in the searching - Algolia Search for Wordpress
<?php
function custom_posts_index_settings( array $settings ) {
$settings['attributesToIndex'][] = 'unordered(taxonomy_post_tag)';
return $settings;
}
add_filter( 'algolia_posts_index_settings', 'custom_posts_index_settings' );
@rayrutjes
rayrutjes / algolia-number-synonyms.js
Created July 28, 2016 10:12
Generate number synonyms for Algolia. Run `node` algolia-number-synonyms.js
// @see number to string, pluginized from http://stackoverflow.com/questions/5529934/javascript-numbers-to-words
// @see http://stackoverflow.com/questions/20425771/how-to-replace-1-with-first-2-with-second-3-with-third-etc
const convert = function (num) {
return num2str.convert(num);
}
const num2str = {}
num2str.ones=['','one','two','three','four','five','six','seven','eight','nine'];
num2str.tens=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'];
@rayrutjes
rayrutjes / algolia-support.js
Created August 19, 2016 12:13
Quick script to test calls to Algolia indices.
#!/usr/bin/env node
var algoliasearch = require('algoliasearch');
const APP_ID = 'whatever';
const API_KEY = 'whatever';
const INDEX_NAME = "test";
var client = algoliasearch(APP_ID, API_KEY);
var index = client.initIndex(INDEX_NAME);
@rayrutjes
rayrutjes / wordpress-svn-git-sync.md
Last active September 27, 2016 08:33
Some steps to kickstart the svn / git sync for WordPress plugins

Create an empty git branch

$ git checkout --orphan svn

checkout empty svn repository of the plugin

$ svn co https://plugins.svn.wordpress.org/search-by-algolia-instant-relevant-results/ .