Skip to content

Instantly share code, notes, and snippets.

View GuyPaddock's full-sized avatar

Guy Elsmore-Paddock GuyPaddock

View GitHub Profile
@GuyPaddock
GuyPaddock / filter.sh
Created November 6, 2018 16:51
2017-10-19 - Eliminate Zero-width Spaces (\u200b) from PHP Source Files
#!/bin/env bash
for f in $(find . -name '*.php'); do
directory=$(dirname "${f}");
mkdir -p "../processed/${directory}";
cat "${f}" | tr "$(printf %b '\u200b')" " " > "../processed/${f}";
done
@GuyPaddock
GuyPaddock / render.sh
Created November 6, 2018 16:52
2017-10-19 - Render PHP Files to HTML in Bulk through CLI
#!/bin/env bash
for f in $(find . -maxdepth 1 -name '*.php'); do
directory=$(dirname "${f}");
basename=${f%.*}
mkdir -p "../rendered/${directory}";
php -f "${f}" > "../rendered/${basename}.html";
done
@GuyPaddock
GuyPaddock / HOWTO.md
Created November 16, 2018 20:43
WIP: Installing FileMaker Server 17 on Windows Server Essentials 2016

Two services conflict with FileMaker Server 17 on ports 80 and 443:

  • IIS Web Site for Windows Server Essentials Connect (i.e. http://YOURSERVER/connect and https://YOURSERVER/remote) is bound on *:80 and *:443.
  • BranchCache (part of Windows Server) is bound on *:80 (and somehow is able to share that port with IIS).

Need to:

  • Move Windows Server Essentials to a different set of ports (temporarily), via IIS Admin Console.
  • Stop BranchCache (temporarily)

The goal is to trick the FileMaker Server installer into proceeding with install, so we can then tweak the IIS config AFTER install.

@GuyPaddock
GuyPaddock / backup.sh
Last active December 11, 2018 19:18
Crude HP Touchpad WebOS Backup Script (run with `nohup` for best results over SSH; errors appear in errors.log)
#!/usr/bin/env sh
cd /media/cryptofs
tar -cvpjf webos-backup.tbz2 \
--exclude=/proc \
--exclude=/media/internal \
--exclude=/tmp \
--exclude=/dev \
--exclude=/sys \
--exclude=/var/run \
--exclude=/media/cryptofs/webos-backup.tbz2 \
@GuyPaddock
GuyPaddock / split_zip.sh
Last active March 18, 2019 15:22
Split a ZIP archive for Drupal Feeds Fetcher Archive + CSV into separate archives < 100 MB each (needed for Pantheon)
#!/usr/bin/env bash
##
# @file
# Asset Zip Splitter
#
# Splits a ZIP archive containing the following file structure into separate
# archives that contain no more than 100 MB each:
# - *.csv (CSV files that reference image files)
# - images/ (a folder of images referenced by the image files)
@GuyPaddock
GuyPaddock / print-time-and-checksum.sh
Created May 3, 2019 01:59
Calculate checksum over kubectl bash without timing out
#!/usr/bin/env bash
(while true; do date; sleep 1; done) &
sha1sum * | tee checksums.txt
@GuyPaddock
GuyPaddock / array_contains.sh
Created July 2, 2019 03:38
Check if a value is in an array in Bash
##
# Determine if a given element exists in an array.
#
# Based on:
# https://stackoverflow.com/a/11525897/4342230
#
# @param string $1
# The value to look for (the "needle").
# @param string... $2...
# The array of values to search (the "haystack").
@GuyPaddock
GuyPaddock / resurrect.php
Last active September 18, 2019 14:45
Resurrecting an Unsaved Drupal 8 Node from the Database using Devel
<?php
// NOTE: Node previews expire after 7 days. Be sure to use this method to extract the desired data before then.
// IMPORTANT: Set this to the user ID of the person who was creating/lost the node.
$user_id = 1;
// IMPORTANT: Set this to the UUID that appeared in the node preview URL.
// This value is from a URL that looked like this:
// https://my-site/node/preview/ed4eaac0-3c32-427e-860f-6ce8fc79c3b2/full
$preview_id = 'ed4eaac0-3c32-427e-860f-6ce8fc79c3b2';
@GuyPaddock
GuyPaddock / results.txt
Last active December 18, 2019 14:55
How Static Variables Work with Inheritance in PHP
On PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ):
ClassA = 1576680836
ClassA = 1576680836
ClassA = 1576680838
ClassA = 1576680838
ClassA = 1576680840
ClassA = 1576680840
ClassX = 1576680842
@GuyPaddock
GuyPaddock / results.txt
Last active December 18, 2019 14:57
How array_reduce() and array_map() Behave with Associative Arrays in PHP
On PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ):
Array
(
[a] => ABC: 1
[b] => ABC: 2
)
,1,2