Skip to content

Instantly share code, notes, and snippets.

View pdewouters's full-sized avatar
🌄
Working from home

Paul de Wouters pdewouters

🌄
Working from home
View GitHub Profile
@pdewouters
pdewouters / gist:6549885
Created September 13, 2013 12:13
This example sets up a custom Exception handler, uses try...catch blocks and passes in a valid array to the object constructor. Does not generate any errors.
<?php
/**
* Custom Error Handler for E_RECOVERABLE_ERROR
*
* http://stackoverflow.com/a/2468534/285564
*
* @param $errno
* @param $errstr
* @param $errfile
@pdewouters
pdewouters / gist:6540219
Last active December 22, 2015 22:29
Notify user of Vagrant status
alias vh='vagrant halt; terminal-notifier -sound default -title "Vagrant Status" -message "Vagrant shutdown successfully" &'
alias vu='vagrant up; terminal-notifier -sound default -title "Vagrant Status" -message "Vagrant is ready!" &'
alias vr='vagrant reload'
@pdewouters
pdewouters / functions.php
Created August 24, 2013 14:19
metabox definition
function cmb_list_metaboxes( array $meta_boxes ) {
$fields = array(
array(
'id' => 'description',
'name' => 'Description',
'type' => 'text'
),
array(
'id' => 'completed',
@pdewouters
pdewouters / groceries-api.php
Created August 23, 2013 11:56
new item creation
case 'POST':
// new item
$data = json_decode( file_get_contents( "php://input" ), true );
$list_item = $data['description'];
$post_meta = get_post_meta( 7, 'list-item' );
add_post_meta(7,'list-item', $list_item );
@pdewouters
pdewouters / gist:6310419
Created August 22, 2013 17:41
zshrc config
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
DEFAULT_USER="pauldewouters"
@pdewouters
pdewouters / gist:6205099
Created August 11, 2013 14:22
first pass at gruntfile with sass compile and livereload
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.js'],
@pdewouters
pdewouters / new_gist_file
Created June 21, 2013 15:00
whitelist gitignore
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@pdewouters
pdewouters / content-form.php
Created June 20, 2013 19:40
wrongly calling the GF form
$form = get_sub_field( 'select_form' );
gravity_form_enqueue_scripts( $form->id, true );
gravity_form( $form->id, false, true, false, '', true, 1 );
@pdewouters
pdewouters / class-loggly-import-tweets.php
Created June 18, 2013 19:30
Sort Tweets by created date
uasort( $this->tweets, function( $a, $b ){
if ( strtotime($a->created_at) == strtotime($b->created_at) ) {
return 0;
}
return ( strtotime($a->created_at) < strtotime($b->created_at) ) ? -1 : 1;
});
@pdewouters
pdewouters / gist:5682211
Created May 31, 2013 00:10
load more posts script
jQuery(document).ready(function($) {
// The number of the next page to load (/page/x/).
var pageNum = parseInt(ssm_alp.startPage) + 1;
// The maximum number of pages the current query can return.
var max = parseInt(ssm_alp.maxPages);
// The link of the next page of posts.
var nextLink = ssm_alp.nextLink;