Skip to content

Instantly share code, notes, and snippets.

View benedict-w's full-sized avatar

Benedict benedict-w

View GitHub Profile
@benedict-w
benedict-w / auto-acf-json-export.php
Last active March 3, 2020 15:29
Auto generated acf-json from Advanced Custom Fields JSON export
/**
* Auto generated acf-json from Advanced Custom Fields JSON export
* How to use:
*
* 1. Export ACF fields to JSON.
* 2. Rename file "acf-export.json".
* 3. Place in theme root.
* 4. Add this script to functions.php, run once. Check scripts are added to acf-json folder (needs write permissions).
* 5. Remove after successful use!
*/
@benedict-w
benedict-w / virtualbox-bootcamp-setup
Last active March 23, 2016 10:27
Run Windows 7 Bootcamp from Virtual Box
# see for info: https://kindlevsmac.wordpress.com/2011/10/14/how-to-run-windows-7-bootcamp-in-virtualbox/
# view available disk partitions
diskutil list
# unmount bootcamp
diskutil unmount /dev/disk0s4
# make bootcamp writeable
sudo chmod 777 /dev/disk0s4
@benedict-w
benedict-w / iso_4217_currency_codes.php
Last active March 14, 2022 07:16
ISO 4217 currency codes as PHP array
<?php
// http://en.wikipedia.org/wiki/ISO_4217
return array(
'AFA' => array('Afghan Afghani', '971'),
'AWG' => array('Aruban Florin', '533'),
'AUD' => array('Australian Dollars', '036'),
'ARS' => array('Argentine Pes', '032'),
'AZN' => array('Azerbaijanian Manat', '944'),
@benedict-w
benedict-w / iso639_languages_en.php
Last active December 16, 2015 05:19
ISO 639 language codes as PHP array
<?php
return array(
'aa' => 'Afar',
'ab' => 'Abkhaz',
'ae' => 'Avestan',
'af' => 'Afrikaans',
'ak' => 'Akan',
'am' => 'Amharic',
'an' => 'Aragonese',
@benedict-w
benedict-w / remove_orphans.sql
Created April 3, 2013 09:20
mysql remove orphans
DELETE FROM `_table_1`
WHERE `_key` NOT IN (SELECT `key` FROM `_table_2`)
@benedict-w
benedict-w / get_rails_server_pid
Last active December 12, 2015 02:49
Get Process ID of Rails Server (port 3000) MacOS
lsof -P | grep ':3000' | awk '{print $2}'
sudo kill -9 [process_id]
@benedict-w
benedict-w / jquery_image_preload.js
Last active February 24, 2020 04:32
Simple jQuery Image Preload Extension
/**
* Simple jQuery Image Preloader Extension
*
* @param images = array source images to preload
* @param callback = optional function to execute when loaded
*/
$.fn.imagePreloader = function (images, callback) {
var deferreds = [];
$.each(images, function(i, src) {
deferreds.push(new $.Deferred(function (dfd) {
@benedict-w
benedict-w / neteven_webservice_examples.php
Created January 23, 2013 11:58
Neteven examples taken from Web Services Technical Guide v1.8_EN 21
<?php
/**
* May 2012 Web Services Technical Guide v1.8_EN 21
*
* Note: information must be encoded with utf8_encode function
*
* Library used: PHP5 SOAP library
* http://php.net/soap
*/
@benedict-w
benedict-w / dynamic_rowspan.php
Created January 18, 2013 17:25
PHP dynamic rowspan for mysql results
<?php
/**
* addRowspan
*
* from an array of assoc mysql results, appends a column 'rowspan' by looking ahead
* for keys with the same value.
*
* @param string $span_key - key to base span on
* @param array $rows - 2d array of rows
*/
@benedict-w
benedict-w / pdo_query_builder.php
Created November 5, 2012 16:00
A basic query builder class that provides wrappers for building PDO CRUD statements.
<?php
/**
* PDO Query Builder
*
* A basic query builder class that provides wrappers for building PDO queries.
*
* @author Ben Wallis
*/
class pdo_query_builder {