Skip to content

Instantly share code, notes, and snippets.

View MagePsycho's full-sized avatar

magepsycho MagePsycho

View GitHub Profile
<?php
/**
* @author Raj KB <[email protected]>
* @website https://www.magepsycho.com
*
*/
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
@MagePsycho
MagePsycho / default.vcl
Created February 21, 2019 10:49
Wordpress Varnish VCL File
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 / Installation.md
Last active June 3, 2022 09:44
Wordpress: Cheatsheet

Manually (Option 1)

warden shell
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
touch /tmp/wordpress/.htaccess
mkdir /tmp/wordpress/wp-content/upgrade
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
cp -a /tmp/wordpress/. /var/www/html
@MagePsycho
MagePsycho / README.md
Last active July 6, 2018 21:40
Code Deployment via Webhook (Bitbucket)

Assumption

  • OS: Ubuntu 16.04
  • SCM: Bitbucket
  • Remote Git Repo: [email protected]: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 03:58
Shell Script: Magento2 Database + Codebase Backup. More - http://www.blog.magepsycho.com/
#!/bin/bash
#
# Script to backup Magento2 Codebase + Database
#
# @author Raj KB <[email protected]>
# @website http://www.magepsycho.com
# @version 0.1.0
# UnComment it if bash is lower than 4.x version
@MagePsycho
MagePsycho / .gitignore
Created August 28, 2017 20:18
Magento 1: Gitignore
# General web stuff
#/.htaccess
/robots.txt
/sitemap.xml
# Dynamic Magento data
/var/*
/media/catalog/product/cache/*
/media/tmp/
/media/js/*
@MagePsycho
MagePsycho / Mongo-Installation-Ubuntu-20.04.md
Last active August 30, 2022 08:08
MongoDb (Server, Client, PHP Extension) #mongo #mongodb

Install MongoDB

wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

# Start MongoDB
sudo systemctl start mongod
@MagePsycho
MagePsycho / mysql-cumulative-sum.sql
Created August 7, 2017 19:18
MySQL: Running Total (Cumulative Sum)
-- 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 August 7, 2017 18:52
MySQL: 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 October 6, 2017 06:44
MySQL: Dump all databases in a localhost
#! /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"