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"]
{
"name": "npm-task-runner-example",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"clean": "rimraf dist && mkdirp dist/css",
"prebuild": "npm run clean",
"build:js": "node tasks/build/js.js",
"watch:js": "watch 'npm run build:js' assets/js",
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@rayrutjes
rayrutjes / detectcontenttype.go
Created December 12, 2015 13:36
golang detect content type of a file
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
if err != nil {
@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 / ais-wp.css
Created July 7, 2016 12:48
Some boilerplate to create an instantsearch.js search experience in your WordPress theme. This works in combination with the Algolia Search plugin for WordPress.
#ais-wrapper {
display: flex;
}
#ais-main {
padding: 1rem;
width: 100%;
}
@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-wordpress-exclude-home-page.php
Last active July 20, 2018 12:31
Exclude home page WordPress Algolia plugin
<?php
// functions.php
define( 'CUSTOM_HOME_ID', 2 );
function custom_should_index_post( $flag, WP_Post $post ) {
if ( $post->post_type === 'page' && $post->ID === CUSTOM_HOME_ID ) {
return false;
}