Skip to content

Instantly share code, notes, and snippets.

@doekenorg
doekenorg / is_initialized_helper.php
Last active Aug 1, 2021
Helper function for `is_initialized()`
View is_initialized_helper.php
<?php
if (!function_exists('is_initialized')) {
/**
* Returns whether a property is initialized with a value.
* @param string|object $object The class (name), that contains the property.
* @param string $property The name of the property.
* @return bool Whether the property is initialized with a value.
*/
function is_initialized($object, string $property): bool {
@doekenorg
doekenorg / Worksheet.php
Created Aug 18, 2020
Worksheet hook example
View Worksheet.php
<?php
class Worksheet {
/**
* Holds the worksheet title.
* @var string
*/
private $title;
// Registers the filter hooks.
View keybase.md

Keybase proof

I hereby claim:

  • I am doekenorg on github.
  • I am doekenorg (https://keybase.io/doekenorg) on keybase.
  • I have a public key ASDUAUlkb_h8z6LUdqVZueohavoSm-hyAEuEbzprLa0H_wo

To claim this, I am signing this object:

@doekenorg
doekenorg / functions.php
Created Feb 7, 2019
Make Gravity Perks Nested Forms work with Entries in Excel
View functions.php
<?php
//functions.php
add_filter('gfexcel_field_value_form', function ($value, $entry, \GF_Field $field) {
$entries = gp_nested_forms()->get_entries($value);
$nested_form = \GFAPI::get_form(rgar($field, 'gpnfForm'));
$entries = array_map(function ($entry) use ($nested_form) {
return \GFCommon::get_submitted_fields($nested_form, $entry, false, false, 'text', false);
@doekenorg
doekenorg / sizeSort.php
Last active Aug 29, 2015
Sort array of sizes relative to amount of X's (XXS, S, M, L, XL, etc)
View sizeSort.php
<?php
$sizes = array("XS", "L", "M", "S", "XXS", "XXL", "XXS", "M", "XXXXXL", "XL");
// Function doesn't handle (X+)M, because that would make no sense at all.
function sizeSort($cmp1, $cmp2)
{
$sort = array("S", "M", "L");
if (preg_match("/(^[X]*)([SML])$/is", $cmp1, $parts_1) && preg_match("/(^[X]*)([SML])$/is", $cmp2, $parts_2)) {
@doekenorg
doekenorg / gist:7578491
Created Nov 21, 2013
Little bashscript that find replaces every ip in a series of named-files.
View gist:7578491
#dnschange.sh
!/bin/sh
for domain in "$@"
do
sed -i 's/ORIGINAL_IP/NEW_IP/g' /var/named/$domain.db
done
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue