Wednesday, March 17, 2010

HowTo: Remove recursively all the ".svn" from a directory

Most of the times when you are working on a project you need to collaborate with other people, or you want at least that if your computer crashes not to loose all your work.
In this case it is essential to work with some sort of version control system. Nowadays the most important versioning systems are CVS, SVN and GIT.

In my case the choice is most of the times subversion(SVN) because of its simpleness, its seamless integration into the Eclipse framework due to "SubClipse" and because there are thousands of free SVN-hosts around, of which Google Code is probably the most well known.

This works (more or less) fine and should not be the topic of this post. The problem starts when you want to give your work away without disconnecting from your repository. If you just copy your project and (zip it and) send it to someone else you'll probably send all the ".svn" staff hidden into each folder of your project, and in a reasonably big project this could be even more than 100, which makes it unfeasible to do this work by hand.

For all the Unix users, like the Linux guys and the Mac guys, there is a really simple solution using the terminal. The following command finds recursively all the ".svn"'s in the subtree you are launching the command including "." (Find, starting from "." all directories who's name is ".svn")
find . -type d -name .svn
this command can now be passed to the remove command (rm)
rm -rf `find . -type d -name .svn`
The flags in this case tell to the "rm" command
  • -r --> recursively (all the sub(folders|files))
  • -f --> force (do not ask for confirmation, just delete)

If you are not an experienced Unix user be careful with the "rm" command in combination with these two flags, they could remove your entire system when used in the "right" way :-P

Sunday, March 7, 2010

JavaScript-Engine in a Java program

Some days ago I was experimenting on an easy way to evaluate a calculation saved within a String variable of my program.
After some searches and a very useful hint I finally found the Java "ScriptEngineManager" introduced in Java 6 (JavaDoc). This engine is a very useful extension to the Java programming language as it allows to natively import the functionality of (in this case) JavaScript (documentation).

With this knowledge I wrote this simple test-program to show the possibilities of this technology:

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;


public class ScriptTest {


  public static void main(String[] args) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
  try {
  Number ret = (Number) jsEngine.eval("10 + 5 * (2 +3 *6)");
  System.out.println(ret.doubleValue());

  Boolean ret1 = (Boolean) jsEngine.eval("100 >= (6*5)");
  System.out.println(ret1.booleanValue());

jsEngine.put("Hallo", "Servus");
String ret2 = (String) jsEngine.eval("Hallo");
System.out.println(ret2);
} catch (ScriptException ex) {
ex.printStackTrace();
}
}
}

Monday, March 1, 2010

Microsoft Office 2007: "This copy of Microsoft Office is not genuine"

Some time ago Microsoft published an Update named "Office Genuine Advantage (KB949810)".
This update causes some Versions to display a message like the one below:
This copy of Microsoft Office is not genuine.


Please excuse this interruption. This copy of Microsoft Office did not pass validation. Click Learn More for details and for help identifying the best way to get genuine Microsoft Office.
When your Office shows a message like this it means that the version you are using is indexed by MS as stolen or unauthorized copied.
Of course there exist several reasons why this could happen; either someone copied your serial and published it in some strange forums, or you have bought your PC with MS Office pre-installed and the first owner still uses its version, or you simply downloaded it from somewhere.

There exists a very simple solution to come over this problem, and if you have not stolen your copy feel free to use this solution in order to remove this annoying pup-up.
  1. Close Office completely
  2. Go to C:\windows\system32
  3. Locate the following three files:
    OGAAddin.dll
    OGACheckControl.dll
    OGAEXEC.exe
  4. Rename all of them into *.old to obtain
    OGAAddin.dll.old
    OGACheckControl.dll.old
    OGAEXEC.exe.old
  5. Re-run Office
  6. (delete the *.old files)
Now the pop-up doesn't show up again and you can use your copy as before the update

Golang setup PATH

Quite recently we startet in the company to use and write some Go programs. I love Go. It's easy to learn, read and modify. One of the m...