firstruby

Master ruby with us

Archive for October, 2008

GIT with branches

Posted by firstruby on October 31, 2008

In SVN,  we can create standard repository structure like,
– trunk       – current code
– branches – versions
– tags
such as we can store the code in different branches in GIT,
git push origin demo1.0
where demo1.0 – name of the branch

Posted in Blogroll, firstruby, Useful Links | Tagged: , | Leave a Comment »

Reset MySQL password on Windows

Posted by firstruby on October 26, 2008

1) Log in as Administrator.

2) Stop the MySQL service. Go to Start menu > Control Panel > Administrative Tools > Services > Stop MySQL service.

3) Create “mysql-init.txt” file with following 2 lines,

UPDATE mysql.user SET Password=PASSWORD(‘mypassword’) WHERE User=’root’;
FLUSH PRIVILEGES;

4) Open command prompt, and give following command to reset MySQL password,

“C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt” –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.0\my.ini” –init-file=C:\\mysql-init.txt

The appropriate –defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the –defaults-file setting.

5) After the server has started successfully, delete C:\mysql-init.txt

Posted in Useful Links | Tagged: , | 1 Comment »

GIT – Fast Version Control System

Posted by firstruby on October 25, 2008

GIT is distributed version control system. Following is a small stuff which may help to use GIT with our applications,

Goto root directory of the application, say my application is ‘demo’.

1. To take the code from GIT server,

bango@bango-desktop:~$ git clone <git-url>

After that, I need to change my directory to ‘/demo’.  To update the code from GIT server,

bango@bango-desktop:~/demo$ git pull

2. Once you complete the functionality, and if you want to commit the code to GIT server, then

bango@bango-desktop:~/demo$ git status

‘git status’ will show you the names of all changed files.

3. To add changed files to GIT server,

bango@bango-desktop:~/demo$ git add <path_of_the_1st_changed_file>
bango@bango-desktop:~/demo$ git add <path_of_the_2nd_changed_file>

like this, add all files.. and if you have many files and if you want to add them at a time, then

bango@bango-desktop:~/demo$ git add .

4. To commit the code to GIT server,

bango@bango-desktop:~/demo$ git commit -m “<your-message-regarding-the-functionality>”

5. To push the code to GIT server,

bango@bango-desktop:~/demo$ git push origin master

You may find more commands here…  http://www.kernel.org/pub/software/scm/git/docs/

I am using GIT with my RubyOnRails applications.

Posted in Useful Links | Tagged: , | Leave a Comment »

Import and Export Database to/from MySQL

Posted by firstruby on October 23, 2008

Small stuff about how to import and export data to/from MySQL with the help of mysql and mysqldump commands,

IMPORT database to MySQL,

D:\>mysql -u username -p password database_name < file.sql

database_name should be there in database. Put your username, password and database_name with yours MySQL information. After this command, data from file.sql will be imported to your database.

EXPORT database from MySQL,

D:\>mysqldump -u username -p password database_name > file.sql

Please replace username, password and database_name with yours MySQL information.

After this command, data will be exported to file.sql

Posted in Useful Links | Tagged: | Leave a Comment »

Access Remote MySQL database in RubyonRails application

Posted by firstruby on October 23, 2008

To give the remote access to database, on server, we have to give the following command,

mysql> CREATE DATABASE foo_development;
mysql> GRANT ALL ON
foo_development.* TO root@'192.168.1.25' IDENTIFIED BY 'PASSWORD';

where 192.168.1.25 – IP Address of the client machine,

Now modify  ../config/database.yml file in our RoR application as follows,

development:
adapter: mysql
database: foo_development
username: root
password: PASSWORD
host: 192.168.1.1

where 192.168.1.1 – IP Address of server

Posted in firstruby, Useful Links | Tagged: , | 1 Comment »