Skip to content

Instantly share code, notes, and snippets.

View gelanivishal's full-sized avatar
🎯
Focusing

Vishal Gelani gelanivishal

🎯
Focusing
View GitHub Profile
@gelanivishal
gelanivishal / validation.md
Last active February 21, 2017 01:38
Magento 2 xml validation

Check updates to the GitHub today, Magento 2 introduced new command to automatically generate all the URN resolutions for the PhpStorm.

To use it: have Magento installed on the same machine as PhpStorm go to the root directory execute command

$ php bin/magento dev:urn-catalog:generate .idea/misc.xml
@gelanivishal
gelanivishal / product_by_id.php
Created December 31, 2016 17:45
Load product by product id in listing #M2
<?php
// PS: Do not use *load/save* methods directly, instead use related repositoryinterface.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$load_product=$objectManager->get('Magento\Catalog\Api\ProductRepositoryInterface');
$_product = $load_product->getById($_single_product_id);
find . -type f -exec chmod 644 {} \; // 644 permission for files
find . -type d -exec chmod 755 {} \; // 755 permission for directory
find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
@gelanivishal
gelanivishal / lnmp.sh
Last active February 21, 2017 01:39
Ubuntu 16.04: Install Nginx + PHP7 + MySql
# Nginx
sudo apt-get update
sudo apt-get install nginx
sudo nano /etc/nginx/sites-available/default
# PHP
sudo apt-get update
sudo apt-get install php7.0-fpm php-mysql
sudo apt-get install php7.0-mysql php7.0-mysqli php7.0-curl php7.0-json php7.0-mcrypt php7.0-zip php7.0-dom php7.0-intl
sudo nano /etc/php/7.0/fpm/php.ini
$.ajax({
url: "http://www.example.com/api",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
type: 'POST',
dataType: 'json',
contentType: 'application/json',
processData: false,
data: '{"foo":"bar"}',
@gelanivishal
gelanivishal / m2_commands.sh
Last active February 21, 2017 01:39
M2: Useful commands
# deploy static content
php bin/magento setup:upgrade
rm -rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ pub/static var/composer_home
php bin/magento setup:static-content:deploy
chmod -Rf 777 pub/ var/
# enable language pack for any language
php bin/magento cache:clean
php bin/magento setup:static-content:deploy et_EE
@gelanivishal
gelanivishal / wp-fix-file-permission.sh
Created December 25, 2016 03:07
Wordpress fix file permission
wget https://gist.github.com/Adirael/3383404/raw/6c5446d56477426faeb709e5b807f00422acdea2/fix-wordpress-permissions.sh # <-- Check below code wp-permissions.sh
chmod +x fix-wordpress-permissions.sh
sudo ./fix-wordpress-permissions.sh /your/wordpress/path
@gelanivishal
gelanivishal / create-ftp-account-via-ssh.sh
Created December 25, 2016 03:06
Create FTP Account Via SSH
useradd <user>
groupadd <group-name>
gpasswd -a <user> <group-name>
chgrp -R <group-name> /path/to/dir/
chmod -R g+rw /path/to/dir/
passwd <user>
@gelanivishal
gelanivishal / scp
Created December 25, 2016 03:06
Transfer data from local to server and server to local with using scp
Secure Copy (scp)
Copy the file "foobar.txt" from a remote host to the local host
> $ scp your_username@remotehost.edu:foobar.txt /some/local/directory
Copy the file "foobar.txt" from the local host to a remote host
> $ scp foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy the directory "foo" from the local host to a remote host's directory "bar"
> $ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
@gelanivishal
gelanivishal / download-file-curl.sh
Created December 25, 2016 03:05
Download file using CURL
curl -u USER:PASS -O ftp://HOST/PATH/FILE.EXT