Monday 27 January 2014

Testing Screen Size [Type] While designing with bootstrap


While designing webpage with bootstrap 3, you can add an extra `row` to check that what kind of screen you are using now. Add the following html but don't forget to remove when you complete you design.


<div class="row">
  <div class="col-lg-4 col-lg-offset-4 visible-lg">LG</div>
  <div class="col-md-4 col-md-offset-4 visible-md">MD</div>
  <div class="col-sm-4 col-sm-offset-4 visible-sm">SM</div>
  <div class="col-xs-4 col-xs-offset-4 visible-xs">XS</div>
 </div>


This code will display which screen are you using now. For example if you are on large screen, it will display `LG`, on medium screen it will display `MD` , on small devices like Tablets, it will show `SM` and on Extra Small devices like Mobile phones screens it will display `XS`

Thursday 23 January 2014

Importing mysql database in wamp using mysql command line


For big databases it is usually good practice to import it using command line. Most of the times you will face problems while importing databases with php my admin.

Following is a step by step procedure to import database with command line.

1) Start wamp server and click on tray icon (windows). Icon is located at bottom-right near the computer clock.

1.1) You need to create an empty database. Use following command to create a new database

create database database_name.

e.g. : create database my_database

2) Go to mysql and select MYSQL Console and switch to your database with the following command

use my_database;

3) //this step is for your own convenience.

Copy your database file (remember not the zip file, but the text file. If you have backup in zip format, first extract it.)

4) Go to MySQL shell and type the following command

mysql> source path_to_your_sql_file

For example , file is laying in C:\

so type the following command

mysql> source C:\db_backup.sql

Tuesday 21 January 2014

MongDB Query with DBRef



General syntax for mongodb find query is 

db.collection.find({<here comes the find conditin>})

for example : if i want to find a student with email address student@email.com , query will be like

db.students.find({"email":"student@email.com"})

where students is a collections. 

Now let us say this student belongs to a certain group and we want to find all students of the group to which the said student belongs. We will be using the DBRef for that group, following will be our query

db.students.find({group:DBRef("groups", ObjectId("52a852a844aeb67db4a3518b"))}).pretty()

this query will finds all student who belong to group with object id = ObjectId("52a852a844aeb67db4a3518b")