Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / Remove the branch locally and in the remote repository in one operation.md
Created September 2, 2024 09:39
This code snippet updates the "nome-branch" branch in a Git repository and deletes it from its origin.

Remove the branch locally and in the remote repository in one operation

Preview:
git branch -D nome-branch && git push origin --delete nome-branch
Associated Context
Type Code Snippet ( .sh )
Associated Tags Git branching Git push origin Nome-branch management Command line interface Node js frameworks Version control Data processing Remote repository creation Repository deletion
💡 Smart Description This code snippet updates the "nome-branch" branch in a Git repository and deletes it from its origin.
@FrancoStino
FrancoStino / Calculate Volumetric Weight Shipping - Woocommerce.md
Created August 14, 2024 09:39
A PHP function to calculate and set volumetric weight for shipping packages in WooCommerce based on product dimensions.

Calculate Volumetric Weight Shipping - Woocommerce

Preview:
<?php 

add_filter('woocommerce_cart_shipping_packages', 'calculate_volumetric_weight_shipping');

function calculate_volumetric_weight_shipping($packages) {
    $conversion_factor = 200; // Il fattore di conversione: 200 kg per m³
   
@FrancoStino
FrancoStino / git-export.md
Created July 29, 2024 14:19 — forked from vanquang9387/git-export.md
git: export diff files between 2 branches/commits

We can get list of changed files between 2 branches/commits by

$ tar --ignore-failed-read -vczf archive.tgz $(git diff --name-only --diff-filter=ACMRT master develop)

Let's see important part:

  1. git diff master develop:
    Get differences between master and develop branches.
@FrancoStino
FrancoStino / Create symbolic links to custom plugins.md
Created July 11, 2024 09:22
Create symbolic links to custom plugins in the current directory from a specified location.
@FrancoStino
FrancoStino / Ollama and Open-WebUI Services.md
Created July 4, 2024 12:24
This code snippet is a configuration file that sets up services for an Ollama application. It specifies the image, container name, ports, volumes, and restarts when running or not. The open-webui service uses Docker API to create

Ollama and Open-WebUI Services

Preview:
version: '3.8'

services:
  ollama:
    image: ollama/ollama
    container_name: ollama
 ports:

Webpack device server configuration - AEM

Preview:
"start": "webpack-dev-server --open --config ./webpack.dev.js --env writeToDisk",
Associated Context
Type Code Snippet ( .json )
Associated Tags package.json GitHub: sidea2 webpack-dev-server open command config file writeToDisk function web development server configuration environment variable
Associated Commit Messages go
@FrancoStino
FrancoStino / Sync ACF Fields on WP_CLI Commands.md
Last active June 7, 2024 18:35
Check if WP_CLI is defined and if the ACF_Commands class does not already exist, then synchronize ACF fields.

Sync ACF Fields on WP_CLI Commands

Preview:
// Controlla se WP_CLI è definito e se non esiste già la classe ACF_Commands
if ( defined( 'WP_CLI' ) && WP_CLI && ! class_exists( 'ACF_Commands' ) ) :

    /**
     * Classe ACF_Commands
     */
    class ACF_Commands extends WP_CLI_Command {
@FrancoStino
FrancoStino / Sync ACF Fields on Admin Init.md
Last active June 12, 2024 08:11
This code snippet adds an action to the admin_init hook. It retrieves field groups, finds JSON field groups which have not yet been imported, and then imports fields from a group based on their local or private values in it. The sync array is also

Sync ACF Fields on Admin Init

Preview:
/**
 * Synchronizes ACF field groups from JSON files.
 *
 * This function is hooked to the `admin_init` action and is responsible for
 * finding and importing any ACF field groups that have been defined in JSON
 * files but have not yet been imported into the database.
 *
@FrancoStino
FrancoStino / Setting JAVA_HOME using update-alternatives in Linux.md
Last active June 4, 2024 15:03
I ran this command in my project directory to build and package it: mvn clean javadoc:jar package I do have my JAVA_HOME variable set correctly. Evidently: $ which java /usr/bin/java $ sudo ls -...

Setting JAVA_HOME using update-alternatives in Linux

Preview:
export JAVA_HOME=$(update-alternatives --query javadoc | grep Value: | head -n1 | sed 's/Value: //' | sed 's@bin/javadoc$@@')
Associated Context
Type Code Snippet ( .sh )
Associated Tags Java Home Update Alternatives Query Javadoc Grep Value head Command sed Command Framework: None JAVA_HOME update-alternatives javadoc environment variable
📝 Custom Description I ran this command in my project directory to build and package it:mvn clean javadoc:jar package
I do have my JAVA_HOME variable set correctly.Evidently:$ which java/usr/bin/java$ sudo ls -...
@FrancoStino
FrancoStino / Docker Engine Stop and Start Commands - Linux.md
Last active May 2, 2024 15:18
Stops and starts a Docker container using the systemctl command, starting with docker mode for debugging.

Docker Engine Stop and Start Commands - Linux

Preview:
# Check if docker engine is active and stop or start accordingly
if systemctl is-active --quiet docker; then
    sudo systemctl stop docker
else
    sudo systemctl start docker
fi