Skip to content

Instantly share code, notes, and snippets.

@victordit
victordit / remove-table-prefixes.sql
Created October 19, 2020 10:22 — forked from molotovbliss/remove-table-prefixes.sql
Remove table prefixes MySQL
# Set @database, @old_prefix and @new_prefix (if you want a different prefix instead of removing)
# Execute the Generated SQL Query this generates to rename all tables found with prefix.
SET SESSION group_concat_max_len = 999999999;
SET @database = "databasename";
SET @old_prefix = "mgn_";
SET @new_prefix = "";
SELECT GROUP_CONCAT("RENAME TABLE ", TABLE_NAME, " TO ", replace(TABLE_NAME, @old_prefix, @new_prefix),'; ' separator '')
FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database AND TABLE_NAME LIKE CONCAT(@old_prefix, '%');
@victordit
victordit / composer_versions_cheatsheet.md
Created September 18, 2020 10:11 — forked from calebporzio/composer_versions_cheatsheet.md
Composer version symbol cheatsheet
...
"require": {
    "vendor/package": "1.3.2", // exactly 1.3.2 (exact)

    // >, <, >=, <= | specify upper / lower bounds
    "vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
    "vendor/package": "<1.3.2", // anything below 1.3.2

 // * | wildcard
<?php
require_once "app/Mage.php";
umask(0);
// set current store to admin and turn on developer mode
Mage::app('admin');
Mage::setIsDeveloperMode(true);
// load product collection
$productCollection=Mage::getResourceModel('catalog/product_collection');
foreach($productCollection as $product){
echo $product->getId();
@victordit
victordit / shell_delete_unused_images
Created August 6, 2020 12:58 — forked from aleron75/shell_delete_unused_images
Delete no more used Product Images on Magento 1
<?php
require_once 'abstract.php';
class Mage_Shell_CheckImages extends Mage_Shell_Abstract
{
const CATALOG_PRODUCT = '/catalog/product';
const CACHE = '/cache/';
protected function _glob_recursive($pattern, $flags = 0)
@victordit
victordit / export_categories_m1.php
Created July 9, 2020 01:19 — forked from bluec/export_categories.php
Export Magento category tree with full names, paths and URLs
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
@victordit
victordit / magento2-clear.sql
Created December 20, 2019 13:42 — forked from sergiojovanig/magento2-clear.sql
Magento 2 Clear Database
##########################################################
# PRODUCTS
##########################################################
DELETE FROM `catalog_product_bundle_option`;
DELETE FROM `catalog_product_bundle_option_value`;
DELETE FROM `catalog_product_bundle_selection`;
DELETE FROM `catalog_product_entity_datetime`;
DELETE FROM `catalog_product_entity_decimal`;
DELETE FROM `catalog_product_entity_gallery`;
DELETE FROM `catalog_product_entity_int`;
@victordit
victordit / curl.md
Created December 10, 2019 15:57 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@victordit
victordit / git.migrate
Created July 31, 2019 14:21 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@victordit
victordit / .bashrc
Created December 13, 2018 14:33
git branch in linux profile
## Edit your profile
vim ~/.bashrc
## Add the follow code after last line
## git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "