Skip to content

Instantly share code, notes, and snippets.

View twopix's full-sized avatar
💭
Be on top, not just online!

George Melidis twopix

💭
Be on top, not just online!
View GitHub Profile
@twopix
twopix / decode_slugs.sh
Last active February 21, 2024 12:26
This Bash script decodes URL-encoded slugs from an input file and writes the decoded slugs to an output file. It is useful for converting encoded text, such as URL parameters or filenames, into human-readable format. Instructions: 1. Prepare an input text file containing URL-encoded slugs. 2. Run this script to decode the slugs and write the dec…
#!/bin/bash
# Input and output file paths
input_file="input_slugs.txt"
output_file="output_slugs.txt"
# Check if input file exists
if [ ! -f "$input_file" ]; then
echo "Input file '$input_file' not found."
exit 1
@twopix
twopix / opencart_delete_orders.sql
Created August 29, 2023 11:07
Delete Opencart orders. Delete orders based on specific conditions, such as keeping only the orders from the last week and deleting all other orders
-- Delete order products
DELETE FROM oc_order_product
WHERE order_id IN (
SELECT order_id
FROM oc_order
WHERE date_added < DATE_SUB(NOW(), INTERVAL 1 WEEK)
);
-- Delete order options
DELETE FROM oc_order_option
@twopix
twopix / function.php
Created December 6, 2022 11:48
Fully Disable Gutenberg editor
// Fully Disable Gutenberg editor.
add_filter('use_block_editor_for_post_type', '__return_false', 10);
// Don't load Gutenberg-related stylesheets.
add_action( 'wp_enqueue_scripts', 'remove_block_css', 100 );
function remove_block_css() {
wp_dequeue_style( 'wp-block-library' ); // Wordpress core
wp_dequeue_style( 'wp-block-library-theme' ); // Wordpress core
wp_dequeue_style( 'wc-block-style' ); // WooCommerce
wp_dequeue_style( 'storefront-gutenberg-blocks' ); // Storefront theme
}
@twopix
twopix / gist:b84ff64664da7d9f73216b0b6f298afb
Last active June 28, 2022 09:36
javascript . extract array from obj
languages: [
{
label: "English",
code: "en",
},
{
label: "Deutsch",
code: "de",
},
{
@twopix
twopix / .httaccess
Created June 21, 2022 17:57
change php version in subdomain
# lsapi configuration for alt-php72
<IfModule lsapi_module>
lsapi_engine On
AddHandler application/x-httpd-alt-php72___lsphp .php .php7 .phtml
</IfModule>
# lsapi configuration for alt-php73
<IfModule lsapi_module>
lsapi_engine On
AddHandler application/x-httpd-alt-php73___lsphp .php .php7 .phtml
@twopix
twopix / footer.php
Created June 18, 2022 11:58
Change language in Userway with polylang function
@twopix
twopix / products.sql
Created May 10, 2022 19:40
Opencart. Add products to parent categories if not exists
INSERT INTO `2p_product_to_category`
SELECT p.product_id, c.parent_id
FROM `2p_product_to_category` p
LEFT JOIN `2p_category` c on p.category_id = c.category_id
WHERE NOT EXISTS (SELECT * FROM `2p_product_to_category` pc WHERE pc.product_id = p.product_id and
pc.category_id = c.parent_id ) AND c.parent_id !=0
@twopix
twopix / function.php
Created April 4, 2022 19:54
WooCommerce Display Stock Availablity
/**
* WooCommerce Display Stock Availablity
*/
add_filter( 'woocommerce_get_availability', 'mg_display_stock_availability', 1, 2);
function mg_display_stock_availability( $availability, $_product ) {
global $product;
@twopix
twopix / currect.php
Created March 30, 2022 13:58
php script that correct files and permissions recursively
<?
header('Content-Type: text/plain');
/**
* Changes permissions on files and directories within $dir and dives recursively
* into found subdirectories.
*/
function chmod_r($dir, $dirPermissions, $filePermissions) {
$dp = opendir($dir);
while($file = readdir($dp)) {
@twopix
twopix / journal3
Created February 21, 2022 16:00
opencart add home text to breadcrumps
//add home to breadcrumps
document.body.onload = addbrElement;
function addbrElement () {
const newSpan = document.createElement("span");
// and give it some content
const newContent = document.createTextNode("Home!");
// add the text node to the newly created div