Skip to content

Instantly share code, notes, and snippets.

View manishnakar's full-sized avatar
💭
Exploring Nodejs

Manish Nakar manishnakar

💭
Exploring Nodejs
  • Mumbai, India
  • 10:59 (UTC +05:30)
View GitHub Profile
@manishnakar
manishnakar / install.sh
Created March 26, 2019 08:32 — forked from marklit/install.sh
Bot Detection Script. Works with Apache and Nginx Log Files.
sudo apt-get update
sudo apt-get install \
python-dev \
python-pip \
python-virtualenv
virtualenv findbots
source findbots/bin/activate
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
@manishnakar
manishnakar / Goaccess
Created December 18, 2018 09:15
Visitors
https://goaccess.io/
sudo apt update
$ sudo apt install goaccess
$ sudo goaccess -f /var/log/nginx/access.log -c
sudo apt-get install percona-toolkit
pt-online-schema-change --alter
"Add column <new_column> varchar(60) NOT NULL default <default_value>"
--user=root D=<database_name>,t=<table_name> --execute
SELECT b.email, c.value AS name, a.updated_at, d.added_at, d.product_id, e.name, SUM(g.qty_ordered) AS purchased
FROM `wishlist` AS a
INNER JOIN customer_entity AS b ON a.customer_id = b.entity_id
INNER JOIN customer_entity_varchar AS c ON a.customer_id = c.entity_id AND c.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'firstname' AND entity_type_id = b.entity_type_id)
INNER JOIN wishlist_item AS d ON a.wishlist_id = d.wishlist_id
INNER JOIN catalog_product_flat_1 AS e ON d.product_id = e.entity_id
LEFT JOIN sales_flat_order AS f ON f.customer_email = b.email
LEFT JOIN sales_flat_order_item AS g ON (f.entity_id = g.order_id AND g.sku LIKE CONCAT(e.sku,'%') AND g.product_type = 'simple')
GROUP BY b.email, c.value, a.updated_at, d.added_at, d.product_id, e.name
@manishnakar
manishnakar / Magento-order-sum-breakout-report.sql
Created October 21, 2018 07:25 — forked from tegansnyder/Magento-order-sum-breakout-report.sql
Magento - Sum of All Orders by Month and Year Breakdown includes Discount Sums
SELECT sub_query.month_ordered,
sub_query.year_ordered,
SUM(sub_query.base_subtotal) AS sum_base_subtotal,
SUM(sub_query.discount_amount) AS sum_discount_amt,
SUM(sub_query.order_qty) AS sum_total_item_count,
COUNT(sub_query.entity_id) AS total_orders
FROM
(SELECT so.entity_id,
MONTH(so.created_at) AS month_ordered,
YEAR(so.created_at) AS year_ordered,
@manishnakar
manishnakar / Magento Admin Backend.md
Created August 29, 2018 05:20 — forked from tegansnyder/Magento Admin Backend.md
Magento Custom Admin Backend

You can set your own custom Magento admin URL in:

System -> Configuration -> [ADVANCED] -> Admin -> Admin Base URL

NOTE: Make sure you have added a ServerAlias directive to your virtual host configuration for backend.domain.com and that you have a SSL cert or wildcart setup for HTTPS traffic on that subdomain or you will lock yourself out the admin.

Rules for your .htaccess file to prevent duplicate urls and redirect directly to admin dashboard:

Lumen and naming transactions into NewRelic

Problem: How to build transaction name for NewRelic in Lumen.

Description: NewRelic tries to group similar transaction into group, to be able easier watch for them later on Extra-Problem: NewRelic has an issue and becuase of that they can not group following transactions:

  • /orders/zzZfN0kZ6F1PtFdQ4Baq
  • /orders/aaZDd0k43D1GtFeG5cCe ...
find . -name \*.php -not -path "./vendor/*" -exec php -l "{}" \;
Check swapfile
cd /
ls -a
Just follow these steps:
Make all swap off
sudo swapoff -a
Resize the swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
@manishnakar
manishnakar / error_log
Created August 24, 2017 12:30
php error log
ob_start();
var_dump($_POST);
error_log(ob_get_clean(), 4);