Pages

Friday, April 29, 2011

Java -=- How to copy file using Apache IOUtils

Here is a code snippet that explain how to copy a file using IOUtils. You can get Apache IOUtils at http://commons.apache.org/io/download_io.cgi

InputStream in = null;
OutputStream out = null;

try {
    // Ensure folder is created
    FileUtils.forceMkdir(new File("/Users/yann/myfolder"));

    in = new FileInputStream(new File("/Users/yann/from.txt"));
    out = new FileOutputStream(new File("/Users/yann/myfolder", "to.txt"));

    IOUtils.copy(in, out);

} finally {
    IOUtils.closeQuietly(in);
    IOUtils.closeQuietly(out);
}

Wednesday, April 27, 2011

Good site to find free favicons

Here's a good site to find free favicons

http://www.freefavicon.com/

JAD Java Decompiler Download Mirror

Since http://www.kpdus.com/ is not available anymore, JAD is now hard to find.

Here's a mirror containing all the versions of JAD. This article is a copy of Tomas Varaneckas's site (http://www.varaneckas.com/jad).

 

Installation

Unzip jad.zip file into any appropriate directory on your hard drive.
This will create two files:
  • an executable file named 'jad.exe' (Windows 9x/NT/2000) or 'jad' (UNIX)
  • README file 'Readme.txt', which contains the short user's manual
For UNIX users: make 'jad' executable: chmod a+x jad
No further setup is required.

Disclaimer

JAD is Copyright 1997-2001 Pavel Kouznetsov. All rights reserved. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE IN ON-LINE CONTROL OF AIRCRAFT, AIR TRAFFIC, AIRCRAFT NAVIGATION OR AIRCRAFT COMMUNICATIONS; OR IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY. THE AUTHOR DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OFFITNESS FOR SUCH USES. YOU MUST REPRESENT AND WARRANT THAT YOU WILL NOT USE THE SOFTWARE FOR SUCH PURPOSES

Monday, April 18, 2011

[RSA] Install Cicso AnyConnect on Mac OS X Snow Leopard

Hi!

There is a bug with the version of Cisco AnyConnect 2.3 that made impossible to install the VPN client on Mac OS X Snow Leopard.

To be able to install it, we must download a newer version (2.4 and later).

You can get the client by connecting to the Cisco Web Site (http://www.cisco.com/cisco/software/navigator.html) and download it. You need a username / password.

If you do not have an account on the Cisco's Web Site, you can download a copy of the software here:
at  http://unf.net/snowleopard/anyconnect-macosx-i386-2.4.0154-k9-BETA.zip


Download and install the client. After that, connect yourself to the RSA servers. The AnyConnect client will be automatically updated.

You must be ready to use AnyConnect Client with Snow Leopard.

Thursday, April 14, 2011

ExtJS -=- Converting a timestamp value to a valid date when loading a FormPanel (DateField)

I've got a problem today. I was trying  to load a record that contains a timestamp field that comes from a Rails application (with PostgreSQL DB).

The FormPanel refuse to load the date value in my DateField component. I've discovered that it was because the DateField did not recognize the date because it was a timestamp.

In order to be able to set the date's value, we need to format the timestamp as a date when loading the FormPanel.

Here's how to do this.

Generated JSON used to load the FormPanel
{
     success:true, 
     data: {
          start_date: \"Tue Apr 12 20:06:11 UTC 2011\", 
          id: 4, 
          app_id: 2, 
          version: \"1.2.3\", 
          message: \"test msg\", 
          active: true
     }
}


Add this code to your FormPanel
form.getForm().on({
    actioncomplete: function(form, action) {
        if (action.type === 'load') {
            if (action.result.success) {
                var date = new Date(action.result.data.start_date);

                form.setValues({
                    start_date: date.format('Y-m-d')
                });
            }
        }
    }
});

When loading, the value of the date will be converted from a timestamp to a valid date and the DateField will recognize the value.

ExtJS -=- Wait message while loading a store

Hi!

To display a loading message while a store is loading, simply add this line of code...

// Store Definition
var objectAStore =  new Ext.data.JsonStore({
    url: '/objecta/json_dropdown_list',
    root: 'Records',
    totalProperty: 'Total',
    fields:[
    {
        name: 'id'
    },
    {
        name: 'name'
    }
    ]
});

// Loading Mask
new Ext.LoadMask(Ext.getBody(),{msg:'Loading data...', store: objectAStore});

If you want a loading mask for a grid panel, simply set GridPanel's property "loadMask" to true

Monday, April 11, 2011

Mac OS X -=- Installing Java 1.4 on Snow Leopard

By default, Snow Leopard does not include Java 1.4 anymore. All the Java 1.4 softlinks points to the Java 1.6 library. If you want to install Java 1.4, you must install it manually.


In the terminal: 


Get the java 1.4.2 that was included in 10.5 "leopard" and unpack

cd /tmp/
curl -o java.1.4.2-leopard.tar.gz http://icebergsofts.com/static_content/java.1.4.2-leopard.tar.gz
tar -xvzf java.1.4.2-leopard.tar.gz

Move it to your System java folder (password needed)
sudo mv 1.4.2 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2-leopard

Tell OS X that java 1.4.2 actually is java 1.4.2
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo ln -s 1.4.2-leopard 1.4.2
sudo ln -s 1.4.2 1.4

Open Java Preferences
open "/Applications/Utilities/Java Preferences.app"

Change the properties to use Java 1.4.2 32-bit by default:



Credits goes to http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard