Skip to content

Instantly share code, notes, and snippets.

View esimonetti's full-sized avatar
📃
Open to new opportunities

Enrico Simonetti esimonetti

📃
Open to new opportunities
View GitHub Profile
@esimonetti
esimonetti / secretHandling.php
Last active May 13, 2019 05:45
Sample of programmatic AES256GCM and blowfish encryption and decryption of secret value in Sugar
<?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 January 9, 2019 23:34
Add tags to reports on listviews
<?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 October 30, 2019 08:14
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/ - USE TOOT…
<?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 December 28, 2018 05:47
Show last 10 commentlog entries on Cases, with the newest one at the top
<?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 September 25, 2018 05:30 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

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

<?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 October 30, 2019 08:16
Count records per Sugar table and output in json and csv format for reporting purposes - USE TOOTHPASTE INSTEAD! https://github.com/esimonetti/toothpaste
<?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');
@esimonetti
esimonetti / purge_activities_stream.php
Last active November 1, 2018 21:37
The latests up to date project is located here: https://github.com/esimonetti/SugarActivityStreamPurger. CLI script to hard delete activity streams. It will keep: comments, activities with comments, user posts, link and unlink activities and all activities created within the last N months
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-09-19 on Sugar 8.0.0
//
// CLI script to hard delete activity streams. It will keep: comments, activities with comments, user posts, and all activities created within the last N months
//
// TEST, TEST, TEST AND USE AT YOUR OWN RISK!
@esimonetti
esimonetti / CustomSugarCacheRedis.php
Created August 7, 2018 04:27
The aim of this customisation is to not run Redis::expire when the ttl is 0, to set no expiration for those keys
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-08-07 tested on Sugar 8.0.0 on PHP 7.1
// file: custom/include/SugarCache/CustomSugarCacheRedis.php
// The aim of this customisation is to not run Redis::expire when the ttl is 0, to set no expiration for those keys
class CustomSugarCacheRedis extends SugarCacheRedis
@esimonetti
esimonetti / purge.sh
Created May 3, 2018 01:24 — forked from adrienbrault/purge.sh
Script to reduce VM size before packaging for vagrant
#!/bin/sh
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
aptitude -y purge ri
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5