Skip to content

Instantly share code, notes, and snippets.

View martijngastkemper's full-sized avatar

Martijn Gastkemper martijngastkemper

View GitHub Profile
@martijngastkemper
martijngastkemper / update-wordpress.sh
Last active August 29, 2015 13:56
Update WordPress submodule to new version (tag).
cd folder-containing-wordpress
git fetch --tags
git checkout x.y.x
cd ../
git add folder-containing-wordpress
git commit -m "Upgrade WordPress to x.y.z"
git push
# To fetch a submodule when you changed the version locally, git pull isn't enough
cd folder-containing-wordpress
@martijngastkemper
martijngastkemper / postMash.js
Last active August 29, 2015 13:56
Fixes WordPress plugin "PostMash Custom" when WordPress is installed in "different-dir"
new Ajax('../wp-content/plugins/postmash-custom/saveList.php', {
new Ajax('/wp-content/plugins/postmash-custom/saveList.php', {
@martijngastkemper
martijngastkemper / dumpdatabase.bash
Last active August 29, 2015 13:57
Dump MySQL database and remove definer. Definer must be an existing user. So when moving a database to another server the trigger can fail when the definer doesn't exists.
mysqldump database-name | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > output.sql
@martijngastkemper
martijngastkemper / wp-tell-a-friend-popup-form.php
Last active August 29, 2015 13:58
Make the [Tell a friend] (http://www.gopiplus.com/work/2012/05/21/wordpress-plugin-wp-tell-a-friend-popup-form) plugin for WordPress work with an changed WordPress source directory. Useful for WordPress in Git repositories
# Not working
wp_enqueue_style( 'tell-a-friend', get_option('siteurl').'/wp-content/plugins/wp-tell-a-friend-popup-form/tell-a-friend.css');
wp_enqueue_script( 'tell-a-friend-form', get_option('siteurl').'/wp-content/plugins/wp-tell-a-friend-popup-form/tell-a-friend-form.js');
wp_enqueue_script( 'tell-a-friend-popup', get_option('siteurl').'/wp-content/plugins/wp-tell-a-friend-popup-form/tell-a-friend-popup.js');
# Working
wp_enqueue_style( 'tell-a-friend', plugins_url( 'tell-a-friend.css', __FILE__ ) );
wp_enqueue_script( 'tell-a-friend-form', plugins_url( 'tell-a-friend-form.js', __FILE__ ) );
wp_enqueue_script( 'tell-a-friend-popup', plugins_url( 'tell-a-friend-popup.js', __FILE__ ) );
@martijngastkemper
martijngastkemper / ajax.php
Last active August 29, 2015 13:58
Fixes WordPress plugin "File Un-Attach" when WordPress is installed in "different-dir"
# Change
require_once '../../../wp-load.php';
# into
require_once '../../../different-dir/wp-load.php';
@martijngastkemper
martijngastkemper / dump-triggers
Created April 22, 2014 08:51
Dump MySQL triggers
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql
@martijngastkemper
martijngastkemper / zabbix.php
Last active August 29, 2015 14:01
Zabbix API uitproberen
<?php
// load ZabbixApi (http://zabbixapi.confirm.ch/)
require 'ZabbixApiAbstract.class.php';
require 'ZabbixApi.class.php';
try {
// connect to Zabbix API
$api = new ZabbixApi("...");
@martijngastkemper
martijngastkemper / search-version.bash
Created May 30, 2014 10:47
Search a file by version
#!/bin/bash
fromVersion=$1
if [ -d .sql-update ]
then
start=false
for sqlFile in `ls -v .sql-update/*`
do
if [[ $sqlFile == *$fromVersion* ]]
@martijngastkemper
martijngastkemper / EnvStream.php
Last active August 29, 2015 14:02
I was searching for a solution to make key files available in my Heroku app without adding it to the repository. Using a streamwrapper doesn't work, because ssh2 only accepts strings to files without a schema part. But still want to share this very useless class with you. "echo file_get_contents( 'env://ENV_VAR' );" does exactly the same as "get…
<?php
class EnvStream
{
private $var, $position = 0;
function stream_open($path, $mode, $options, &$opened_path)
{
$this->var = parse_url( $path, PHP_URL_HOST );
return true;
@martijngastkemper
martijngastkemper / .bashrc
Created July 3, 2014 22:49
Solves a runtime exception when executing shell command via PHP exec().
# .bashrc
[ -z "$PS1" ] && return