Skip to content

Instantly share code, notes, and snippets.

View pelmered's full-sized avatar
🎯
Focusing

Peter Elmered pelmered

🎯
Focusing
View GitHub Profile
@pelmered
pelmered / party.sh
Created September 19, 2014 12:09
Best shell script ever
#!/bin/bash
while :
do
eject
eject -t
done
#!/bin/sh
echo "committing as $(git config user.name) ($(git config user.email))",
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
#STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep "app/.*\.php"`
PROJECT_PATH=`php -r "echo dirname(dirname(realpath('$0')));"`
VENDOR_BIN_DIR="${PROJECT_PATH}/vendor/bin/";
@pelmered
pelmered / BaseEnum.php
Last active June 16, 2020 12:22
Enum classes
<?php
namespace App\Enums;
use App\Rules\IsValidEnum;
use Illuminate\Support\Str;
abstract class BaseEnum
{
protected $name;
protected $values = array();
<?php
function incrementDeep(&$array, $value) {
$array += $value;
}
$test['foo']['bar']['test'] = 5;
incrementDeep($test['foo']['bar']['test'], 5);
incrementDeep($test['foo']['bar']['test2'], 5);
@pelmered
pelmered / gist:e5633068658e75ba9a80
Last active October 13, 2021 14:55
Cleanup orphaned ACF data
# This might ruin your database and I do not take any responsibility for that. Backup your database before continuing
!
# Check the results throughly
SELECT * FROM `wp_postmeta`
WHERE `meta_key` IN
( SELECT TRIM(LEADING '_' FROM `meta_key`) AS mk
FROM `wp_postmeta`
WHERE `meta_value` regexp '^field_[0-9a-f]+'
AND `meta_value` NOT IN