Archive for November, 2011

Simple Terrain in Unity 3D

Simple Terrain in Unity 3D

It’s boring to debug the same code again and again. So i decided to try something out of the box this time. Finally end up in doing something in Unity 3D. Well You may or may not aware of Unity 3D.

Unity 3D is a game engine to create 3D games with sizzling graphics. But the interesting thing about Unity is it’s freaking easy to handle. Scripting in unity is also not complex. Unity supports JavaScript and C# as scripting languages. And the more interesting part is 1 design to multi platforms. You can publish your game design to run on various platforms like Android, iPhone, PC, Mac and Web.

Fascinating!!!  isnt it ? :)

Here is my simple demo.

Take a look at the image gallery of the terrain.
[nggallery id=1]

November 14, 2011 1 comment
Nikon L110 Battery Exhaustion Fix

Nikon L110 Battery Exhaustion Fix

I got a  problem with my Nikon L110 camera. This camera operates in 4 AA batteries. But I hardly managed to shoot 20 pics with flash with a fully charged battery set. Finally fixed this issue. Here is the fixes,

  • Make sure you selected the correct battery type in the menu.
  • Update the firmware of the camera to the latest version. Step by step instruction to update the L110 firmware is available here.
Hope this helps. :)
November 9, 2011 0 comments
Mongo DB & C# – Fun and Fun Only

Mongo DB & C# – Fun and Fun Only

MongoDB, As I said in my title it’s just fun to deal with. Believe me you also will say the same at the end of this post. So let’s go into NO SQL World.

What is No SQL ?

No more sql here pls. This is a world without SQL. So how to perform operations with db ?. Follow with me……

What is Mongo DB ?

Mongo DB is a NO SQL Database server. Most of the popular programming languages got drivers to connect and play with Mongo. No SQL is a new world of storage. You don’t find any tables or rows to store your data. So How ? There is a different representation to store data. We don’t have tables anymore but we have something called collections. We don’t have Rows or Records anymore bu we have something called documents. Basically if you want to store a bunch of contact details, you first create a ‘Contacts’ collection and store each contact detail as a ‘Contact’ document.

Let’s get started!!!

Downloading Mongo DB

1 ) Take a quick look in to Quick Start Guide to install the DB.
2) It’s good to install as a Windows service. Execute the following command to install as a windows service.

D:\mongodb\bin>mongod –dbpath D:\mongodb –logpath D:\mongodb\log.txt –install

3) Start the service.
4) Download C# Driver from the following location.

     http://github.com/samus/mongodb-csharp/tree/master

There are several drivers available for C#. I’m going to use this one in this tutorial.

Connection to DB with C# Driver

Create a new C# project (Console Project) and add reference to C# Driver you already downloaded.

Mongo mongo = new Mongo(ConnectionString);
mongo.Connect();
IMongoDatabase db = mongo.GetDatabase("Test");

That’s it. We Connected to DB called ‘Test’.

Let’s say which collection we are going to use.

IMongoCollection Contacts = db.GetCollection("Contacts");

Well, we also said we are going to use Collection ‘Contacts’.

Now we need to insert a new Record. Oh Sorry ! No more records. We need to insert a ‘Document’.

   Document doc = new Document();
   doc["Name"] = "John";
   Contacts.Insert(doc);
   mongo.Disconnect();

So now we inserted a document with a ‘Name’ property. The cool things about NO SQL DB and Documents is it’s schema free. Now we can insert another document to the same collection with another property called ‘id’ or something.

Full Source code of the above example would look like

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MongoDB
{
    class Program
    {
        static void Main(string[] args)
        {
            Mongo mongo = new Mongo();

            mongo.Connect();

            IMongoDatabase db = mongo.GetDatabase("Test");

            IMongoCollection Contacts = db.GetCollection("Contacts");

            Document doc = new Document();

            doc["Name"] = "John";

            Contacts.Insert(doc);
            mongo.Disconnect();
            Console.WriteLine("Inserted");
            Console.ReadLine();

        }
    }
}

Using Connection String

You also can use connection string to connect to a specific Mongo DB server.

string ConnectionString = "YourConnectionStringHere";
Mongo mongo = new Mongo(ConnectionString);

Mongo DB Hosting

There are several mongoDB hosting services available. https://mongohq.com/home is a good service which has a free star up package to test MongoDB Application. You can use connection string to connection to these Hosted MongoDBs.

November 8, 2011 1 comment