Posts Tagged ‘yajukumar’

Install sublime on Ubuntu

June 22, 2017 Leave a comment

Sublime is a very popular editor, it is very easy to use and very lightweight.
Sublime site

Installation of sublime is very simple on linux.

For Sublime-Text-2:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-2
$ sudo apt-get update
$ sudo apt-get install sublime-text

For Sublime-Text-3:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
$ sudo apt-get update
$ sudo apt-get install sublime-text-installer


Connect Mysql from git on windows

December 16, 2016 Leave a comment

We can connect to mysql from git on window through this command.

winpty mysql -uROOT -pPASSWORD

Categories: Mysql Tags: , , , ,

MongoDb Introduction

April 7, 2016 Leave a comment

MongoDB Databse-
MongoDB is NoSql and document oriented database. MongoDB stores data using a flexible document data model that is similar to JSON.

Create Database-
>use yaju;

Show Database-
>show dbs

Drop Database-
To drop database, first use that database then use following command.

Create Collection-
Collections are like table in MySql. We can create collection in two ways.

First, we can create empty collection

Second, we can create dynamic collection with insert command. Mongo check that collection if collection is exists then insert data in existing collection otherwise create new collection and insert data. That can be through followning command.

Show collections-
Show all collection in a database use following command.
>show collections;

Insert document-
We can insert single document and multiple document as well.

Single document
Multiple document
>db.testtable.insert([{‘name’:’yajuvendra’},{‘name’:’yaj’}, {‘name’:’yaju’},{‘name’:’yajkumar’}]);

Select document-
Select all document
Select particular document
> db.testtable.find({‘name’:’yaj’});

Remove document-
> db.testtable.remove({‘name’:’yaju’});

Update document-
> db.testtable.update({name:’yaj’},{$set:{name:’yaju_update’}})

Mysql Important

November 3, 2015 Leave a comment


#Login to mysql
mysql> -hlocalhost -P3306 -u{user name} -p

#Select Current User
mysql bin folder>select user();
| user() |
| root@localhost |
1 row in set (0.00 sec)

#Select Mysql Version
mysql bin folder>select version();
| version() |
| 5.6.17 |
1 row in set (0.00 sec)

#Select Current Database
mysql bin folder>select database();
Output- These is not database selected.
| database() |
| NULL |
1 row in set (0.00 sec)

#Select Current date with Hour Minute and Second
mysql bin folder>select now();
| now() |
| 2016-04-04 12:52:55 |
1 row in set (0.00 sec)

#Select Current date, shows only date.
mysql bin folder>select now();
| current_date() |
| 2016-04-04 |
1 row in set (0.00 sec)

#Export database or table
mysql bin folder>mysqldump -hlocalhost -P3306 -u{username} -p{password} {database name} {table name} > export file path/filename.sqlpath/filename.sql

#Import database or table
mysql bin folder>mysql -hlocalhost -P3306 -u{username} -p{password} {database name} {table name} < import file path/filename.sql

Create: mysql>create view {view name} as select * from {table name};
View: mysql>show full tables;
mysql>show full tables in {database name} table_type like ‘view’;
Drop: mysql>drop view {view name};

mysql>delimiter //
mysql> create trigger {trigger name}
after insert
on {table name} for each row
insert into {table name} values(”, new. {new value});
mysql>delimiter ;

mysql>show triggers;

mysql>drop trigger {trigger name};

mysql>delimiter //
mysql>create procedure {procedure name}(in inputvalue int, out outputvalue int)
outputvalue = inputvalue;
end; //
mysql>delimiter ;

mysql>call {procedure name}(inputvalue, @output);
mysql>select @output;(result 100);

mysql>show procedure status;

mysql>drop procedure {procedure name};

mysql>delimiter //
mysql>create function {function name}({parameter name} {data type})
returns {data type}
declare {variable name} {data type};
select {variable name} into {paramerter name} from {table name} where id={parameter name};
return ({variable name});
end; //
mysql>delimiter ;


Categories: Mysql Tags: , , , , ,

Speed up site with .htaccess

January 20, 2015 1 comment

Append these line in your .htaccess file.

#Trun on compression

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

#Turn on content caching

ExpiresActive On
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”

ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/ “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType image/svg+xml “access plus 1 month”

ExpiresDefault “access 2 days”
Header set Cache-Control “public”
Header unset Cache-control

Header append Vary: Accept-Encoding
Header unset Pragma

#Mod_deflate is an apache module that can be used to compress data using gzip compression before sending it to the browser

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/x-font-ttf

Install Ruby On Windows

January 19, 2015 Leave a comment

Get ruby installer for windows from here
Download Development kit from here

Setup development enviorment-
1. Run ruby installer
a. Set installation path. Mine is C:\wamp\bin (I’m using wamp server for php and I’m going to use it’s mysql and Apache.)
2. Run Development kit installer
a. Set installation path. Mine is C:\wamp\bin\Ruby193\DevKit
3. Open commant prompet and run this command to check ruby version.
> ruby -v
OUtput comes like this ruby 1.9.3p551 (2014-11-13) [i386-mingw32] if not then set enviorment valiable for ruby. Mine is C:\wamp\bin\Ruby193\bin


December 20, 2014 Leave a comment

OPcache is bundled with PHP 5.5.0 and later, and is available in PECL for lower PHP version.
OPcache improves PHP performance. OPcache stores precompiled script bytecode in shared memory on first request. When next request comes then PHP does not compile that script, it uses precompiled script from OPcache.
cache opcache_reset() OPcache offers a function to reset.
pcache_invalidate ( string $script [, boolean $force = FALSE ] ) This function invalidate a script.

Enable OPcache on linux: To enable OPcache on linux uncommment or add this line in php.ini if this not enable OPcache on server then put full path of

OPcache configuration: You can change OPcache configuration from php.ini. Some important configuration setting are
1. opcache.revalidate_freq=60
Here 60 is seconds. OPcache validate cache after given seconds.

2. opcache.max_accelerated_files=7000
This is number of script sotre in OPcache. You can change this number as you needed.

To see OPcache configuratin and status you need a script on same server. Opcache-gui is the good script.

Scaling PHP Book

Categories: php Tags: , , , , , , ,
%d bloggers like this: