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 / 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 / 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 / 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 / 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 / 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]})/..
@gggeek
gggeek / check.sql
Created April 24, 2020 22:50
ezplatform data integrity: check any file in the ezimagefile table which is not listed in the xml text of ezcontentobject_attribute of type ezimage
select i.contentobject_attribute_id, group_concat(i.filepath)
from ezimagefile i
left join (
select
id,
concat(
'|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@filename'), '&amp;', '&'),
'|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&amp;', '&'), '_',
replace(
-- list of aliases, space separated
@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
{
@gggeek
gggeek / PersistenceCachePurger.php
Created January 12, 2018 17:57
Fix for ezp-28736
<?php
namespace MyCustomer\VendorOverrideBundle\Cache;
use eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger as BasePersistenceCachePurger;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType;
use eZ\Publish\SPI\Persistence\Content\Location;
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
class PersistenceCachePurger extends BasePersistenceCachePurger
@gggeek
gggeek / dumpdb.sh
Created July 22, 2016 15:35
managing ezpublish db and storage for sharing between devs
#!/usr/bin/env bash
# Command to dump the dev db + storage
# We try to clean up both the db and the storage as much as possible when dumping
#
# @todo allow user to specify target files
function help {
echo 'Usage: dumpdb.sh [-f] [env]'
echo 'Options:'
class WebDriver extends AbstractWebDriver
{
protected $proxy = '';
public function setProxy($proxy)
{
$this->proxy = $proxy;
}
/**