Skip to content

Instantly share code, notes, and snippets.

Aaron Bonner ajbonner

Block or report user

Report or block ajbonner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ajbonner
ajbonner / php-fpm-fcgi-status.sh
Last active Aug 2, 2017
PHP-FPM Status from CLI
View php-fpm-fcgi-status.sh
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 Aug 7, 2017
Rename old git tags and copy annotations
View rename_tags.sh
#!/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 Apr 11, 2017
Strace all running php-fpm processes to file with timestamps and pid
View strace-fpm.sh
sudo strace -f -tt -o /tmp/php.trace -s1024 -p `pgrep -f php-fpm | tr '\n' ','`
View homebrew-install-gnu.sh
# 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 Jul 8, 2016
Fix tiresome headers already sent bug in Magento 1.x
View ImageController.php
<?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 Feb 5, 2016
Quick and dirty way to test if an observer responds to a given event in Magento 1 using MageTest
View event_dispatch_check.php
<?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 Jul 8, 2015
Mac OSX Vagrant /etc/export for NFS
View gist:e5eb20d253c2695912fa
"/Users/aaron/Sites" 192.168.200.100 -alldirs -mapall=501:20
@ajbonner
ajbonner / filter_rename
Last active Aug 29, 2015
Mass Rename Files in a Dir Using Sed Expression
View filter_rename
#!/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
View enable_core_dumps.sh
#!/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
@ajbonner
ajbonner / intervention_watermark.php
Created Feb 6, 2014
Intervention Watermarking with Cache
View intervention_watermark.php
<?php
$filestore = new \Illuminate\Cache\FileStore(
new \Illuminate\Filesystem\Filesystem(),
'/some/path/to/somewhere/specific/intervention-cache');
$repository = new \Illuminate\Cache\Repository($filestore);
$cache = new \Intervention\Image\ImageCache($repository);
$watermark = $cache->make($watermarkFile)->get(0, true);
You can’t perform that action at this time.