Friday, November 18, 2016

Get magento session variable in php page

Mage::app('admin'); //get the admin session
Mage::getSingleton('core/session', array('name'=>'adminhtml')); //verify if the user is logged in to the backend
if(Mage::getSingleton('admin/session')->isLoggedIn()){
echo "logged in";
}else{
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
header('Location: '.$url."index.php/admin");
exit;
}

Thursday, November 17, 2016

How to Add Disqus Comment System in WordPress


Disqus

Disqus, pronounced "discuss", is a service and tool for web comments and discussions. Disqus makes commenting easier and more interactive, while connecting websites and commenters across a thriving discussion community.
The Disqus for WordPress plugin seamlessly integrates using the Disqus API and by syncing with WordPress comments.

Disqus for WordPress

  • Uses the Disqus API
  • Comments indexable by search engines (SEO-friendly)
  • Support for importing existing comments
  • Auto-sync (backup) of comments with Disqus and WordPress database

Adding Disqus Commenting System in WordPress

Adding Disqus commenting system to WordPress is very easy. 
First thing you need to do is go to Disqus website and login or signup for a new account. 
Once you are logged in, click on For Websites link next to the Disqus logo.

On the next screen, you need to click on Add Disqus to Your Site button next to your profile pic on the top right corner of the screen.

This will take you to a signup form where you need to provide your website information. Provide the title of your blog or website and then choose a unique URL for your website on the disqus commenting system. This unique URL will be the place where you can access all your comments after you have installed Disqus on your site. Lastly choose a category for your website. Once you are done, hit the Finish Registration button.




Now that you have registered your site for Disqus commenting system, it is time to connect your WordPress site to the Disqus platform. To do this, you need to install and activate the Disqus Comment System plugin. Upon activation, go to Comments » Settings and sign in with your Disqus account.


disqus-wordpress-signin

Once you are logged in, you will be shown the site you registered for Disqus commenting system. Select the site and click on the next button to finish the set up. That’s all. You have successfully added Disqus comment system to your site.

mongodb install windows

mongodb install windows

Download the latest production release of MongoDB from the MongoDB downloads page.

Click on .msi file and follow the instructions.

mongo Db

To Start the Mongodb server

Open an Administrator command prompt. Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to run the Command Prompt as Administrator. Go to Mongo db installed directory.
sy: mongod --dbpath="path to db" --port=27017
 Example: mongod --dbpath=d:\mongodb\ --port=27017

mongod ------ Command
dbpath  --- specify the database storeing path
port --- port number default port (27017)




Connect to the Mongo Db server using command prompt

Using below command we will able to connect to mongo server from command prompt in windows

sy : mongo --port=27017
Example: "C:\Program Files\MongoDB\Server\3.2\bin\mongo.exe

Friday, November 4, 2016

MySQL to export and import an .sql file from command line

 
 

To Export & Import Mysql data using Command Line

To export

If it's an entire DB, then:
$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql
If it's all DBs, then:
$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql
If it's specific tables within a DB, then:
$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql
You can even go as far as auto-compressing the output using gzip (if your DB is very big):
$ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.sql.gz
If you want to do this remotely and you have the access to the server in question, then the following would work (presuming the MySQL server is on port 3306):
$ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql

To import

Type the following command to import sql data file:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
In this example, import 'data.sql' file into 'blog' database using Anil as username:
$ mysql -u anil -p -h localhost blog < data.sql
If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows:
$ mysql -u username -p -h 202.54.1.10 databasename < data.sql
OR use hostname such as mysql.cyberciti.biz
$ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql
If you do not know the database name or database name is included in sql dump you can try out something as follows:
$ mysql -u username -p -h 202.54.1.10 < data.sql

Friday, August 12, 2016

Mysql Interview Questions



  • What are the different tables present in mysql

           ---Myisam, isam, innodb, heap, merge


  • Types of index in mysql 

           --unique index, index

  • How to create Indx

           --sy: CREATE  INDEX AUTHOR_INDEX ON tutorials_tbl (tutorial_author)


  • Table have multiple index which order query will follow



  • Explain keyword 

Thursday, August 11, 2016

Linux Commands


1. To remove files in current directory

rm -rf ./*


2.To change the file permissions

Why is Magento 1.4 including javascript files by filesystem path?
  
 chmod -R 777 var/ media/
-R --recusively
777 --- Full permissions to all users
var/media --- directory path


3. Add svn repositry in server

svn co  
 svn co https://acd.svn.beanstalkapp.com/ekr-tbp/trunk test2/


4. To start the apache server

service httpd start
service httpd stop

5. To see the error log

tail
tail -f  
cat  

6.To Rename the folde name
mv old-file-name  new-file-name

7. Zip the files on current directory
tar -cvf aws6-9-16.tar
tar -czf aws6-9-16.tar.gz . --exclude=./*.gz

mv testfile testfile2

8. To set number in vim editor
:set nu

9. To remove all content of  a file using vim editor
:1,$d
dgg
10. Download a file using curl
curl -OL http://pear.php.net/go-pear.phar

11. To unzip specific file on current directory
unzip agf-stage.zip -d .
. ---current directory
agf-stage.zip ---file name


Mysql adding user for remote access or workbench



In order to connect remotely you have to have MySQL bind port: 3306 to your machines IP in my.cnf. Then you have to have created the user in both localhost and '%' wildcard and grant permissions on all DB's as such . See below:


path : /etc/mysql/my.cnf

my.cnf
#Replace xxx with your IP Address 
bind-address        = xxx.xxx.xxx.xxx
Creating the user
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
And granting permissions to the user
GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';
FLUSH PRIVILEGES;

To get the user list and there permissions in mysql db
mysql> SELECT user, host FROM mysql.user;
+------------+---------------------+
| user       | host                |
+------------+---------------------+
| adadmin    | %                   |
| tbpmagento | %                   |
| wpuser_agf | %                   |
| root       | 127.0.0.1           |
| root       | ::1                 |
| ces        | localhost           |
| root       | localhost           |
| tbp        | localhost           |
| tbpmagento | localhost           |
+------------+---------------------+