Skip to content

Instantly share code, notes, and snippets.

Enrico Simonetti esimonetti

Block or report user

Report or block esimonetti

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
@esimonetti
esimonetti / with_acl_team_set_id.php
Last active Sep 2, 2019
Find records across all tables with acl_team_set_id not null, and their teams
View with_acl_team_set_id.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-09-02 on Sugar 8.0.0
//
// CLI script to find records with acl_team_set_id
function usage($error = '') {
@esimonetti
esimonetti / sugar-cli-foos.txt
Last active Sep 2, 2019
Useful sugar file system commands to analyse an instance
View sugar-cli-foos.txt
# Quick way to tell the difference of the modules dir of two instances
# 1 - from within the vanilla system module's dir
cd modules
ls -la | awk '{ print $9 }' | grep -v '\.' | grep -v '\.\.' > ~/core_modules_dir.txt
# 2 - from within the customer system module's dir
cd modules
ls -la | awk '{ print $9 }' | grep -v '\.' | grep -v '\.\.' > ~/customer.txt
# 3 - diff the twos and do some foos to get the actual differences
diff -auNw ~/core_modules_dir.txt ~/customer.txt | grep + | grep -v "@" | cut -c 2- | grep -v "\+\+" | grep -v "\-\-"
@esimonetti
esimonetti / .htaccess
Last active Aug 27, 2019
Change sugar upload dir to another disk/mount
View .htaccess
...
...
# file path will depend on the installation path or where the file should be
# if this needs to be executed everywhere (even from cron), consider setting it on php.ini instead of the .htaccess
php_value auto_prepend_file /var/www/html/sugar/prepend.php
@esimonetti
esimonetti / secretHandling.php
Last active May 13, 2019
Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
View secretHandling.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-05-13
// Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
// secret value to encrypt for storage purposes, and to decrypt real-time
@esimonetti
esimonetti / list.php
Created Jan 9, 2019
Add tags to reports on listviews
View list.php
<?php
//
// Enrico Simonetti
// 2019-01-10
//
// file: custom/Extension/modules/Reports/Ext/clients/base/views/list/list.php
//
// Add tags to reports on listviews
//
@esimonetti
esimonetti / mysql_tables_optimize.php
Last active Aug 5, 2019
CLI script to optimize Sugar mysql tables, by dropping all non-primary indices, optimizing and finally re-creating indices. Script similar to https://gist.github.com/esimonetti/7c4d57d57464ce6a71973de6fe0da089 but implementing the recommendations described here https://www.percona.com/blog/2010/12/09/mysql-optimize-tables-innodb-stop/
View mysql_tables_optimize.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2019-01-04 on Sugar 8.0.2
//
// CLI script to optimize Sugar mysql tables, by dropping all non-primary indices, optimizing and finally re-creating indices
function usage($error = '') {
@esimonetti
esimonetti / commentlog.php
Created Dec 28, 2018
Show last 10 commentlog entries on Cases, with the newest one at the top
View commentlog.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-12-28 Sugar 8.3.0
// Show last 10 commentlog entries on Cases, with the newest one at the top
//
// file: custom/Extension/modules/Cases/Ext/Vardefs/commentlog.php
//
@esimonetti
esimonetti / docker-cleanup-resources.md
Created Sep 25, 2018 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks
View docker-cleanup-resources.md

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
View mysql_tables_optimize.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-09-20 on Sugar 8.0.0
//
// CLI script to optimize Sugar mysql tables
ini_set('memory_limit', '64M');
@esimonetti
esimonetti / table_record_counter.php
Last active Sep 19, 2018
Count records per Sugar table and output in json and csv format for reporting purposes
View table_record_counter.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-09-19 on Sugar 8.0.0
//
// CLI script to output the current record count per SQL table, in json and csv format
ini_set('memory_limit', '64M');
You can’t perform that action at this time.