Archive

Author Archive

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 https://www.sublimetext.com/

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

Update kali source.list

June 15, 2017 Leave a comment

Paste following line in etc/apt/source.list

# deb cdrom:[Debian GNU/Linux 2017.1 _Kali-rolling_ – Official Snapshot amd64 LIVE/INSTALL Binary 20170416-02:08]/ kali-rolling contrib main non-free

#deb cdrom:[Debian GNU/Linux 2017.1 _Kali-rolling_ – Official Snapshot amd64 LIVE/INSTALL Binary 20170416-02:08]/ kali-rolling contrib main non-free
deb http://http.kali.org/kali kali-rolling main contrib non-free
deb http://security.kali.org/kali-security kali-rolling/updates main contrib non-free
deb http://http.kali.org/kali kali-rolling main contrib non-free
deb http://security.kali.org/kali-security kali-rolling/updates main contrib non-free
deb http://http.kali.org/kali sana main non-free contrib
deb http://security.kali.org/kali-security sana/updates main contrib non-free

Categories: Etc

14GB pen drive lost space

June 10, 2017 Leave a comment

Insert pen drive in usb port and follow following command.

cmd
diskpart
list disk
select disk 1 (Careful! Choose the correct number here. See note above.)
list partition (Inspect the results to double-check this is the right disk)
clean
list partition (There should be none)
create partition primary
list partition (There should be one)
format fs=fat32 quick
list partition (There should still be one)
exit

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.
>db.dropDatabase();

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

First, we can create empty collection
>db.createCollection(‘test’);

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.
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});

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
>db.testtable.insert({‘name’:’yajuvendra’},{‘name’:’yaj’});
Multiple document
>db.testtable.insert([{‘name’:’yajuvendra’},{‘name’:’yaj’}, {‘name’:’yaju’},{‘name’:’yajkumar’}]);

Select document-
Select all document
>db.testtable.find();
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();
Output-
+—————-+
| user() |
+—————-+
| root@localhost |
+—————-+
1 row in set (0.00 sec)

#Select Mysql Version
mysql bin folder>select version();
Output-
+———–+
| 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();
Output-
+———————+
| 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();
Output-
+—————-+
| 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

VIEW
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};

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

View:
mysql>show triggers;

Drop:
mysql>drop trigger {trigger name};

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

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

View:
mysql>show procedure status;

Drop:
mysql>drop procedure {procedure name};

STORED FUNCTIONS
Create:
mysql>delimiter //
mysql>create function {function name}({parameter name} {data type})
returns {data type}
begin
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/vnd.ms-fontobject “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

%d bloggers like this: