Skip to content

Instantly share code, notes, and snippets.

Raj KB MagePsycho

Block or report user

Report or block MagePsycho

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MagePsycho
MagePsycho / default.vcl
Created Feb 21, 2019
Wordpress Varnish VCL File
View default.vcl
vcl 4.0;
import std;
import directors;
backend server1 {
.host = "127.0.0.1"; # IP or Hostname of backend
.port = "8080"; # Port Apache or whatever is listening
.max_connections = 800; # That's it
.first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?
@MagePsycho
MagePsycho / Wordpress.md
Last active Dec 29, 2018
Wordpress: Cheatsheet
View Wordpress.md

CHANGE BASE URL

BASIC

SELECT * FROM wp_options where option_name IN ('siteurl', 'home');
UPDATE wp_options SET option_value = 'http://blog.mage-expo.com' WHERE option_name IN ('siteurl', 'home');

ADVANCED

SET @OLD_URL = 'oldurl.com';
@MagePsycho
MagePsycho / README.md
Last active Jul 6, 2018
Code Deployment via Webhook (Bitbucket)
View README.md

Assumption

  • OS: Ubuntu 16.04
  • SCM: Bitbucket
  • Remote Git Repo: git@bitbucket.org:magepsycho/magepsycho.git
  • Deployment Branch: master
  • Web Root Dir: /var/www/magento2/magepsycho
  • Git Repo Dir: /var/www/magento2/magepsycho.git

Git Setup

In remote server

@MagePsycho
MagePsycho / mage2-codebase-database-backup.sh
Last active May 29, 2018
Shell Script: Magento2 Database + Codebase Backup. More - http://www.blog.magepsycho.com/
View mage2-codebase-database-backup.sh
#!/bin/bash
#
# Script to backup Magento2 Codebase + Database
#
# @author Raj KB <magepsycho@gmail.com>
# @website http://www.magepsycho.com
# @version 0.1.0
# UnComment it if bash is lower than 4.x version
@MagePsycho
MagePsycho / .gitignore
Created Aug 28, 2017
Magento 1: Gitignore
View .gitignore
# General web stuff
#/.htaccess
/robots.txt
/sitemap.xml
# Dynamic Magento data
/var/*
/media/catalog/product/cache/*
/media/tmp/
/media/js/*
@MagePsycho
MagePsycho / MongoDb-Installation-Ubuntu-16.04.md
Last active Aug 1, 2019
MongoDb (Server, Client, PHP Extension) #mongo #mongodb
View MongoDb-Installation-Ubuntu-16.04.md

Mongo DB Installation (Ubuntu)

Mongo Server [Not using this one]

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org=3.2.6 mongodb-org-server=3.2.6 mongodb-org-shell=3.2.6 mongodb-org-mongos=3.2.6 mongodb-org-tools=3.2.6
echo "MongoDB v3.2.6 installed successfully"
@MagePsycho
MagePsycho / mysql-cumulative-sum.sql
Created Aug 7, 2017
MySQL: Running Total (Cumulative Sum)
View mysql-cumulative-sum.sql
-- without using SET variable
SELECT t.id,
t.count,
(@running_total := @running_total + t.count) AS cumulative_sum
FROM TABLE t
JOIN (SELECT @running_total := 0) r
ORDER BY t.id
-- with SET variable
SET @running_total := 0;
@MagePsycho
MagePsycho / dynamic-table.sql
Last active Aug 7, 2017
MySQL: Dynamic Table + SQL
View dynamic-table.sql
-- @author Raj KB
-- @website http://blog.magepsycho.com
SET @STORE_ID = 7;
SET @CATALOG_FLAT_TABLE = CONCAT('catalog_product_flat_', @STORE_ID);
SET @QUERY = CONCAT('SELECT * FROM ', @CATALOG_FLAT_TABLE, ' LIMIT 10');
PREPARE stmt FROM @QUERY;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@MagePsycho
MagePsycho / dump-all-dbs.sh
Last active Oct 6, 2017
MySQL: Dump all databases in a localhost
View dump-all-dbs.sh
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/home/rajendra"
MYSQL=/usr/bin/mysql
MYSQL_USER="root"
MYSQL_PASSWORD="mys123"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql-dump"
@MagePsycho
MagePsycho / m2-import-prices-index.php
Last active Oct 16, 2018
Update Magento2 Prices in bulk - an easier and faster way!
View m2-import-prices-index.php
<?php
/**
*
* @author Raj KB<magepsycho@gmail.com>
* @website http://www.magepsycho.com
* @extension MassImporterPro: Pricing - http://www.magepsycho.com/mass-importer-pro-price-importer-regular-special-tier-group.html
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
You can’t perform that action at this time.