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

Saturday, 2 June 2012

html links



http://www.html5rocks.com/en/tutorials/forms/html5forms/

http://www.99lime.com/elements/

http://www.the-art-of-web.com/html/html5-form-validation/


html to haml

1. Install this: http://rubyinstaller.org/
2. Click “Start Command Prompt with Ruby” on the start menu.
3. Run gem install haml on this prompt.
4. Run haml path\to\input.haml path\to\output.html on this prompt to compile a Haml file to HTML


jquery

Some other Links

ROR BASICS:


http://rigaux.org/language-study/syntax-across-languages-per-language/Ruby.html
http://www.troubleshooters.com/codecorn/ruby/basictutorial.htm#_Loops
http://www.tutorialspoint.com/ruby-on-rails/rails-introduction.htm
http://slideshow.rubyforge.org/ruby19.html#
http://rails.nuvvo.com/lesson/6372

RUBY VALIDATIONS:

http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html
http://guides.rubyonrails.org/active_record_validations_callbacks.html
http://ramesh-rubyonrails.blogspot.in/2007/10/validations-in-rails.html

MYSQL COMMANDS:

http://www.pantz.org/software/mysql/mysqlcommands.html
http://www.gieson.com/school/mysql/index.html

ACTIVE RECORD ASSOCIATIONS:

http://guides.rubyonrails.org/association_basics.html
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

QUERIES IN RAILS:
http://guides.rubyonrails.org/active_record_querying.html

AJAX WITH RAILS:

http://oldwiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters
http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/periodically_call_remote

ROR SESSIONS:
http://rails.nuvvo.com/lesson/6376-action-controller-verification

JAVASCRIPT DIFFERENT APPLICATIONS:
http://www.fabulant.com/fast/o_newscripts.html

RUBY ON RAILS OPEN SOURCE PROJECTS:
http://www.webresourcesdepot.com/23-amazing-and-open-source-ruby-on-rails-
applications/

RENDER TAG LINK:
http://guides.rubyonrails.org/layouts_and_rendering.html

Sample application url:
http://www.webresourcesdepot.com/23-amazing-and-open-source-ruby-on-rails-
applications/

css:
http://www.css3.info/


blogs regardin gruby:

http://rails-savvy.blogspot.in/

http://rubyonrailsqa.blogspot.in/2011/03/command-in-rails.html

http://php-ajax-javascript.blogspot.in/

http://allquestions.co.in/


screen share:

http://www.mikogo.com

download and share the session with partner-enjoy!!!! 



Important Links Regarding Ruby

Main:
http://guides.rubyonrails.org/getting_started.html

http://ruby.railstutorial.org/

http://rubymonk.com/


http://www.tutorialspoint.com/ruby/ruby_overview.htm



For-Newbies(with Video):
http://net.tutsplus.com/sessions/ruby-for-newbies/



Extra


http://www.troubleshooters.com/codecorn/ruby/basictutorial.htm

http://rubylearning.com

http://books.google.co.in/books?id=jMCO096qlRsC&pg=PA33&dq=how+to+write+ruby+script&hl=en&ei=y07KTfeuG4LtrQfw7sGaBQ&sa=X&oi=book_result&ct=book-thumbnail&resnum=3&ved=0CHEQ6wEwAg#v=onepage&q&f=true

http://www.fincher.org/tips/Languages/Ruby/





Working wit time zone:
http://www.elabs.se/blog/36-working-with-time-zones-in-ruby-on-rails








ROR

rails guide

ruby tutorials point

ruby learning

Ruby the Right Way

ruby detail notes

Invention And Basic of RUBY (IMP)

ROR INstallation

MAC ADdREss

RuBY HiStoRy & InForMation

Action Mailer Basics

API RUBY IMP

ruby RUBY

session and LGOIN MANAGEMENT

QuarkRuby: Sessions and cookies in Ruby on Rails

Action Controller: Session - Ruby on Rails

Closing the browser should actually clear the session variables an ASP.net session id - Stack Overflow

CLEARING SESSIONS

want to destroy session on browser close for logout - Ruby on Rails: Talk | Google Groups

Using Xming, a free X-server for Windows, to connect via SSH tunnels | tjansson.dk

CloudSpokes

matt-beedle.com

Find Records with Datetime that match today's date - Ruby on Rails - Stack Overflow


To install rvm

http://blog.sudobits.com/2011/10/27/how-to-install-ruby-on-rails-in-ubuntu-11-10/
http://www.the-tech-tutorial.com/?p=1868

Dynamic form creation:
 form builder - http://www.wufoo.com/


Ruby organization - for methods ....
http://www.ruby-doc.org









creating charts
http://googlevisualr.herokuapp.com/


Api-s

jQuery
http://api.jquery.com

rails-
http://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001706


http://api.rubyonrails.org

http://lettersrb.com/

picture upload
http://railsforum.com/viewtopic.php?id=4642


sublime editor installation:
http://www.technoreply.com/how-to-install-sublime-text-2-on-ubuntu-12-04-unity/

hashes 
http://blog.devinterface.com/2011/02/ruby-enumerables-operation-on-hashes/