Skip to content

Instantly share code, notes, and snippets.

View robwilde's full-sized avatar
🏠
Just keep Coding, keep on Coding...

Robert Wilde robwilde

🏠
Just keep Coding, keep on Coding...
View GitHub Profile
@robwilde
robwilde / Dockerfile
Created June 14, 2019 06:05 — forked from michaelneu/Dockerfile
docker-compose configuration for PHP with NGINX and MySQL, including sendmail, MailDev and phpmyadmin
# see https://github.com/cmaessen/docker-php-sendmail for more information
FROM php:5-fpm
RUN apt-get update && apt-get install -q -y ssmtp mailutils && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install mysql mysqli sysvsem
RUN pecl install xdebug-2.5.5 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@robwilde
robwilde / Dockerfile
Created June 4, 2019 11:19 — forked from md5/Dockerfile
Testing docker-php-ext-install sockets
FROM php
RUN docker-php-ext-install sockets
COPY test.php /
CMD ["php", "/test.php"]
@robwilde
robwilde / postgres-cheatsheet.md
Created June 4, 2019 09:35 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@robwilde
robwilde / example-wp-list-table.php
Created May 25, 2018 13:32 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@robwilde
robwilde / README.md
Created February 7, 2018 00:48 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@robwilde
robwilde / caldera-forms-rest-api-client-usage.js
Created November 12, 2017 10:31 — forked from Shelob9/caldera-forms-rest-api-client-usage.js
Example code for using the Caldera Forms REST API JavaScript client. See: https://calderaforms.com/doc/caldera-forms-rest-api/
/**
* Get form config details
*
* api is instance of CFAPI
*/
var form = api.getForm();
/**
* Get first page of entries
*
<?php
class MyCPTs {
public function __construct() {
add_action( 'init', array ( $this, 'load_cpts'), 0 );
}
/**
@robwilde
robwilde / gist:fa00607c7e341fd46cb2ed1c6d8aabfd
Created April 2, 2017 14:22 — forked from supermethod/gist:913394
Convert a PHP array into XML file using SimpleXML
class ArrayToXML
{
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
* Based on: http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
@robwilde
robwilde / API.md
Created May 24, 2016 03:57 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@robwilde
robwilde / wp-singleton-namespace-example.php
Created October 30, 2015 10:45 — forked from szbl/wp-singleton-namespace-example.php
Quick Singleton class to be included in WordPress plugin (or theme functions.php file) that will create a simple Person post type and shows some methods of encapsulating functionality in a class as a "namespace," as well as applying filters to things, allowing other users to extend your code.
<?php
class Sizeable_Person
{
const POST_TYPE_SLUG = 'szbl-person';
public static $instance;
public static function init()
{
if ( is_null( self::$instance ) )