Connecting from windows to MYSQL on Ubuntu

7 11 2007

When using mysql server on ubuntu, there is a property called  bind-address in the /etc/mysql/my.cnf file. This forces mysql to only listen to localhost.

If you want to connect to mysql from a different box say windows, make sure you comment this line.

Then restrart my sql –  sudo /etc/init.d/mysql restart

Now login to mysql on comand prompt as root  - sudo mysql -u root -p
‘=Enter password

Create a brand new user with this syntax

grant all privileges on *.* TO ‘devuser’@'IP ADDRESS OF WINDOWS’ IDENTIFIED BY ‘NEW PASSWORD’ with grant option;
After this you can use a mysql client like navicat in windows to connect with user devuser, password NEW PASSWORD.

Note that when IP changes you would have to do this all over again.





Setting up Subversion in Ubuntu

30 06 2007

I recently was setting up subversion in Ubuntu. Here are the steps I went through to do this

1) I used Synaptic package manager to install subversion and apache2.I also installed RapidSVN which is a client for subversion.

2) Edit the conf file in apache

>> sudo gedit /etc/apache2/mods-available/dav_svn.conf

This file controls subversion.

THe file after changes looks like this

# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# <Location URL> … </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>

# Uncomment this to enable the repository
# DAV svn
DAV svn
# Set this to the path to your repository
#SVNPath /var/lib/svn
#SVNPath /var/local/svn
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, …).
# You need either SVNPath and SVNParentPath, but not both.
#SVNParentPath /var/lib/svn
SVNParentPath /var/local/svn

# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A “Basic Auth” section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don’t need the fine-grained control, don’t configure it.

# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the ‘htpasswd’ command to create and
# manage the password file - and the documentation for the
# ‘auth_basic’ and ‘authn_file’ modules, which you will need for this
# (enable them with ‘a2enmod’).
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd

# To enable authorization via mod_authz_svn
#AuthzSVNAccessFile /etc/apache2/dav_svn.authz

# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the ‘authz_user’
# module (enable it with ‘a2enmod’).
<LimitExcept REPORT>
Require valid-user
</LimitExcept>

</Location>

I used the option to create many repositories under /var/local/svn.Hence i

needed SVNParentPath. I also have limited to access to http as this is internal only.

<LimitExcept REPORT>
Require valid-user
</LimitExcept>

requires a valid user for all access

3) Create a user

sudo htpasswd -c /etc/apache2/dav_svn.password $username, it will ask for a password. Give something thats safe like “hello” :)

4) Create a project using svnadmin . Go to your svn root

and run sudo svnadmin $PROJNAME

5) Give apached write access to that project

sudo chown -R www-data:www-data /var/local/svn/$PROJNAME

You can now access the project like

http://localhost/svn/$PROJNAME where $PROJNAME is name of your repository.

You are set now :) Go SVN





Ubuntu - Check it out .You will be surprised

12 06 2007

I have been a linux user for many years ( early days of redhat).  I tried many distributions from Redhat, Fedora, Suse, Mandrake and simple things used to frustrate me. On one hand i would hear the linux experts go gaga over the next coolest version of linux. On the other hand me a not so advanced user would go through the repeated dejections of having tried installing Linux struggling with it and giving up.

I believe in a system where things should just work like magic. I would not have to grep this and man that to get some basic functionality.

I tried to use Linux mostly for my blog that was hosted on my server, a code repository using CVS and then tools like apache webserver. SO as you see i am a pretty primitive linux user.

Here is my linux litmus test. At a bare minimum can i do these

-  Connect to my windows box running next to it . Not that i had a need but i had heard that it was cool
- Set up updates like the windows update and install any software with ease
- Just getting the install to recognize the monitor. ( Startx syndrome)
- Can  I connect a digital camera and copy pictures
- Burn Cd’s

Till date i have had very less success in doing all of the above in the same linux distro,

Then i heard of dell installing Ubuntu from Atul and figured if Dell would use it, it must be good. And boy was i right.

UBUNTU SIMPLY ROCKS :)

I wanted the GNome desktop along with the server. And so i burnt a iso image of the server and within 15 minutes I was up and running. A month ago i had tried to install XP on the same server, but XP refused to determine my network card and kept looking for some drives which i could never figure out. And then i had to call a number to get a authorization code for Windows. Nothing of that sort in the uBuntU world.

One more command
sudo app-get install ubuntu-desktop and an hour later i was fully functional.

True to its wordIt has been one surprise after another.

Here are my litmus test results

1) Right after install i went to Places - Network and lo I was in the windows world. No samba and stuff . May it does behind the scenes but i did not have to worry
2) There is a little tool called Synaptic Package Manager. Make it your true friend. Everything under the sun is under that for installing software. Updates are shown on the computer by itself. Just click and install. I installed eclipse , mysql and skype with no issues.
3) Monitor - No issues period.
4)As soon as i connected my digital camera , a window popped up and i could import pictures with ease. Although i am yet to figure out how to browse to my camera folder and just copy what i want like i can i windows explorer.
5) Burning CDs - no problem and so was playing a movie file.

Try it , you wont be dissapointed.

IT just works - MaGic.
 





Installing Subversion on Suse

8 01 2007

Today i was involved with an install of subversion on Suse Linux. What a breeze. Took less than an hour to set up, integrate with Apache and so on.

Initially i got misled by some google articles including this on at this location. Not that accurate

But once i found out the location of the subversion docs /usr/share/doc/packages/subversion/it was just following the lines.

For those of you installing follow this instead of any google search tips. May save some time.

And just for the recods I am very impressed with Suse. I was runnign on Red hat for years. Recently i switched to Suse and use the Gnome desktop now. Wow havent things changed a lot.





Unit tests are the heart beat of your system. don’t let the beat stop!

5 01 2007

So whats the hardest part of writing unit tests beyong writing the first test.

Writing the second, third, fourth …

Another important factor is that if there are not enough tests, the developers are not having the comfort zone to make changes, refactor etc. When the trust factor on unit tests goes down, developers don,t keep it up to date and soon unit tests are just dead code never to be run again. This is seen quite often in projects today. This translates to more hours debugging, wasted down times , more cost and slip in schedules.

HEre are some symptoms that your code is dying and there is not enough active healthy test coverage. I say healthy because its not enough to just check for null values and collections, its going beyond the basics, using it as a tool to write the code that make all the difference. The code is only as good as the tests are.

Symptoms

1) It takes for ever getting even small pieces of funtionality out of the door

2) Bugs that were fixed few releases ago, keep crawling up

3) There is a resistance from developers to make any kind to change to major parts of the system.

4) Your developers work crazy hours on code and have no idea when they will get finished . The only thing they know is that they are working hard.

5) There is a blame game between QC and development. Sort of a throw it over the wall mentality. Where developers ship code to QC , QC starts finding silly defects which could have been easily found during development. The stress levels are high between the two groups. Development has the big brother mentality.

Avoiding all these are quite easy if developers are motivated and unit test culture is built into the culture of your organization. Critical to this is management support and an understanding that it takes time and money to produce good tests. This is not something that can be done in as much time as just writing code. It pays of in the long run for a health y product and goes a long way during maintenance.

It is very important to keep these tests running on every build. Continuous test integration. Running all tests every check in. ( It does not take much if the tests are structured correctly)

Unit test Category tags in NUNIT ( for example ) provide a great way to seperate unit test , integration test, long running tests and so on.

The # 1 Mantra of writing tests is Test independence. Test in every layer should run without depending on the other layer. Mock objects, Object databases, in memory databases, Test driven development can really help this cause. This process actually makes the design better and allows for better encapsulated systems that are not interdependent.

Test independence means

1) Every class / component should be testable by itself

2) When you test a class, lets say in the business layer, (that calls the database layer) , you should be able to test the business layer without the database being there ie Mock the database. These may be part of your test category Unit Test

3) The database layer ( if you are unfortunate to use a relational database) should also be unit tested. This becomes part of you Integration Category.

4) You could use a mock or a stub( Look on Fowler’s site for an excellent discussion on the difference) to test dependent layers.

5) Anything that touches a physical system like a database, file system, external systems are all Unit tests but could be treated as a different category. Many time developers treat this as integration test and dont think they have to run it at all times. its your code your team is responsible for its test health and code quality.

6) Follow the 15 - 30 minute agile coding cycle .

  • Get code from repository,
  • Work on one task at a time ( Most men are really bad at multitasking, if you are a women then may be you can work on a few at a time)
  • Write few Tests from a list of tests that you have planned to write for that task,
  • Write the Code,
  • Make the Tests pass,
  • Update code again from code repository,
  • Build and Run all the tests ( build database if needed - if it takes too much time) then run all unit tests at category Unit Test,
  • Checkin code
  • Start again

It is very tough to start walking this road of writing tests and code to support it. Its like a new years resolution to lose weight and be healthy.Not many do it, but those who do, Do live longer :)





Do you need Something refreshing

2 09 2006

I listened today to this two year old IT Conversations piece by Joel Spolsky.

http://www.itconversations.com/shows/detail207.html

If you are having some time, an MP3 player or a headset, listen to this.

Excellent thoughts. It is very different. Seems honest and has some great insights if you are trying to build a software product.