Skip to content

Instantly share code, notes, and snippets.

@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 / Modify WooCommerce Dropdown Variation Attribute Options HTML with Sorting.md
Last active April 10, 2024 12:37
This code snippet adds a filter to modify HTML of the dropdown for variation attribute options. It parses arguments with default values and sorts it into variables based on whether an option is selected or not, using custom filters in WC

Modify WooCommerce Dropdown Variation Attribute Options HTML with Sorting

Preview:
<?php

// Add a filter to modify the HTML of the dropdown for variation attribute options
add_filter('woocommerce_dropdown_variation_attribute_options_html', 'wc_dropdown_variation_attribute_options_sorted', 20, 2);

// Function to sort the variation attribute options
function wc_dropdown_variation_attribute_options_sorted( $html, $args ) {
@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
@FrancoStino
FrancoStino / GoogleShipping Class with Feed Helper and XML - CTX Feed.md
Last active April 11, 2024 19:00
This code snippet defines a class called GoogleShipping that extends the Shipping class. It includes methods for getting shipping information, fetching feed file types and parsing XML data based on certain conditions such as location ID, location group name, minimum handling time, maximum transmission time,

GoogleShipping Class with Feed Helper and XML - CTX Feed

Preview:
<?php

/**
 * Class GoogleShipping
 *
 * @package    CTXFeed
 * @subpackage CTXFeed\V5\Shipping
@FrancoStino
FrancoStino / Recursive Deleting for Files.md
Created March 13, 2024 09:53
The code snippet deletes files one by one, and then updates the index with the current state of the working directory. The '--ignore-unmatch' flag is used to operate quietly (silencing unnecessary output) in case there are no files to remove.

Recursive Deleting for Files

Preview:
# To make the command more performant, we can skip the recursive deletion of files one by one, and instead directly update the index with the current state of the working directory.
# This can be achieved using the following single command:

git rm -r --cached . -q --ignore-unmatch

# The '-q' flag is used to operate quietly (silencing unnecessary output).
# The '--ignore-unmatch' flag prevents an error in case there are no files to remove.
@FrancoStino
FrancoStino / Docker Run Out. Dispatcher AEM.md
Last active March 12, 2024 20:14
This code runs a Docker container on port 4503 8080 and pauses the running process.

Docker Run Out. Dispatcher AEM

Preview:
@echo off
   bin\docker_run out host.docker.internal:4503 8080
   pause
Associated Context
Type Code Snippet ( .js )
@FrancoStino
FrancoStino / Enable long file paths in Git configuration..md
Last active March 7, 2024 08:04
Filename too long in Git for Windows I'm using Git-1.9.0-preview20140217 for Windows. As I know, this release should fix the issue with too long filenames. But not for me. Surely I'm doing something wrong: I did git config core.longpa...

Enable long file paths in Git configuration.

Preview:
git config --system core.longpaths true
Associated Context
Type Code Snippet ( .sh )
Associated Tags windows git git config system longpaths Git configuration System command line Configuration management Command-line interface Version control Software development (SDK) User input github bitbucket version-control mercurial Git Configuration System Level Core Settings Long Paths True Value Version Control File Management Configuration Options System-wide Settings Path Length Limit
📝 Custom Description Filename too long in Git for WindowsI'm using Git-1.9.0-preview20140217 for Windows. As I know, this release should fix the issue with too long filenames. But not for me.Surely I'm doing something w
@FrancoStino
FrancoStino / Disable Payment Gateway for Specific City in WooCommerce.md
Last active March 6, 2024 17:24
This code snippet adds a filter to the 'woocommerce_available_payment_gateways' list. It checks if an admin user is enabled and disables country based on their billing city, then removes the customer's shipping city from that available gateways by setting it in

Disable Payment Gateway for Specific City in WooCommerce

Preview:
// Register a filter hook with a specific function name
add_filter('woocommerce_available_payment_gateways', 'customize_payment_gateway_based_on_criteria', 10, 1);

// Function to customize a payment gateway based on specific conditions
function customize_payment_gateway_based_on_criteria($available_gateways) {
    // Check if in the admin area and return early
    if (is_admin()) {