Author Archive

Linux – basic commands

Linux is the most used Operating System for servers and the feature that is most fascinating is Command Line. Command Line is a program that is used to run commands and system interpret these commands. Here are some beginner commands that a new Linux user can use in his learning. In Linux file name and

Linux – SSH using Terminal via Port

If we have to connect to a remote server using SSH then we can do it using following command. Suppose we have remote server IP as 11.111.111.11 and username as root ssh root@11.111.111.11 If we need to specify some port then we can do as under. suppose our port number is 2233 ssh -p 2233

Yii Framework- Creating hidden field

In Yii framework we can create a hidden field using model and without model as described below 1. Creating hidden field without model. echo CHtml::hiddenField('name' , 'value', array('id' => 'name')); 2. Creating hidden field with model. echo $form->hiddenField($model, 'name');

mongoDB – Foreground Index Vs Background Index

Foreground Index Vs Background Index By default an index in MongoDB is Foreground index and while an index is a foreground index it will block all other writers (i-e no other process can write to collection), We can build it in background so that it will not block other writers. Foreground Indexes are 1. Fast

MongoDB – Sparse Index

We can create indexes on a collection’s fields but what happens when we are creating an index and that key is not present more then one document in that collection. Suppose we have a collection with following documents 1. {a:1, b:2, c:3} 2. {a:1, b:2} 3. {a:1, b:2} If we create an index on c

MongoDB – Unique Index

MongoDB allows us to specify a unique constraint on an index. These constraints  will prevent an  application from inserting documents that have duplicate values for the inserted fields. Suppose we have  a collection named  things in a database stuff. db.stuff.things({"a":"apple"}); A unique index can be created by following command. db.students.ensureIndex({student_id:1, class_id:1}, {unique:1}); The _id index

MongoDB – Multikey Indexes

In MongoDB we can have a key that holds an array  like {interests: ["swimming", "reading", "programming"]}, {"sports":["tennis","gym"]} We can have an index on interests key. like (suppose we  have a people collection and interests field in it) db.people.ensureIndex({"interests":1}); MongoDB will create an index for every item in the  array like for swimming, reading, programming. If

MongoDB – creating and viewing indexes

According to definition from Wikipedia , A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and the use of more storage space to maintain the extra copy of data. Indexes are used to quickly locate data without having to

PHP – Create folder and a file in the folder

I worked on a project in that project we have to create folders and then files in that folders. is_dir is a function that checks whether a directory exists or not.  mkdir creates a driectory, file_put_contents is a function that create file and places   contents in that file. Following the example code. if(!is_dir("files")) mkdir("files"); $file_name

MongoDB – Insert, Update, Delete and Read

MongoDB stores data in form of documents  are JSON like key – value pairs.