Skip to content

Instantly share code, notes, and snippets.

@ajbonner
ajbonner / Fix-GH-10218-DateTimeZone-Parse-ETC-php82.patch
Created January 17, 2023 11:47
Fix PHP GH Issue 10218 < PHP 8.2.1 DateTimeZone cannot parse + abbreviation in Timezones
diff -ruN php-8.2.1/ext/date/lib/parse_date.c php-8.2.1-gh10218/ext/date/lib/parse_date.c
--- php-8.2.1/ext/date/lib/parse_date.c 2023-01-03 13:40:55.000000000 -0500
+++ php-8.2.1-gh10218/ext/date/lib/parse_date.c 2023-01-17 06:37:01.121532677 -0500
@@ -787,7 +787,7 @@
(**ptr >= 'A' && **ptr <= 'Z') ||
(**ptr >= 'a' && **ptr <= 'z') ||
(**ptr >= '0' && **ptr <= '9') ||
- **ptr == '/' || **ptr == '_' || **ptr == '-'
+ **ptr == '/' || **ptr == '_' || **ptr == '-' || **ptr == '+'
) {
@ajbonner
ajbonner / php-fpm-fcgi-status.sh
Last active August 2, 2017 14:54
PHP-FPM Status from CLI
sudo -u www-data \
SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
REQUEST_METHOD=GET \
QUERY_STRING=full \
cgi-fcgi -bind -connect /var/run/php/php7.0-fpm.sock
@ajbonner
ajbonner / rename_tags.sh
Last active August 7, 2017 19:43
Rename old git tags and copy annotations
#!/bin/bash
for tag in $(git tag | grep '^2017'); do
git tag -a $(echo $tag | sed 's/^2017/17/') $tag -m "$(git tag -n $tag | sed -E 's/2017\.[0-9]{2}\.[0-9]{2}\.[0-9]{2}\s*//')"
git tag -d $tag
git push origin :refs/tags/$tag
done
@ajbonner
ajbonner / strace-fpm.sh
Created April 11, 2017 14:13
Strace all running php-fpm processes to file with timestamps and pid
sudo strace -f -tt -o /tmp/php.trace -s1024 -p `pgrep -f php-fpm | tr '\n' ','`
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@ajbonner
ajbonner / ImageController.php
Last active July 8, 2016 18:46
Fix tiresome headers already sent bug in Magento 1.x
<?php
/**
* Generate image thumbnail on the fly
*/
public function thumbnailAction()
{
$file = $this->getRequest()->getParam('file');
$file = Mage::helper('cms/wysiwyg_images')->idDecode($file);
$thumb = $this->getStorage()->resizeOnTheFly($file);
if ($thumb !== false) {
@ajbonner
ajbonner / event_dispatch_check.php
Last active February 5, 2016 19:52
Quick and dirty way to test if an observer responds to a given event in Magento 1 using MageTest
<?php
class SomeTestTest extends MageTest_PHPUnit_Framework_TestCase
{
/**
* @param string $observerName e.g. mymodulens_mymodule_does_something_on_order_place
* @param string $eventName e.g. a dispatched event e.g. sales_order_place_after
* @param string $area e.g. global/frontend/admin/adminhtml
*/
public function assertObserverReceivesEvent($observerName, $eventName, $area)
@ajbonner
ajbonner / gist:e5eb20d253c2695912fa
Created July 8, 2015 17:38
Mac OSX Vagrant /etc/export for NFS
"/Users/aaron/Sites" 192.168.200.100 -alldirs -mapall=501:20
@ajbonner
ajbonner / filter_rename
Last active August 29, 2015 14:00
Mass Rename Files in a Dir Using Sed Expression
#!/usr/bin/env bash
find . -name '*.gz' -print | while read SRC_FILE; do
DEST_FILE=$(echo $SRC_FILE | sed 's/_2014.*.sql.gz/.sql.gz/')
mv $SRC_FILE $DEST_FILE
done
@ajbonner
ajbonner / enable_core_dumps.sh
Created April 11, 2014 21:04
Enable Core Dumps
#!/usr/bin/env bash
echo '/tmp/core-%e.%p' > /proc/sys/kernel/core_pattern
echo 0 > /proc/sys/kernel/core_uses_pid
ulimit -c unlimited