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 / afterEntryPoint.php
Last active November 29, 2017 20:02
Disable Activity Stream on Sugar 7 - Application logic hook to disable writes everywhere and example of vardefs to disable module specific UI
<?php
// Enrico Simonetti
// enricosimonetti.com
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
{
public function disableActivityStream($event, $arguments)
@esimonetti
esimonetti / CustomNotesFilterApi.php
Last active December 8, 2017 05:21
Sample customised filter api to help find Notes that are related to multiple Contacts at the same time, with a custom many to many relationship
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-08 tested on Sugar 7.9.2.0
// Sample customised filter api to help find Notes that are related to multiple Contacts at the same time, with a custom many to many relationship
// eg: {{url}}/rest/v10/Notes?contact_id[]=<first id>&contact_id[]=<second id> will only return Notes that are related to both contacts at the same time
//
// file: custom/modules/Notes/clients/base/api/CustomNotesFilterApi.php
@esimonetti
esimonetti / arduino_temperature_driven_fan.ino
Last active December 14, 2017 06:31
Arduino Temperature Driven Fan - Driving a two speeds fan with an Arduino, based on the environment temperature
#include <EEPROM.h>
#include <EasyButton.h>
#include <LiquidCrystal.h>
#include <dht.h>
// board led
const int board_led = 13;
// eeprom value
byte eeprom_value;
@esimonetti
esimonetti / SugarScript.php
Last active February 6, 2018 23:06
Quick Sugar multi purpose script
<?php
// Enrico Simonetti
// enricosimonetti.com
function usage($error = '') {
if (!empty($error)) print(PHP_EOL . 'Error: ' . $error . PHP_EOL);
print(' php ' . __FILE__ . ' --instance /full/path' . PHP_EOL);
exit(1);
}
@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
@esimonetti
esimonetti / afterEntryPoint.php
Created January 31, 2018 00:38
Disable network card's mac address query on guid/uuid generation
<?php
// Enrico Simonetti
// enricosimonetti.com
// 2018-01-31 on 7.9.3.0
// custom/logichooks/application/afterEntryPoint.php
class afterEntryPoint
@esimonetti
esimonetti / delete_orphans.php
Last active June 29, 2018 02:15
CLI script to find and delete orphan records on the custom tables of Sugar modules - Tested up to 35M records in one script run, at about 5,200 records deleted per second
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2017-12-13 on Sugar 7.9.2.0
//
// CLI script to find and delete orphan records on the custom tables of Sugar modules
function usage($error = '') {
@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 / afterSaveCases.php
Last active August 20, 2018 23:15
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
<?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
@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