Ruben Laguna’s blog

Opensource Java

Finally Sun has released Java under GPL2 license.

Read more about it at Tor Norbye’s blog or at this digg entry.

Some highlights:

  • HotSpot VM and JavaC compiler will be opensourced under the OpenJDK project
  • SE 7.0 to be OS’ed first, SE6 to follow
  • License GPV2 a la GNU/Linux with a GNU/Classpath exception to allow linking to non-GPL code.
  • GPLv2 chosen due to popularity, compatability and protection (non-public fork not legal)
  • Possibility of eventual GPLv3 upgrade when the FSF releases it.
  • Easier to distribute runtime as well as SDK with Linux etc.
  • Commercial licence policies remain in place.

Apache JMeter Bugs

I’ve been working with Apache JMeter 2.2 mainly for JDBC benchmarks and I found a couple of bugs.

Nightly Tester Tools for Firefox 2.0

I’ve just installed the Firefox 2.0 RC1 and noticed that almost every extension/add-on I had has been disabled. Firefox 2.0 check if the extension is compatible with the Firefox version and disables it if it is not. You can force firefox to load the extension anyway using the Nightly Tester Tools. It works for several extensions like easyGestures and Blinklist toolbar. Just because Firefox 2.0 says the extension is incompatible doesn’t mean it won’t work, it only means that the extension’s developer didn’t tested it for firefox 2.0. just that.

Using GroovyMonkey to Obtain All Eclipse Icons 2

I’ve been playing with GroovyMonkey that is more or less a patch to EclipseMonkey that allows to run other languages besides Javascript.
With this Eclipse plugin you can run javascript, groovy, etc. scripts that interacts with the Eclipse API. To get an impression of what you can do with GroovyMonkey take a look to these posts (1, 2, 3, 4 ). Following those post you can make a script to download all eclipse icons from the eclipse repository. My first GroovyMonkey script generates a webpage with all eclipse icons (previously downloaded with the example scripts) to easily spot the icons.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<span class='line'>/*
</span><span class='line'> * Menu: Get Eclipse Icons > Make web page
</span><span class='line'> * Script-Path: /EclipseIcons/monkey/make_web_page.gm
</span><span class='line'> * Kudos: ecerulm
</span><span class='line'> * License: EPL 1.0
</span><span class='line'> */
</span><span class='line'>
</span><span class='line'>def findFilesinFolder(folder) {
</span><span class='line'>    def toReturn = new ArrayList();
</span><span class='line'>    
</span><span class='line'>    folder.members().each {
</span><span class='line'>      if (it instanceof org.eclipse.core.resources.IFolder) {
</span><span class='line'>         toReturn.addAll(findFilesinFolder(it));
</span><span class='line'>      } else {
</span><span class='line'>         toReturn.add(it);
</span><span class='line'>      }
</span><span class='line'>    }
</span><span class='line'>    
</span><span class='line'>    return toReturn;
</span><span class='line'>} 
</span><span class='line'>def targetProject = workspace.getRoot().getProject( 'EclipseIcons' )
</span><span class='line'>def iconsFolder = targetProject.getFolder("icons");
</span><span class='line'>def buf = new StringBuffer();
</span><span class='line'>buf.append "&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
</span><span class='line'>buf.append "&lt;html>&lt;head>&lt;title>Eclipse Icons&lt;/title>&lt;/head>&lt;body>";
</span><span class='line'>def members = iconsFolder.members();
</span><span class='line'>members.each { plugin ->
</span><span class='line'>  if (plugin instanceof org.eclipse.core.resources.IFolder) {
</span><span class='line'>	  def name = plugin.getName();
</span><span class='line'>//	  buf.append "\nh1. "+name+"
</span><span class='line'>
</span><span class='line'>\n";
</span><span class='line'>//	  buf.append "p. ";
</span><span class='line'>	  
</span><span class='line'>	  
</span><span class='line'>	   findFilesinFolder(plugin).each {arg ->
</span><span class='line'>	      def location = arg.getLocation().toString();
</span><span class='line'>	      def l = iconsFolder.getLocation().toString().length()+1;
</span><span class='line'>	      location = location.substring(l); 
</span><span class='line'>	      buf.append "&lt;a href=\""+location+"\" title=\""+location+"\"> &lt;img src=\""+location+"\" alt=\"location\"/>&lt;/a>\n";
</span><span class='line'>	   }
</span><span class='line'>	  
</span><span class='line'>	  
</span><span class='line'>//	  buf.append "
</span><span class='line'>
</span><span class='line'>\n";
</span><span class='line'>  }
</span><span class='line'>}
</span><span class='line'>buf.append "&lt;/body>&lt;/html>";
</span><span class='line'>contents = buf.toString();
</span><span class='line'>def indexHtml = iconsFolder.getFile("index.html");
</span><span class='line'>if (indexHtml.exists()) {
</span><span class='line'>  indexHtml.delete(false, true, null);
</span><span class='line'>}
</span><span class='line'>fileStream = new ByteArrayInputStream(contents.getBytes("UTF-8"));
</span><span class='line'>indexHtml.create(fileStream, false, null);</span>

If you have trouble seeing the script code try this gist

PHP Script to Update the Date in the Exif Photo Headers

When I returned from my trip to NYC I realized that the camera was set to the wrong date!. I left the camera without batteries a long time and the camera reset to year 1900. So all photos had the wrong date in the EXIF headers, with 295 photos manually correct each one was not an option. Well. I realized that all I have to do to correct the photos is take one phote see the date in that photo and substract that date from the actual date of the photo to obtain the time difference between the photos. Then I wrote a php shell script to walk over all photos and add that time difference to each photo. The script is here updatedate.zip .
Before you try to execute it you need php 5 and pel (php exif library).
But beware pel-0.9 has a bug in the PelTag.php file, so you will have to download the latest peltag.php from cvs. If you see the following error that means that you have the old PelTag.php

Fatal error: Cannot redefine class constant PelTag::XP_COMMENT in pel\PelTag.php on line 1086

And then all you have to do is to edit the update.php file and put the dates there

1
2

1
2
<span class='line'>$cameradate    = mktime(1 , 0, 0, 11, 30, 1999);
</span><span class='line'>$tripstartdate = mktime(10, 0, 0,  3,  2, 2006);</span>

the mktime format is documented here.

mktime* (hour,minute,second, month,day,year)

The command line format is

php updatedate.php xxx.jpg

and it will output to filename with the prefix “new-”. If you want to apply it to a several files then you can do

ls *.jpg|xargs php updatedate.php

Copyright © 2015 - Ruben Laguna - Powered by Octopress