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 / 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 / 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 / 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 / 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 / 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 / checkbox grid sync mvvm.js
Created May 29, 2018 11:12
Telerik Kendo grid checkbox mvvm binding to model
/**
* La variabile $checkedField che vedi riferita arriva da una variabile lato server che contiene
* il nome della colonna da utilizzarsi per settare in automatico il campo del model sul checkbox click
*
* Puo anche valere null o false, in quel caso il valore Javascript deve corrispondere a null o false, per
* fare questo in php si usa il metodo json_encode
*/
/**
* Determina quale e' la colonna tenuta in sync con la checkbox
@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 / 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 / How to store GIT credentials on Azure Kudu environement.md
Last active January 25, 2018 16:47
How to store GIT credentials on Azure (Kudu) environment for external private git repositories authentication

Global GIT Config File

Original problem

  • We need to authenticate to multiple private external repositories using credentials stored in a file
  • We don't want use private/public RSA keys with ssh

Investigating how to load user defined .gitconfig