Archive for August, 2009

Java: Image IO, JAI

Friday, August 21st, 2009

Docs

Sample code links:

  • The Perils of Image.getScaledInstance() (Best algorigthm to scale down/up images with ImageIO)
    • “… be aware that if you try to downscale an image by a factor of more than two (i.e., the scaled instance is less than half the size of the original), and you are using the BILINEAR or BICUBIC hint, the quality of the scaled instance may not be as smooth as you might like…. To combat this issue, you can use a multi-step approach when downscaling by more than two times; this helps prevent the information loss issue and produces a much higher quality result that is visually quite close to that produced by Image.SCALE_AREA_AVERAGING.”
  • JAI Tutorial (Sun)
  • Resizing with JAI
  • Resizing with JAI (Subsample for best result)

Other Samples

Java: Sorting List with Comparator

Tuesday, August 18th, 2009
class EmpSortByName implements Comparator{

    public int compare(Employee o1, Employee o2) {
        return o1.getName().compareTo(o2.getName());
    }
}

....
List employees = ...;
Collections.sort(employees , new EmpSortByName());

java.lang.Comparable: int compareTo(Object o1)
This method compares this object with o1 object. Returned int value has the following meanings.

  1. positive – this object is greater than o1
  2. zero – this object equals to o1
  3. negative – this object is less than o1

java.lang.Comparator: int compare(Object o1, Objecto2)
This method compares o1 and o2 objects. Returned int value has the following meanings.

  1. positive – o1 is greater than o2
  2. zero – o1 equals to o2
  3. negative – o1 is less than o1

Source: Java Sorting: Comparator vs Comparable Tutorial

AspectJ: Suppress Warnings adviceDidNotMatch

Tuesday, August 18th, 2009
@SuppressAjWarnings({"adviceDidNotMatch"})

See forum discussion

Skype: Advanced Links & Callto apis

Saturday, August 15th, 2009
<a href="skype:echo123?call">Click</a>(make a call to echo123)

<a href="skype:echo123">Click</a>(default action - call)

<a href="skype:echo123?add">Click</a>(add echo123 to your contacts)

<a href="skype:+14035551111?call">SkypeOut call</a>

<a href="skype:user1?chat">Start a text chat with user1</a>

<a href="skype:user1;user2;user3?chat">(Start a multichat with 3 people)</a>

<a href="skype:user1;+14035551111?call">User and Phone conference</a>

<a href="skype:user1?userinfo">User Info</a>

<a href="skype:user1?sendfile">(Send a file to user1)</a>

Official Advanced Skype links docs

Apache: SSL Certificate generate CSR

Friday, August 7th, 2009

CSR-Generation Instructions

To generate a triple-DES encrypted key pair and a Certificate Signing Request (CSR):

Enter the following commands:

  1. cd /usr/bin/ (/your path to openssl/)
    Enter a passphrase when prompted to.
  2. openssl genrsa -des3 -out <name of your certificate>.key 1024
  3. openssl req -new -key <name of your certificate>.key -out <name of your certificate>.csr

If you are requesting a Wildcard certificate, please add an asterisk (*) on the left side of the Common Name (e.g., “*.domainnamegoes.com” or “www*.domainnamegoeshere.com”). This will secure all subdomains of the Common Name.

(source: Godaddy’s help)

BTW, Godaddy has the cheapest certificates you can find (with great support).