Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, December 24, 2009

OOo2GD 2.0.0, now with autoupdate of documents in Google Docs :-)

Available is new version 2.0.0 of OOo2GD :-)
Biggest new thing is autoupdate of Google Docs documents/spreadsheets/presentations. It works in this way that for documents downloaded with checked Autoupdate checkbox every saving of file to this [after change] will cause update of document in Google Docs. This will work to stop OO.org.
It has some limitations, first if you edit your file on 2 computers in the same time with autoupdate mode only version saved by last of computers will be available in Google Docs.
Second if you will try to open the same document from Google Docs two times OOo2GD will autoupdate only 1st file.



To make life easier, you may default Autoupdate in config window by selecting "Default autoupdate".



We have also two new translations:
  • Czech translation
  • Hungarian translation


You can download OOOo2GD v2.0.0 from OOo2GD page in OpenOffice.org extensions repository or from project page :-)


Similar postsbeta
OOo2GD 2.2.0 - autoupdate extended ;-)
OOo2GD 2.3.0 - new documents, and autoupdate in work ;-)
OpenOffice.org2GoogleDocs 3.0.0 - uploading without conversion to Google Docs :-)
OOo2GD 1.6.0 :-)
Download your document in choosen format from Google Docs with OOo2GD 1.8.0 :-)

Wednesday, December 16, 2009

OOo2GD 1.9.1 - choose Look And Feel which you like :-)

Available is new version of OpenOffice.org2GoogleDocs, this time with version number 1.9.1.
In this version you will find one new feature, possibility to choose Look And Feel which should be used by OOo2GD user interface.

List of available Look And Feels depends on Java version, Operating System and in case of Linux, Solaris, HP-Ux and some other systems also from this which window manager is used.
After each change of Look And Feel, which you may do in config window:


You will need to close all OOo2GD windows.

To download new version go to OOo2GD page in OO.org extensions repository, or to project page.


Similar postsbeta
OOo2GD 2.1.2 - small fix
OOo2GD 2.1.0 - filtering, sorting and more *nix friendly config file names
OOo2GD 2.2.0 - autoupdate extended ;-)
OOo2GD 2.0.0, now with autoupdate of documents in Google Docs :-)
OOo2GD 2.1.1 is ready :-)

Saturday, November 14, 2009

Which language is fastest? ;-)

Update: 15/01/2010 - It seems that I made big bug in test code for C# which caused decreasing of C# results about factor 10! I assumed that DateTime.New.Ticks returns nanoseconds, but it returns ticks, and in one nanosecond we have 10 ticks... Sadly nobody looked into sources of my tests :-(
So results for C# should be divided by 10, and in this case C# is faster than Java about 3 times [but not Java 1.5 with -server switch used in this case Java is a little faster than C#].
New results for Intel Core 2 Duo T6600 2.20 GHz under 64 bit Windows 7:
C# z .NET 4.0 - 1.17 ms
Java 1.5 with switch -server - 1.096 ms
Java 1.6 with switch -server - 2.8895 ms
Python 2.6 - 10.88 ms

Recently I made tests of this which programming language gives quicker code ;-)
Of course it depends from this what this code should to do.
So I choose thing which I'm writing almost always in new [new for me] language :-)

I wrote it even during my first session, over green screen [on RS232 connection] when I was first time connected to HP-UX on my University server ;-) [or maybe not??? I'm not sure now ;-)]

This thing is simple numerical integration of function f(x)=e-x2 in range (-10,10> [when calculated form minus infinity to plus infinity result is equals to square root from Pi :-), I was really impressed when my professor showed it to us on our lecture from mathematical analysis]. Those calculations are performed in 10000 of steps, and repeated 1000 times for stable result [so we measure time of 1000 iterations from 0 to 9999] and divide result by 1000 to get information about time needed to calculate one iteration.

If you are interested in source codes of programs I wrote for those tests, please use one of those links [those are links to my blog in Polish, but you needn't be afraid ;-) you are interested only in source codes] sources for Java, Python, C, and C# [here you may find ZIP file with some of those programs], sources for JavaScript [here is a simple JavaScript tester, which will display info how long took one full iteration for calculate this numerical integration], and finally sources for Go [here you need to be warned, that this Go program should have changed one line, where math.Exp() is used, it should use math.Pow()].

And results are interesting ;-)

C++ 32bit - 0.985 ms
C++ 64bit - 1.387 ms
JavaScript from Mozilla Firefox 3.5.4 - 1.380 ms
JavaScript from Google Chrome 4.0.223.11 - 2.514 ms
Java 64bit - 3.8 ms
Java 32bit - 4.7 ms
Google Go 32bit - 8.521 (5.68) ms
Python 2.5.2 32bit - 10.3 ms
Python 2.5.4 64bit - 10.16 ms
C# 64bit - 14 ms

All tests except test for Go was performed on my 64 bit Windows 7 laptop with Core 2 Duo processor, Go was tested on virtual Ubuntu 9.10 in VMware Player 3.0 hosted on Windows 7, in case of Go first result [8.521 ms] is a result shown by test program, second result [5.68 ms] was calculated by comparing results of JavaScript from Firefox on Windows 7 and in this virtual Ubuntu 9.10.
C++ code was compiled with Visual C++ 2008 Express Edition [for 64 bits I used compiler from Windows 7 SDK, here instruction how to make Visual C++ 2008 Express Edition to use it :-)]

The biggest surprise for me was really poor result of C#, and superb result of JavaScript in FireFox :-) I still don't know why JS was so fast :-) [interesting thing also is this that FireFox JavaScript was here faster than Google Chrome JavaScript ;-)}
Result of Go wasn't so surprising, now after the premiere of this language we can here only praises, but its still experimental thing, and I used 32 bit version of compiler which isn't the best ;-) [I must also admit that after my first experience with Go I don't like it and I hope this one Google project will die].

I think that good advice after this test is ;-) If you need to write some very quick code use C++, if it must be fast but needn't to be extremal fast - use Java, and newer use C# ;-)


Similar postsbeta
Calculation of SSD life time in EEE PC
Sources of JPC - x86 emulator in Java
How to detect clickbaits?
Programmers love to over complicate...
Gouraud Shading in JavaScript :-)

Sunday, January 11, 2009

OpenOffice.org2GoogleDocs 1.4.1

New day and new version ;-) This time it is 1.4.1. In this version I fixed little and nasty problem which caused that in some rare occasions users got error Problem: no object DCH for MIME application /atom+XML instead of uploading files to Google Docs.

Problem was caused by the fact that in some cases Swing EDT thread might be started with "wrong" ClassLoader, and wasn't able to access libraries needed to contact with Google Docs. This version should fix this problem.

Download


Similar postsbeta
OOo2GD 1.5.0 - we can download spreadsheets :-)
OpenOffice.org2GoogleDocs 1.4.0
Chrome OS and Java
OOo2GD 2.1.1 is ready :-)
OpenOffice.org2GoogleDocs and Apple - first try ;-)

Sunday, December 28, 2008

OOo2GD 1.3.1

Small fix for OpenOffice.org2GoogleDocs.

From now, when user will uncheck checkbox "Remember Password" extension will remove from hard drive file with credentials.

Download.

Also small survey :-)




Similar postsbeta
Export documents to Box.net from your OpenOffice.org with OOo2GD :-)
OpenOffice.org2GoogleDocs 0.9 :-)
OOo2GD 1.4.2
OpenOffice.org2GoogleDocs 0.8.1 - fixes :-)
OpenOffice.org2GoogleDocs 1.2.1

Thursday, October 16, 2008

OOo2GD 1.2.3

After long pause I found time :-) and here it is - version 1.2.3 of OpenOffice.org2GoogleDocs.
In this version we have new translation Portuguese (Brazilian), and first try of handling CAPTCHA for Google Docs [CAPTCHA is a picture with letters which human can reads [most of times ;-)] but program can't, and Google Docs sometimes may require CATPCHA to access].

Download


Similar postsbeta
OOo2GD 1.7.0
OOo2GD 2.0.0, now with autoupdate of documents in Google Docs :-)
OpenOffice.org2GoogleDocs 1.3 beta 1 - update documents on Google Docs
OpenOffice.org2GoogleDocs 1.4.1
OOo2GD 2.3.0 - new documents, and autoupdate in work ;-)

Saturday, September 6, 2008

OOo2GD (OpenOffice.org2GoogleDocs) 1.2.2

In new version you may find two fixes, and one small cosmetic change.
Fixes:
  • for WebDAV, from now possible is uploading of files with space in name
  • for WebDAV, fixed problem with showing message "File Uploaded" when it wasn't uploaded
    Cosmetics:
  • windows with progress bar and information about uploading in progress will be placed near right bottom screen corner [on primary screen]

    Download


    Similar postsbeta
    OpenOffice.org2GoogleDocs 1.0.3
    OpenOffice.org2GoogleDocs 1.4.0
    Export documents to Box.net from your OpenOffice.org with OOo2GD :-)
    OpenOffice.org2GoogleDocs 1.2.1
    OOo2GD 1.8.2
  • Monday, March 24, 2008

    Abuse of Booleans ;-)

    Today next chapter of abusing Java internals with using of reflections ;-)
    In previous chapters we discussed problems: How many is 1+1 in Java and The Secret Life of String.

    Two of well known facts about Boolean in Java are:
    Boolean.valueOf(true) value is true
    Boolean.valueOf(false) value is false

    But how we will shown, not always ;p
    import java.lang.reflect.Field;
    public class HackBool {
    static void fixBooleans() throws Exception {
    Class boolClass = Boolean.class;
    Field field = boolClass.getDeclaredField("value");
    field.setAccessible(true);
    field.setBoolean(Boolean.TRUE, false);
    field.setBoolean(Boolean.FALSE, true);
    }

    public static void main(String[] args) throws Exception {
    System.out.println("Boolean.valueOf("+true+")="+Boolean.valueOf(true));
    System.out.println("Boolean.valueOf("+false+")="+Boolean.valueOf(false));
    fixBooleans();
    System.out.println("Boolean.valueOf("+true+")="+Boolean.valueOf(true));
    System.out.println("Boolean.valueOf("+false+")="+Boolean.valueOf(false));
    }
    }


    When we will try to execute this code we will see:

    Boolean.valueOf(true)=true
    Boolean.valueOf(false)=false
    Boolean.valueOf(true)=false
    Boolean.valueOf(false)=true


    Two first lines looks good, but what with two last? ;-)

    And what we will see after change of this code to this version:
    import java.lang.reflect.Field;
    public class HackBool {
    static void fixBooleans() throws Exception {
    Class boolClass = Boolean.class;
    Field field = boolClass.getDeclaredField("value");
    field.setAccessible(true);
    field.setBoolean(Boolean.TRUE, false);
    field.setBoolean(Boolean.FALSE, true);
    }

    public static void main(String[] args) throws Exception {
    fixBooleans();
    Boolean b = true;
    if (b) System.out.println("TRUE :-)");
    else System.out.println("FALSE :-(");
    }
    }

    Correct answer is:
    FALSE :-(

    Why? Answer is easy, Boolean have two fields TRUE and FALSE, in fixBooleans() we changed values stored in variable value, for now when JVM tries to obtain value of TRUE it gets our change value false. That's whole secret ;-)

    I will try to write next time something more interesting.

    Similar postsbeta
    How many i 1+1 in Java? ;-)
    The Secret Life of String ;-)
    How to create valid file name?
    Recursion is evil ;-)
    How to get negative number from size() in LinkedList in Java? ;-)

    Sunday, March 16, 2008

    How many i 1+1 in Java? ;-)

    Last time we spoke about immutability of String in Java, today lets talk about adding Integers ;-)

    Lets check how many is 1+1 in Java...

    For first try we will use this code:
    public class Integers { 
    public static void main(String[] args) throws Exception{
    Integer i1 = 1;
    Integer i2 = 1;
    System.out.println(i1+"+"+i2+"="+(Integer)(i1+i2));
    }
    }

    After compile and run we will see on the screen:

    1+1=2

    It was easy :-)

    But to our next try we will add some additional code....

    import java.lang.reflect.Field;
    public class Integers {
    public static void main(String[] args) throws Exception {
    Integer i1 = 1;
    Integer i2 = 1;
    System.out.println(i1+"+"+i2+"="+(Integer)(i1+i2));
    fixIntegers();
    System.out.println(i1+"+"+i2+"="+(Integer)(i1+i2));

    }

    static void fixIntegers() throws Exception {
    Class integerClass = Integer.class;
    Field value = integerClass.getDeclaredField("value");
    value.setAccessible(true);
    value.setInt(Integer.valueOf(2), 3);
    }

    }


    And now strange things happens....

    After we compile and run we can see....

    1+1=2
    1+1=3

    How it's possible? ;-)

    Here short explanation ;-)
    Method fixIntegers() changes value of int stored as "int representation" in some Integer... This some Integer is rather important ;-) In Sun Java was decided that conversion of some numbers [actually from -128 to 127] is rather often, so why to make this conversion so often? More reasonable will be to keep somewhere array of those Integers and when it will be needed use one of those objects. Method fixIntegers() first gets Integer object for int value of 2, and using reflections it changes value from 2 to 3 :-)
    Next "magic" things are in line where we made second addition, we adds 1 to 1, and of course we got as a result 2, but we also wants to convert it to Integer, instead conversion we have here usage of value from "pool", we take this object :-) But because we wants to print String representation of this value method toString() of our object is called... and toString() looks to private variable value and finds in this place... 3 :-)
    And it's whole secret ;-)

    Similar postsbeta
    Abuse of Booleans ;-)
    The Secret Life of String ;-)
    How to get negative number from size() in LinkedList in Java? ;-)
    How to create valid file name?
    Recursion is evil ;-)

    Thursday, March 6, 2008

    The Secret Life of String ;-)

    /mad scientist mode on

    They always said "String is immutable - you cannot change its value without changing reference!"

    But what They will say when I will use this code?
    import java.lang.reflect.Field;

    public class StringModificator {
    public static void trueModificator(String str)
    throws Exception {
    Field valueField = str.getClass().getDeclaredField("value");
    valueField.setAccessible(true);
    char[] value = (char[])valueField.get(str);
    char[] reversed = new char[value.length];
    for (int idx=0; idx<value.length; idx++) {
    reversed[idx]=value[value.length-idx-1];
    }
    for (int idx=0; idx<value.length; idx++) {
    value[idx]=reversed[idx];
    }
    }

    public static void falseModificator(String str) {
    str="toster";
    }

    public static void main(String[] args) throws Exception {
    String str = "it's a test";
    String subStr = str.substring(3);
    // prints "it's a test"
    System.out.println(str);
    System.out.println(subStr);

    falseModificator(str);
    // Still prints "it's a test"
    System.out.println(str);
    System.out.println(subStr);

    trueModificator(str);
    // But whats now? ;-)
    System.out.println(str);
    System.out.println(subStr);
    }
    }

    So this whole String isn't so immutable as They said!!!

    /mad scientist mode off

    Similar postsbeta
    Abuse of Booleans ;-)
    How many i 1+1 in Java? ;-)
    How to create valid file name?
    Recursion is evil ;-)
    How to get negative number from size() in LinkedList in Java? ;-)

    Monday, January 28, 2008

    OpenOffice.org2GoogleDocs 0.8 :-)

    I had some spare time to finish coding of new features for AddOn ;-)
    New in version 0.8 are:

  • new method of downloading of documents from Google Docs, this time without using of default web browser ;-) - author of downloading: Stefan Kolarov.
  • translation to Polish, German and Bulgarian. Authors of translation: Polish - me ;-), German - Pascal Herbert, Bulgarian - Stefan Kolarov.

    New version 0.8 you may find on OpenOffice.org extensions page.


    Similar postsbeta
    OpenOffice.org2GoogleDocs 0.8.1 - fixes :-)
    OOo2GD 2.0.0, now with autoupdate of documents in Google Docs :-)
    OpenOffice.org2GoogleDocs 1.0.1
    OOo2GD 1.8.1 - 2 fixes
    OpenOffice.org2GoogleDocs 0.9.1
  • Wednesday, January 9, 2008

    OpenOffice.org2GoogleDocs 0.7.1

    OpenOffice.org2GoogleDocs 0.7.1 is ready :-)
    This version should fix problem with exporting of ODS files (OpenOffice.org Calc Spreadsheets), also version information was added to extension.

    Rest of features is coded ;-)

    Newest version of AddOn you may find at project page.


    Similar postsbeta
    OpenOffice.org2GoogleDocs 0.8.1 - fixes :-)
    OpenOffice.org2GoogleDocs 0.6.5
    OpenOffice.org2GoogleDocs 1.2.0 - WebDAV support
    OpenOffice.org2GoogleDocs 0.7
    OpenOffice.org2GoogleDocs 1.2.1

    Wednesday, January 2, 2008

    One JavaPuzzle ;-)


    Is it a correct Java program? So will it compile and run without exceptions?
    Please give an answer and explain ;-)

    [If nobody will give an answer I will ;-)]


    Similar postsbeta
    OpenOffice.org2GoogleDocs 1.0.4
    Pixelbook
    Chrome OS and Java
    Math is stupid....
    I'm on Twitter ;-)

    Wednesday, December 19, 2007

    OpenOffice.org2GoogleDocs 0.6.5

    New version of my AddOn for OpenOffice.org is available :-)



    Changes in this version:
  • for now is possible to upload files with dots in name :-)
  • small additional changes in source code
  • small piece of auto-promotion ;-)

    Version 0.6.5

    Project Page


    Similar postsbeta
    OpenOffice.org2GoogleDocs 0.7.1
    OpenOffice.org2GoogleDocs 0.8.1 - fixes :-)
    OpenOffice.org2GoogleDocs 0.7
    OpenOffice.org2GoogleDocs 0.9.5
    OpenOffice.org2GoogleDocs 0.9.1
  • Saturday, December 15, 2007

    Why it isn't working???

    I got some reports from users of my OOo2GD extension. It looks that under Linux, and from this what I may see mainly under Ubuntu, Google Docs menu doesn't appear after installation of OOo2GD.
    In most of those systems helps resolution #1 from Known Issues published on project wiki. Also version 0.5 looks to work without problems.

    From this what I know only two files may be connected with this problem, first is Addons.xcu [file with description of extension, this is a place where OpenOffice.org looks to check what should put into menu, where to search code and which applications from pack should see this extension], second is one of classes called GDocs [it's first class loaded by OpenOffice.org, and in this class is coded dispatcher called by OpenOffice where it tries to show menu of extension, and when user use menu items of extension].

    Problem is that those two files are almost identical between version 0.5 and 0.6.
    In 0.6 I added to Addons.xcu line for narrowing set of applications in pack where AddOn should be visible. In GDocs I simply made small refactoring by moving direct using of literals to using of constants.........

    I made small experiment and copied Addons.xcu from version 0.5 to 0.6, but problem still occurs on my Ubuntu........ It looks that I must search harder :-)

    [why I wrote this? In my first company [Aksel or AKSEL-NET] we used to wrote monthly reports, it was boring and rather ineffective but sometimes it helps me to find solution of some problems, so I wrote it here to organize my thoughts :-)]


    Similar postsbeta
    Vacation in progress ;-)
    Early access version of OOo2GD 1.7.0 with partial MacOS support
    OpenOffice.org2GoogleDocs and Apple - first try ;-)
    OOo2GD 2.1.1 is ready :-)
    ePubGenerator v0.0.3 - from OpenOffice.org to EPUB :-)