Skip to content

Instantly share code, notes, and snippets.

@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
@FrancoStino
FrancoStino / Custom WooCommerce Product Export Data Filter Function CSV - Strip HTML & \n.md
Last active May 2, 2024 07:31
This code snippet adds a filter to the 'woocommerce_product_export_row_data' table. It iterates through each row and checks if it contains specific attributes, removing any trailing whitespace characters from that column or short description

Custom WooCommerce Product Export Data Filter Function CSV - Strip HTML & \n

Preview:
add_filter('woocommerce_product_export_row_data', 'your_theme_custom_export_data', 2, 999);

function your_theme_custom_export_data($row, $product)
{
    foreach ($row as $row_name => $row_value)
    {
 // Check for 'description' or 'short_description' directly
@FrancoStino
FrancoStino / Change Ownership and Permissions for Files in a Directory.md
Last active April 18, 2024 16:31
Using the find command to locate files owned by a specific group and changing ownership and permissions.

Change Ownership and Permissions for Files in a Directory

Preview:
sudo find /path/to/directory -group 100999 -exec chown davide:davide {} \; -exec chmod 775 {} \; ; echo "Operazione completata!"
Associated Context
Type Code Snippet ( .js )
Associated Tags sudo command Directory management Command line interface User interaction File creation Shell scripting Dev tools Data retrieval Error handling Output display
💡 Smart Description Using the find command to locate files owned by a specific group and changing ownership and permissions.This code snippet searches for a directory named "Operazione completata" in the specified group, then copies and chmods it to 775. The executable is executed with an error message indicating that something went wrong.
@FrancoStino
FrancoStino / Expose Localhost to the Internet with ngrok.md
Last active April 9, 2024 10:24
This code snippet sets up an HTTP connection to the localhost port 9000 and returns a string with no timeout.

Expose Localhost to the Internet with ngrok

Preview:
// Start a tool to expose a local server running on a specific port over HTTP
// Note: This code snippet requires ngrok to be installed on the system

ngrok http http://localhost:9000
Associated Context