Instantly share code, notes, and snippets.

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');
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');
View purge_activities_stream.php
<?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!
View CustomSugarCacheRedis.php
<?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
View purge.sh
#!/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
View afterEntryPoint.php
<?php
// Enrico Simonetti
// enricosimonetti.com
// 2018-01-31 on 7.9.3.0
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
View afterSaveCases.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-19 on Sugar 7.9.2.0
//
// Set Case's Teams to the private team of the created by user and of the assigned user. This logic will work only if all users have as default team, their own private team only
// file: custom/logichooks/modules/Cases/afterSaveCases.php
View ProcessQueueCommand.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-15 on Sugar 7.9.2.0
// Sugar CLI command to run index processing without waiting for the scheduler
//
// Trigger reindex with: ./bin/sugarcrm search:reindex
// Process records by running either as a background process or with a cron: ./bin/sugarcrm elastic:process_records
View clean_activities_stream.php
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-13 on Sugar 7.9.2.0
//
// CLI script to clean activity streams to keep only the last N months, and keep only activities of records that are still valid
//
// TEST, TEST, TEST AND USE AT YOUR OWN RISK!