Skip to content

Instantly share code, notes, and snippets.

View gggeek's full-sized avatar
💭
Gone fishin'

Gaetano Giunta gggeek

💭
Gone fishin'
View GitHub Profile
@gggeek
gggeek / pre-push.sh
Created December 21, 2022 10:51
Check that version number in code matches the one from the git tag before pushing
#!/bin/bash
# Script to be run as part of the github pre-push hook.
#
# Checks that, if there is a "version-like" tag being pushed, all the files which are supposed to contain the tag do
# actually have the correct tag value in them. If they do not, the push is blocked.
# NB: this does _not_ automatically alter the source files and commit them with the correct tag value, nor prevent the
# tag to be added to the wrong git commit locally (ie. a commit in which the source files have the wrong tag value).
# All it does is prevent the developer from pushing the 'bad tags' to remote repositories, giving him/her the chance to
# manually rectify the situation on the local repo before retrying to push.
@gggeek
gggeek / gist:a836fa51229d31985fe67515d6c3d7e4
Created February 11, 2023 16:14
taskfile ("make-like" but in bash) with better docs generation than the original
# this comment will be in the help text for a_task
function a_task() {
...
}
# prints this help text
function help() {
# @todo allow a tag such as `# @internal` to denote functions as not available for external execution
declare -A DESCRIPTIONS
local CMD MAX LEN
@gggeek
gggeek / test.php
Last active December 12, 2022 12:32
playing around with emulation of array dynamic properties using __get, __set
<?php
class MyClass
{
protected $p = array();
public function &__get($name)
{
echo "Getting: $name\n";
if (!isset($this->p[$name])) {
@gggeek
gggeek / gist:3655027
Last active December 7, 2022 10:42
8. install XHProf
sudo apt-get install graphviz
sudo pecl config-set preferred_state beta
sudo pecl install xhprof
# enable xhprof by creating a config. file for php:
sudo vi /etc/php5/apache2/conf.d/xhprof.ini
#in there put:
extension=xhprof.so
sudo service apache2 restart
$dataManager = $this->getContainer()->get('liip_imagine.data.manager');
$filterManager = $this->getContainer()->get('liip_imagine.filter.manager');
$assetManager = $this->getContainer()->get('eris_fo.assets_manager');
$variationManager = $this->getContainer()->get('eris_fo.assets.variation_generator');
// works using the custom data loader as set in imaginebundle config
$fullSizeImagePath = '/images/content/advertising.png';
$filters = $this->getContainer()->getParameter('assets_image_variations');
$targetAssetsBucket = 'images';
@gggeek
gggeek / client.php
Last active December 7, 2022 10:41
xmlrpc tests
<?php
include('../vendor/autoload.php');
$clnt = new \PhpXmlRpc\Client('https://localhost/var/srv.php');
$clnt->setAcceptedCompression(false);
$clnt->setSSLVerifyPeer(false);
$resp = $clnt->send(new \PhpXmlRpc\Request('yolo'));
@gggeek
gggeek / gist:b01e76694319888a97cdf56cb084662d
Last active December 7, 2022 10:40
A symfony command for eZPublish 5 that lists all available Legacy command-line scripts
<?php
namespace Acme\AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ListLegacyScriptsCommand extends ContainerAwareCommand
{
class WebDriver extends AbstractWebDriver
{
protected $proxy = '';
public function setProxy($proxy)
{
$this->proxy = $proxy;
}
/**
@gggeek
gggeek / ProcessManager.php
Created July 9, 2013 09:59
A simple process-manager in php, which uses forking to run tasks - putting a limit on the number of concurrent processes (aka a queue)
<?php
/**
* A simple process manager, forking jobs to run in parallel. Works on linux and windows.
*
* @copyright G. Giunta
* @license GPL v2
*
* @todo add more methods? f.e. one to kill any the executing processes
*/
@gggeek
gggeek / check-legacy-templates-compiled-today.sh
Created May 13, 2020 08:32
Find out which ez4 templates are actually used in an ez5 site
#!/usr/bin/env bash
# Looks in the legacy cache folder for any compiled legacy templates belonging to a specific design
# Useful to be put in a cronjob
DESIGN=my_site_design
VARDIR=my_site
# names of compiled templates files: ${sourcetpl}-hash.php
EXCLUDEDTEMPLATES=compiled/3-
ROOTDIR=$(dirname ${BASH_SOURCE[0]})/..