Tuesday, 3 July 2012

Fang of Mongo Installation



Ubuntu 10.10: - requirements:  
  $sudo aptitude install python-setuptools mongodb python-django python-pymongo

if not getting installed
- install sudo aptitude with 

$ sudo apt-get install <selected package>
"aptitude" can be your selected package*

then try to install the above command.

installation of Fang of Mango:

  • download archive and unpack into directory of your choice
    after downloading, open console, cd to directory where the files are and type:
    $cd fangofmongo
    $python ./manage.py runserver
    now point your browser to http://localhost:8000/fangofmongo/ and enjoy

    If any error raises at running server regarding time
    ex:raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)  
    try whether the timezone present in the /usr/share/zoneinfo/  directory.. 
    if the time zone is not present then go to fangofmongo extracted directory and open form/settings.py   change the TIME_ZONE = 'America/North_Dakota'  (America/North_Dakota) these should be in your "zone info"  .
    After completing the installation.... try to run the last command. your localhost:8000.
    if still your db is not getting retrieved.. having a problem with --
    error:AttributeError("'module' object has no attribute 'binary',").
    then update your fangofmongo/fom/views.py as follows:
    go to this link and make this changes as shown...
    https://github.com/JeffAMcGee/Fang-of-Mongo/commit/202fd95b5a6558fc60d85bd94ec6a9c6a3c14a2e#diff-0
    these are the probs i faced and got solved and now working fine..
     Enjoying with Fang of Mango.... :)



Saturday, 23 June 2012

Mongo db Quieries


Here is the some important frequently used mongodb queries.
After running mongodb server(mongod) and  interactive shell(mongo),  Our’s first command should be
1. help
->Which will show a lot  of useful command that is helpful at any instance working with mongodb.
2.db.help();
->It is database level help command that will show some of data level command.
3. db.help;
-> This command will show database level methods.
All above command is basic mongodb command.
How to create database?
show dbs; to show all the databases...
show collections; to view all the table in db...
1. use databasename;
In my case it is “use mongotest”,  here USE  is command to create database and  mongotest is database name. It is one of the nice feature of mongodb if there will be no database with this particular name, will create new database else use(move) to exiting database.
 Create table!!!!!!!
1. db.tablename.save({“name”:”ankit”,”phone”:”09533667506″});
Fetch data from tables!!!!!!!!!!
1. db.tablename.find();
return data of table.
2.db.tablename.find;
return methods it self.
Create another record!!!!!!!!!
x={“name”:”abhay”,”phone”:”09932329856″}
db.contacts.save(x);
this is another way of creating new record and saving as an object.
Fetch particular record from tables !!!!!!!!!!
db.contacts.find({“name”:”ankit”});
N.T. -> Search option is case sensetive.
find record using id
> db.contacts.find({_id:ObjectId("4ea3aa28eaaf3871b0549dfa")});
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506" }
Update particular record into tables !!!!!!!!!!
-> there is two way to update table
1. Using save()->this is one of nice feature to mongodb, if there will already row in table it will update with new attribute else will create new record.
2. Using update()->will only update exiting record.
find record using object
> x = db.contacts.findOne({"name":"ankit"});
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506"
}
Now we have object x with reference of contacts table.
> x
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506"
}
Now i am going to add new attribute email
> x.email = "ankit@gmail.com"
ankit@gmail.com
Let's see updated row 
> x
{
        "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
        "name" : "ankit",
        "phone" : "09533607506",
        "email" : "ankit@gmail.com"
}
Now we fetch details from table
> db.contacts.find();
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506" }
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"),
 "name" : "abhay", "phone" : "9932326589" }
table is not updated here, we need to update table.
> db.contacts.save(x);
Now try again
> db.contacts.find();
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"), 
"name" : "abhay", "phone" : "9932326589" }
{ "_id" : ObjectId("4ea3aa28eaaf3871b0549dfa"),
 "name" : "ankit", "phone" : "09533607506",
 "email" : "ankit@gmail.com" }
Delete particular record from tables !!!!!!!!!!
> db.contacts.remove(x);
let's see row is there or not
> db.contacts.find();
{ "_id" : ObjectId("4ea3b067eaaf3871b0549dfb"),
 "name" : "abhay", "phone" : "9932326589" }
yah, this row is deleted
THAT ALL WAS THE CRUD OPERATION ON MONGODB TABLE.

Tuesday, 5 June 2012

Mongo DB


Issue the following command to install the latest stable version of MongoDB:
sudo apt-get install mongodb-10gen
When this command completes, you have successfully installed MongoDB! Continue for configuration and start-up suggestions.



Starting MongoDB

Upstart users can start the mongod process by issuing the following command:
sudo service mongodb start
All other users can issue the following command to start mongod:
sudo /etc/init.d/mongodb start
You can verify that mongod has started successfully by checking the contents of the log file at /var/log/mongodb/mongodb.log.

Stopping MongoDB

Upstart users can stop the mongod process by issuing the following command:
sudo service mongodb stop
All other users can issue the following command to stop mongod:
sudo /etc/init.d/mongodb stop

Restarting MongoDB

Upstart users can restart the mongod process by issuing the following command:
sudo service mongodb restart
All other users can issue the following command to restart mongod:
sudo /etc/init.d/mongodb restart
type "mongo" in your terminal to see the version

Monday, 4 June 2012

To install Ms Office on Ubuntu

Install Wine 1.3 from Ubuntu software center or through these commands-


Step first is installing Wine (windows emulator) version 1.3 through PPA, do following action in terminal 
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update && sudo apt-get install wine1.3
then, have your Ms office package, open the setup.exe file with terminal(wine) or
 through command-


  wine /path/to/office2007installer/setup.exe 


enjoy with your MS Office on Ubuntu!!!!!

Git hub Commands


Common Git Commands

These are most of the commands used in git.

Name and Email address

git config –-global user.name ‘UserName’
git config –-global user.email ‘User-email’

UserName : mention your username
User-email :mention your email


How to sync your work with the repository


git status
git add .
git commit –m’your description of change’
git pull –-rebase
git push
git status

How to create or recreate your local repository


git clone //servername/html$/eFormRepo .
git config push.default tracking

How to determine what has changed

git status
git diff
git diff –-stat
git log
git log --name-only --since='12/10/2009 10:41' --pretty=oneline
git log --name-only --since='12/10/2009 10:41' --
pretty=oneline>filename.txt
git gui blame cgi-bin/SoapConnect.cgi


How to clone  from particular branch

$ git clone "repo link" -b "branch_name"

eg:
 $ git clone git@github.com:gfranko/sdasdasda.selec.js.git -b sep-backup

How to get help

  git help

How to remove a file or directory


git rm filename
git rm directory –r

How to move a file or directory


git mv source_filename destination_filename
git mv source_directory destination_directory
git mv source_filename destination_filename –n (dry run)


How to handle a merge conflict


During a git pull -–rebase you encounter merge conflict.
The file
that has a merge conflict will be displayed in the error.


Open file that has a merge conflict and find the text that is in
conflict.
Git will present both sides of the conflict and it is up
to you to determine what the file should look like.
have information similar to this.
The file will

git add filename (this is the name of the conflicted file)
git rebase –-continue


Working with Branches


git push origin origin:refs/heads/vendor_interface_tracking (create
branch)
git fetch origin (bring changes)
git branch –r (display remote branches)
git checkout -–track –b vendor_interface_tracking
origin/vendor_interface_tracking (one time only per branch)
git checkout vendor_interface_tracking (work on branch)
git checkout master (back to master)
git push origin :heads/vendor_interface_tracking (remove branch)


GIT gui command

 A portable graphical interface to Gitfocuses on allowing users to make changes to their repository by making new commits, amending existing ones, creating branches, performing local merges, and fetching/pushing to remote repositories.

Enjoy!!!!!!!!!!!!!!

Rails 3