Tuesday, August 26, 2008

Web-Safe color chart

//TODO: write a JavaScript to reproduce the char below:


HTML link to open email client

Creating HTML anchor tab for email with subject:


<a href="mailto:YourName@me.com?subject=Hi" >email link </a>

Monday, August 25, 2008

Hibernate Detached criteria with projections (GROUP BY)

Examples of Spring/Hibernate compare, group by, order by (sort) functionality:

    public List fetchDetailMetrics(Date dateFrom, Date dateTo, String navPage, String navOption, OrganizationDTO org)

    {

List pageViews = new ArrayList();

log.warn("Date from " + dateFrom + " to " + dateTo);

DetachedCriteria metrics = DetachedCriteria.forClass(MetricsForUserSession.class);

metrics.add(Expression.between("dateTime", dateFrom, dateTo));

metrics.add(Expression.eq("navOption", navOption));

metrics.add(Expression.eq("navPage", navPage));

if (org != null)

{

    log.warn(" org " + org.getName());

    metrics.add(Expression.eq("organization.id", org.getId()));

}

ProjectionList projectList = Projections.projectionList();

// group by

projectList.add(Projections.groupProperty("entityId"));

// alias of the column head

projectList.add(Projections.alias(Projections.rowCount(), "count"));

metrics.setProjection(projectList);

// order by, sorting

metrics.addOrder(Order.desc("count"));


List results = getHibernateTemplate().findByCriteria(metrics);

if (results == null || results.size() <>

    log.warn("fetched nothing");

else

    log.warn("fetched " + results.size());

log.warn("fetched navPages " + results.size());

for (Object[] column : results)

{

    log.warn(column[0] + " " + column[1]);

    PageView pageView = new PageView();

    determineDescription(pageView, column, navPage);

    pageView.setViewCount(new Integer(column[1].toString()));

    pageViews.add(pageView);

}

return pageViews;

    }















Converting string value to an int

To convert a string type element to an Integer object, use below syntax:



new Integer( numericValueObject.toString() )

Wednesday, August 20, 2008

GWT: Migrate GWT from 1.4 to 1.5


1. Update pom.xml from GWt 1.4

2. In .properties file, point to GWT home (click here to download version 1.5 RC2 of GWT):
GWT_HOME=/opt/gwt/gwt-mac-1.5.1/

3. Unfortunately the new version of hibernate4gwt was incorrectly placed in the maven repository so you have to add it manually with the following statement:

mvn install:install-file -DgroupId=net.sf.hibernate4gwt -DartifactId=hibernate4gwt -Dversion=1.1b -Dpackaging=jar -Dfile="path to jar"/hibernate4gwt-1.1b.jar

Monday, August 18, 2008

Java Date

/** Format: May 16, 2008 */
public static String formatDefaultUSA(Date date)
{
String countryCode = "US";
String languageCode = "en";
return convertToLocalized(date, countryCode, languageCode, DateFormat.DEFAULT);
}
public static String convertToLocalized(Date date, String countryCode, String languageCode, int format)
{
Locale locale = new Locale(languageCode, countryCode);
DateFormat df = DateFormat.getDateInstance(format, locale);
return df.format(date);
}

/** Format: 5/14/08 */
public static String formatShortUsa(Date date)
{
String countryCode = "US";
String languageCode = "en";
int format = DateFormat.SHORT;
return convertToLocalized(date, countryCode, languageCode, format);
}

Wednesday, August 13, 2008

Buying iPhone 3G with GPS

Despite of the fact I already have an iPhone, I wanted to get the iPhone 3G with GPS to use while sailing (iNavX app) or mountain tracking. My wife would perfectly happy to use my previous model.

I don't believe in "hiring the carpenter to fix the plumbing",  so I drove 40 minutes to the Apple store to get it, instead of local AT&T store. There, I learned that Apple went entirely away with the idea of the register and with many people in the place getting any attention without elbowing the neighbors took me 15 minutes. Finally, I flagged down a store clerk who directed me to another one as if selling the item was too difficult for the local "geniuses" in that bar. The sales person, to my astonishment, has put me in waiting line behind a tape. There in waiting line I happened to be the only waiting person, but I guess that made no difference to the sales person. The salesperson asked me diligently if I want an 8 Gb, or 16 Gb phone, black, or white then told me they have only white 8Gb models. Once I made this convenient selection, he wrote a small slip of paper and gave it to another sales person. Now, that I was served by 3 very nice people, each in a different color T-shirt we got down to business. I answered FBI type of questions and after there was nothing else personal about me they could get I gave them my credit card. After running the card they told me that they cannot sale me the iPhone because I have a corporate discount with AT&T and that is blocking the transaction. Fuming, after wasting 2 hours of my time I left without the phone.

Next day, I gave a try the local AT&T store. This time more luck: a local store and the clark waiting in the door -- great, I thought! The nice lady with a notepad asked us if I want to "order" the iPhone, I asked if "ordering" is the same as "buying", she said no, they don't actually have any in stock and that the waiting period if "only" 10 days, which apparently was a good deal comparing to previous 20 days.

I was not surprised when she took my name and asked me to wait. 

The salesperson  could as well drop the "sales" from his title, he was just a person. To order the iPhone it took him 15 minutes of fumbling with the computer keyboard, listening to the conversation of the girls next to us and asking me another set of FBI questions (Do they really need to know if my place is a house or apartment building?)

Finally, I asked him if he would recommend me a better minutes plan to which he said my plan is fine. I asked him, what about the $600 bill last month. He said "Oh!". $20 addition to my bill fixed the issue.

Why do I write this? 

I hope that iPhone gets a real competitor really soon. I hope that Google Android phone operating system will be awesome.



Monday, August 11, 2008

MySQL creating a dump (backup)

wbdb4uccprd00001:~# mysqldump –-user my_user -p my_db > my_db.20080811a.sql
Enter password: 


How to publish Javadoc on Google Code

  1. Upload the javadocs to the google code svn repository for the project.
  2. Change the MIME type of these javadoc pages from text/plain to text/html and text/css. This is done with subclipse (in Eclipse) as follows
    1. Right-click the folder that contains the javadocs. Select [Team] -> [Set Property...].
    2. Name: "svn:mime-type", Value: "text/html".
    3. Select "Set property recursively" and click OK.
    4. Set the property for the individual css file in the same way to "text/css".
  3. Commit the changes to the svn repository.
  4. In Google Code, browse the project source to the index.html of the javadoc.
  5. Select "View raw file". Just link to that URL as your published Javadoc.

I got all my information here:
http://stuffthathappens.com/blog/2007/11/09/howto-publish-javadoc-on-google-code/

Mac: taking a snap shot

To take a snap shot in your Mac:

1. To take a screen shot of your whole window, press shift, Command and 3 keys at the same time. The image will be stored in your main HD.

2. To take a screen shot of rectangular window, press shift, Command and 4 keys at the same time. You will be see a small curser that allows you to select the area you want a snap shot of. The image will be stored in your main HD.