Archive for the ‘Windows’ category

How to recursively remove .svn directories

July 23rd, 2009

Regular readers may have clocked onto the fact that I use Subversion. Well the way it works it to keep a hidden set of directories within your checked out repository. It uses this to track any changes etc.. Each directory is called ‘.svn’ and is within each and every directory and subdirectory you have.

The problem

Now I know I am not alone in saying that when you want to upload the files to a remote server you have to do one of two things

  • Upload the files and .svn directories to your server which is likely to take twice the time and twice the disk space
  • Make a separate local copy of your files and then remove the .svn directories one by one.

I prefer to take option two although in recent months I have taken on the former through sheer laziness. I decided to look for a solution and found my answer…

The answer

For windows machines you need to create a secondary copy of your files to upload, this means it won’t wipe out your local repository files (the ones you want to keep). Next, create a ‘.bat’ file (batch file for executable scripts). The simplest way to do this is to open notepad and doing File > Save as > remove_svn.bat after copying in the code below. It needs to be saved in the root directory of your repository copy. This is important if not it will recurse all directories below the one it is placed in.

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
  rd /s /q "%%i"
)

I have done all the hard work for you on this one.
Just click the following link:
Remove SVN Files (Windows) (82 bytes)

For Macs and other Unix based machines you need to do something similar. This time we simply run a command on the shell (or create a shell script out of it). Again this must be placed in the directory you want to recurse through.

find . -name .svn -print0 | xargs -0 rm -rf

The Credit

Credit for these snippets goes to the following sites. Whether they were the original authors or not I don’t know but credit where credit is due etc..

Mac version – http://snipplr.com/view/201/remove-all-svn-directories/
Windows Version – http://bluespark.tumblr.com/post/23853870/remove-svn-subfolders-on-windows-xp-vista

Changing a Microsoft Office Product Key

April 21st, 2009

I just had a problem at work whereby the version of office installed in the last 30 days needed activating and the product key was not working. Luckily we have several Office keys sitting in the server room so I set about trying to change the key on the machine without having to reinstall. This means you don’t need to uninstall/reinstall Office which will take half an hour. This took me 2 minutes :)

After a short Google search I came across a Microsoft article that told me exactly how to do it. Here are the steps I took:

  1. Close any Microsoft Office Applications
  2. Open the registry (Start -> Run -> regedit)
  3. Find the appropriate office installation key under  HKEY_LOCAL_MACHINE \Software\Microsoft\Office followed by your version
    • Office XP ->…\10.0\Registration
    • Office 2003 -> …11.0\Registration
    • Office 2007 -> …\12.0\Registration
  4. In one of the subfolders you will see a product name field. Select the subfolder with your Office name in it (IE: Microsoft Office 2003)
  5. Delete the following key names:
    • DigitalProductID
    • ProductID
  6. Close the registry (no need to look for a save button, there isn’t one!)
  7. Open up any Office Application and you will be prompted for your product key and then to activate.

Thanks to Microsoft for writing a clear and concise how-to for a change without referring you to various knowledgebase articles. I used the following site for reference: http://support.microsoft.com/kb/895456

Subversion server sertup and configuration for dummies

March 7th, 2009

For those of you that don’t know what it is, Subversion (or SVN for short) is a popular open source version control system used all over the world. Previously people have used other systems like CVS however SVN seems to now be the standard. Firstly here is a little information about clients, skip past it for the server section.

Clients

An SVN client is (obviously) a piece of software that allows you to interact with a central ‘repository’ (or repositories if you work on version controlled files from multiple sources). They facilitate communication and interaction with the SVN server, actions like ‘checking out’ repositories, ‘committing’ your changes and ‘merging’ in other people changes to your own local copy.

This might be a little basic for this tutorial so I shall move swiftly onto client software. The Subversion project is hosted by tigris.org who release the source code for Subversion itself. Volunteers port the code onto different platforms. I can only recommend the software I have used to they are as follows:

  • TortoiseSVN – A free and very popular windows client with Explorer integration
  • SCPlugin – A free, yet buggy, Mac client whose advantage is integration with Finder
  • Zigversion – A Mac client which is free for personal use. No Finder integration (to my knowledge)

Server

This section will detail how to install and configure a Subversion repository on a Unix based system. It assumes that the ‘yum’ package is installed however for those of you who don’t have it or are unaware of what it does then please read Valerie Aurora’s Linux Basics guide where there is a helpful section called ‘Finding and Installing Software’.

First things first, install subversion and its dependancies using yum. This is a nice one liner to get the job done for you.

yum -y install apr apr-utils http-devel mod_dav_svn subversion

Yes it was that easy! One command just installed Subversion and it’s dependancies (let me know if i have missed any). The next thing to do is configure a new repository and setup access using htaccess.

The first thing to do is to create a new repository. For this tutorial I will be using ‘/usr/local/svn’ as a place to store repositories however you can put it anywhere you like on the file system.

Firstly, create the directory ‘svn’ using the mkdir command (within /usr/local/ :) ) and then chown it recursively to apache:apache. Move into it and use the following command to set up your first repository (which in this case is called test but obviously it can be anything you choose):

svnadmin create test

The above install process also adds a new config file into the apache conf.d directory (/etc/httpd/conf.d/). The config file is called subversion.conf, within which is an example block to uncomment to set up http access to the respository and set up htaccess permissions.

The most basic example of what to put in this file is below. It will set up a virtual subdirectory of your website so try to either make the name unique or not use the name on any of your sites on the same server. This example will set up a subdirectory called ‘svn’ so if your site is http://127.0.0.1 then your Subversion path will be http://127.0.0.1/svn

<Location /svn>i
	DAV svn
	SVNParentPath /usr/local/svn
</Location>

After making any changes to this file (and any file served by apache for that matter) then you must restart apache for them to take effect. You can then view your repository in your browser and assuming you see a blank page with something that resembles ‘Revision 0:’ or the name of your repository as a link then you are ready to start using it.

For those that run multiple sites using VirtualHost directives then the above section of code can be included within one as per the example below which should create access to Subversion on a site named ‘svn.localhost’.

<VirtualHost *:80>
	DocumentRoot /usr/local/svn
	ServerName svn.localhost
	<Location /svn>
		DAV svn
		SVNParentPath /usr/local/svn
	</Location>
</VirtualHost>

Access Control

You may want to configure access to your repository allowing only certain people and groups to have different levels of access. Subversion allows a couple of ways to do this but the most common seems to be htaccess. Configuring this is more or less the same as configuring htaccess. See the example below:

AuthType Basic
AuthName "Subversion"
AuthUserFile "/etc/httpd/conf.d/svn_passwd"
Require valid-user

The above 4 lines can be slotted in beween the ‘<Location>…</Location>’ tags. It tells Apache not to allow access to anyone except those that have their crudentials within a file (in passwd format) at the location specified. The ‘AuthName’ line is optional, all it does it put a name onto the box that pops up asking for login information.

The file that I have called svn_passwd can be situated anywhere on the system however it would be sensible NOT to put it anywhere that can be served by any of your websites. Generate the ‘svn_passwd’ file using the following command if it doesn’t already exist.

htpasswd -cm /etc/httpd/conf.d/svn_passwd admin

You will then be prompted for a password for the user and once entered (twice?), after Apache has been restarted you won’t be able to get access to your repositories without those details. The name of the user you choose for this doesn’t have to be a system user and if it is (like admin for example) then the password you use doesn’t have to match its counterpart.

After restarting Apache again you will be only be able to access your repository with a correct set of credentials defined in the htpasswd file.

That concludes the tutorial for now. I hope that I have given you a good round knowledge of Subversion server setup which in turn will enable you to easily run your own version control system. There will likely be snags along the way, there always are. If in doubt then Google it! or ask me (who will likely Google it anyway :) )

Resources

http://svnbook.red-bean.com

Windows XP Update Popup

January 5th, 2009

The windows update popup has lost me hours of work for the last time!

Please Restart... Please Restart... Please...

Please Restart... Please Restart... Please...

Ok.. so that may be a little over the top, maybe minutes of work but it’s still irritating losing all of the windows I have spend days opening and lovingly arranging. After the umpteenth popup of the day I thought I would Google the answer to turn off this unwanted menace.

I found a site that told me exactly the answer I was hoping for and I was popup free in under 5 minutes. The depressing thing is that it was written in 2006 and it took me nearly three years to build up the inclination to do something about it.

So here’s how to do it:

  • Click on the Start button and choose ‘Run.’
  • Type: gpedit.msc.
  • Expand Local Computer Policy, Computer Configuration, Administrative Templates, Windows Components, Windows Update.
  • Select “Re-prompt for restart with scheduled installations.”
  • Choose “Enable” and then type in how many minutes you want to wait.

I do feel it necessary to put a little disclaimer in here, gpedit is not something that you should really go playing with and I imagine you need to be an administrator on the machine (most home computers are set up so you are the admin) to make the change

I got this handy hint from Tech Target however you are bombarded with advertising as you enter the site. you have been warned.