Skip to content

Instantly share code, notes, and snippets.

View MatteoOreficeIT's full-sized avatar

Matteo Orefice MatteoOreficeIT

View GitHub Profile
@MatteoOreficeIT
MatteoOreficeIT / find-overlay2-owner-container.sh
Last active December 7, 2023 11:50
trovare un container a partire da overlay2
#!/bin/bash
# Specifica l'ID del layer di overlay2
OVERLAY_ID="$1"
# Cerca il container associato all'ID del layer
CONTAINER_ID=$(sudo grep -l -r "$OVERLAY_ID" /var/lib/docker/overlay2/*/link | \
sed -n 's|.*/overlay2/\(.*\)/link|\1|p')
# Ottieni il nome del container
@MatteoOreficeIT
MatteoOreficeIT / LaravelQueryJoinRelations.php
Last active October 14, 2023 08:45
Laravel Query Join through Relations
<?php
/**
* User: matteo.orefice
* Date: 16/02/2018
* Time: 16:57
*/
namespace MatteoOrefice\Illuminate\Database\Eloquent\Concerns;
@MatteoOreficeIT
MatteoOreficeIT / collection_product_wide_change.css
Last active July 20, 2023 11:11
Esempio di applicazione regola CSS per tutte le collections e prodotti shopify
/* é necessario poi circorscivere la regola usando un selettore dedicato oltre al sibling css */
body link[rel=alternate][href*="/collections/"] ~ div > div,
body link[rel=alternate][href*="/products/"] ~ div > div,{
background-color: red !important;
}
@MatteoOreficeIT
MatteoOreficeIT / DynamicMailerServiceProvider.php
Last active May 9, 2023 11:13
Laravel: mailing via SMTP with a dynamic configuration determined at Dependency Injection Container resolve-time .
<?php
/**
* Inspired from
* 1. https://github.com/laravel/framework/blob/5.6/src/Illuminate/Mail/TransportManager.php
* 2. https://github.com/laravel/framework/blob/5.6/src/Illuminate/Mail/MailServiceProvider.php
*
* A service provider to register a custom mailer with Dynamic Options ( determined at Dependency Injection Container resolve-time )
*
* 1. resolve-time options: host, port, user, password, secure: [tls,ssl] could be determined at DI container resolve-time
* 2. global options in mail.dynamic config file
@MatteoOreficeIT
MatteoOreficeIT / az-clone-repos.sh
Last active March 16, 2023 13:39
Clone recusively all Azure DevOps repositories
#!/usr/bin/env bash
az devops project list | jq ".value[].name" -r | while read -r PROJECT ;
do
az repos list --project "$PROJECT" | jq ".[].remoteUrl" -r | while read -r GIT_URL ; do
rm -fr "$GIT_URL"
git clone "$GIT_URL"
done
done
@MatteoOreficeIT
MatteoOreficeIT / Integrating_Guzzle_6_Asynchronous_Requests_with_ReactPHP.php
Last active November 23, 2021 06:46
Integrating Guzzle 6 Asynchronous Requests with ReactPHP
<?php
/**
* Credits to :
* @see https://gist.github.com/psampaz/7f2aad5d1d54eeeec8ae
*/
use GuzzleHttp\Handler\CurlMultiHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
@MatteoOreficeIT
MatteoOreficeIT / docker-machine-init.sh
Created June 25, 2020 08:50
Create, start and setup a new docker-machine instance
#!/bin/bash
## NOTA: questo script non va lanciato direttamente ma incluso tramite source o .
if docker-machine status default > /dev/null ;
then
echo "Creazione default docker machine"
docker-machine create default
fi
@MatteoOreficeIT
MatteoOreficeIT / setting-pdo-attributes-in-laravel.php
Last active May 14, 2019 19:56
How to set PDO attributes ( PDO::setAttributes ) Laravel:5.4.* , for example MYSQL_ATTR_USE_BUFFERED_QUERY
<?php
// General error: 2014 Cannot execute queries while other unbuffered queries are active
\DB::getPdo()->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
@MatteoOreficeIT
MatteoOreficeIT / etc.systemd.system.network-write-meta.service
Created March 29, 2019 09:28
systemd unit to write network metadata informations
[Unit]
Description=Write Network Configurations Metadata to /run/network/meta-environ
Requires=network-online.target
After=network-online.target
Before=containerd.service docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c "FILE=/run/network/meta-environ ; hostname -i | sed -e '$ s/^/HOST_ADDRESS_IPV4=/' > $FILE"
@MatteoOreficeIT
MatteoOreficeIT / kendo.core.class.js
Last active March 21, 2019 13:54
kendo.Class.extend OO inheritance facility explained
// var ClasseFiglia = Class.extend(...);
// oppure
// var ClasseFiglia = ClassePadre.extend(...);
// crea una funzione costruttore ClasseFiglia ( detta classe in OOP )
// che si comporta secondo i meccanismi dell ereditarieta'
// Object Oriented, tale costruttore/funzione si puo usare come :
// var instance = new ClasseFiglia({...})
// e generare istanze di quella classe
// Si puo legare su proto.init un costruttore oltre
// alla dichiarazione di proprieta ( condivise ) e metodi che appunto finiranno sul prototype