Skip to content

Instantly share code, notes, and snippets.

View doekenorg's full-sized avatar

Doeke Norg doekenorg

View GitHub Profile
@doekenorg
doekenorg / is_initialized_helper.php
Last active August 1, 2021 13:30
Helper function for `is_initialized()`
<?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 August 18, 2020 07:33
Worksheet hook example
<?php
class Worksheet {
/**
* Holds the worksheet title.
* @var string
*/
private $title;
// Registers the filter hooks.

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 February 7, 2019 16:00
Make Gravity Perks Nested Forms work with Entries in Excel
<?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 August 29, 2015 14:03
Sort array of sizes relative to amount of X's (XXS, S, M, L, XL, etc)
<?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 November 21, 2013 09:22
Little bashscript that find replaces every ip in a series of named-files.
#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