Setting background image of webpage using CSS

I am a developer and designing mainly CSS takes hell out of me. So even to do a small things like setting background image of web page takes lot of effort of me. I am working on an application and using Twitter Bootstrap for the designing purpose. I had a requirement to set background image using bootstrap. In this post I am sharing how can you do that? I know for many of you it may be super easy or may have better way to do. I am sharing this tips for developers like me who does not have any idea how CSS and bootstrap works.


body {
     margin: 0;
     background: url('bg5.jpg');
     background-size: 1440px 800px;
     background-repeat:no-repeat;
     display: compact;
}

I have put image in the root folder of application. I hope this quick tip may help you. After setting this application looks like,

clip_image002

Thanks for reading.

Convert List to List using ConvertAll in C#

I see many developers convert one list to another list using foreach. It is ok and get the job done but there is better way to convert one list to another list using ConvertAll();

Just to explain you scenario better, let us assume you got two classes as below. InternalStudent class is representing Student class internally in the project and this is not supposed to be exposed in Service etc.


public class InternalStudent
    {
        public string IName { get; set; }
        public int IAge { get; set; }
    }

Another class is Student


  public class Student
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }

Now you have List of InternalStudents as below,


List<InternalStudent> lstInterStudent = new List<InternalStudent>
            {
                new InternalStudent {IName="dj",IAge=32},
                new InternalStudent{IName="pinal",IAge=36}
            };

Requirement is to convert List<InternalStudent> to List<Student>. Usually we convert one list to another list using foreach as given below,


List<Student> lstStudent = new List<Student>();
foreach(InternalStudent s in lstInterStudent)
            {
                lstStudent.Add(new Student
                    {
                        Name = s.IName,
                        Age = s.IAge
                    });
            }

There is no problem as such in this way of conversion from one generic list to another generic list. However there is better way to do this conversion.


List<Student> lstStudent = lstInterStudent.ConvertAll(x => new Student
                {
                    Age = x.IAge,
                    Name = x.IName
                });

We are using ConvertAll to convert one generic list to another generic list. I hope you find this post useful. Thanks for reading.

Problem starting mongoDB server on Windows 8? Resolved

Everyone is loving NoSQL and mainly MongoDB. I thought to start getting my hand dirty on this. So to start with downloaded MongoDB for Windows and installed it. So far so good.

Next I browsed to MongoDB folder. To start server typed mongo.exe command. Oops encountered following error that could not connect to server.

clip_image001

Okay so to start using mongoDB first we need to start mongoDB server. That can be done as by using command mongod. So I tried starting mongoDB server using mongod command. Oops again I got following error which clearly says dbpath does not exist.

image

So let us go ahead and create a folder data\db. We are free to create this folder at any location. However later this folder location should be set with dbpath for mongoDB.

clip_image006

Once data folder is created we need to set dbpath which can be done as follows,

clip_image008

It will take some time to get this command executed. You will notice that there is no error encountered.

Command prompt should stopped at

clip_image009

Next launch another command prompt and type command mongo.exe

clip_image011

Here you see mongoDB is connected to database test. To test successful installation, let us insert one record in test database. To insert command is db.test.save(jsonvalue) where test is your database.

clip_image013

After doing these steps mongoDB is installed successfully on your Windows Machine. I hope this post is useful. Thanks for reading.