Top Mobile OS in United States

Source: StatCounter Global Stats - Mobile OS Market Share

Using java.util.Properties in Servlet to save User Preferences

import java.util.Properties;




String propertiesFileName = "my_properties.txt";

SAVE PREFERENCES:
Properties unsavedProperties = new Properties();
unsavedProperties.setProperty("my_name", "Uki");
OutputStream propOut = new FileOutputStream(new File(propertiesFileName));
unsavedProperties.store(propOut, "My Server properties");

LATER READ THE SAVED PREFERENCES:

InputStream inStream = new FileInputStream(propertiesFileName);
Properties savedPropeties = new Properties();
savedPropeties.load(inStream);
String myName = savedPropeties.getProperty("my_name");

Java Servlet: starting a thread that always runs

  • when Java Servlet starts it reads web.xml
  • add listener implementation class to your web.xml



<display-name>your_servlet_namedisplay-name>

<listener>
<listener-class>com.your_package_name.TimedServletCallerlistener-class>
listener>

  • we will use ServletContextListener interface
  • create a NEW thread (Loop) inside contextInitialized(), if you did Thread.sleep without new thread the whole Servlet would pause and container would fail to start it after 45 seconds or so


public class TimedServletCaller implements ServletContextListener
{
private static int sleepMinutes = 1;

class Loop extends Thread
{
public void run()
{
while (true)
{
Log.e("Loop is running!");
takeShortNap();
// do stuff here
}
}
}

@Override
public void contextInitialized(ServletContextEvent arg0)
{
Log.e("***** TimedServletCaller.contextInitialized()");
// execute();
Thread thread = new Loop();
thread.start();
}

private static void takeShortNap()
{
Log.i(" Pausing for " + sleepMinutes + " minute(s).");
try
{
Thread.sleep(sleepMinutes * 60 * 1000);
catch (InterruptedException e)
{
Log.e(e.getMessage());
}
}

  • restart your server (Tomcat) now you can use your Servlet, but also the Loop keeps running and doing useful things like database updates, etc.

HD connector speed

When you are buying the external hard drive storage, I would recommend looking for eSATA connectors, backing up, or copying videos via USB is very slow.

USB 1.1 – 15 Mbps
FireWire (1394a) – 400 Mbps
USB 2.0 – 480 Mbps
FireWire 800 (1394b) – 800 Mpbs
SATA 1.5 – 1.5 Gbps
SATA 3.0 – 3.0 Gbps

near future:

USB 3.0 - 5Gbps
eSATA version of SATA 6G - 6.0Gb/s

Google Documents - please show this to your boss!

We have been using Google docs and Google sites for collaboration for couple of years now, but there are still people who have not heard about the concept. Here is a video to help.

Using HTML panel

I needed to create a subscript text with a link that open up a new popup with different content. Since HorizontalPanel does not work, I used HTMLPanel and use the table tag, which contained element id as shown below.


Click on below image to read the code: CSS


CSS code:



.subscript {
font-size: xx-small;
vertical-align: bottom;
}



.hyperlink_subscript {
text-decoration: none;
cursor: pointer;
color: #0099FF;
font-size: xx-small;
font-weight: normal;
}
Here is how it looks: 



Apache Tomcat: starting, stopping and killing processes

STOPPING:
 /opt/apache/apache-tomcat-6.0.26/webapps $ ../bin/shutdown.sh
Using CATALINA_BASE:   /opt/apache/apache-tomcat-6.0.26
Using CATALINA_HOME:   /opt/apache/apache-tomcat-6.0.26
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-6.0.26/temp
Using JRE_HOME:        /Library/Java/Home/
Using CLASSPATH:       /opt/apache/apache-tomcat-6.0.26/bin/bootstrap.jar
Mar 31, 2010 11:13:58 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.(Socket.java:372)
at java.net.Socket.(Socket.java:186)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)

CHECKING IF STILL RUNNING:
 /opt/apache/apache-tomcat-6.0.26/webapps $ ps aux | grep tomcat
uki       3086  57.9  6.8  1506508 143136 s000  U    11:12AM   0:22.70 /Library/Java/Home//bin/java -Djava.util.logging.config.file=/opt/apache/apache-tomcat-6.0.26/conf/logging.properties -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8 -Dcom.sun.management.jmxremote -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/apache/apache-tomcat-6.0.26/endorsed -classpath /opt/apache/apache-tomcat-6.0.26/bin/bootstrap.jar -Dcatalina.base=/opt/apache/apache-tomcat-6.0.26 -Dcatalina.home=/opt/apache/apache-tomcat-6.0.26 -Djava.io.tmpdir=/opt/apache/apache-tomcat-6.0.26/temp org.apache.catalina.startup.Bootstrap start
uki       3120   0.2  0.0   590540    204 s000  U+   11:14AM   0:00.00 grep tomcat

KILL A PROCESS:
 /opt/apache/apache-tomcat-6.0.26/webapps $ kill 3086

CHECKING IF STILL RUNNING:
 /opt/apache/apache-tomcat-6.0.26/webapps $ ps aux | grep tomcat
uki       3122   0.9  0.0   600020    472 s000  R+   11:14AM   0:00.00 grep tomcat


STARTING:
ill-lt20220@(Wed Mar 31 11:14:27) /opt/apache/apache-tomcat-6.0.26/webapps $ ../bin/startup.sh 
Using CATALINA_BASE:   /opt/apache/apache-tomcat-6.0.26
Using CATALINA_HOME:   /opt/apache/apache-tomcat-6.0.26
Using CATALINA_TMPDIR: /opt/apache/apache-tomcat-6.0.26/temp
Using JRE_HOME:        /Library/Java/Home/
Using CLASSPATH:       /opt/apache/apache-tomcat-6.0.26/bin/bootstrap.jar
ill-lt20220@(Wed Mar 31 11:14:33) /opt/apache/apache-tomcat-6.0.26/webapps $ ps aux | grep tomcat
uki       3132  49.5  3.6  1504832  74680 s000  U    11:14AM   0:06.14 /Library/Java/Home//bin/java -Djava.util.logging.config.file=/opt/apache/apache-tomcat-6.0.26/conf/logging.properties -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8 -Dcom.sun.management.jmxremote -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/apache/apache-tomcat-6.0.26/endorsed -classpath /opt/apache/apache-tomcat-6.0.26/bin/bootstrap.jar -Dcatalina.base=/opt/apache/apache-tomcat-6.0.26 -Dcatalina.home=/opt/apache/apache-tomcat-6.0.26 -Djava.io.tmpdir=/opt/apache/apache-tomcat-6.0.26/temp org.apache.catalina.startup.Bootstrap start
uki       3134   0.0  0.0   590736    308 s000  R+   11:14AM   0:00.00 grep tomcat
ill-lt20220@(Wed Mar 31 11:14:41) /opt/apache/apache-tomcat-6.0.26/webapps $


CHECKING THE LOG:

/opt/apache/apache-tomcat-6.0.26/webapps $ tail -f ../logs/catalina.out
Mar 31, 2010 11:15:12 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory work
Mar 31, 2010 11:15:12 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 31, 2010 11:15:12 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 31, 2010 11:15:12 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/88  config=null
Mar 31, 2010 11:15:12 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 36930 ms



Mac: location of hosts file

The hosts file on Mac is located at: /private/etc/hosts
The easiest way to modify it is using pico, you need to have WRITE permissions to do so.

 ~ $ cd /private/etc/
 /private/etc $ pico hosts

Eclipse: show line numbers

This is simple stuff, but it is frustrating when you want to show line numbers and cannot find the setting:

On Mac:

Eclipse -> Preferences -> General -> Editors -> Text Editors -> Show line numbers




IE8 and Windows7 hacked easily

I don't think anything with Windows is really safe...

http://www.computerworld.com/s/article/9174101/Hacker_busts_IE8_on_Windows_7_in_2_minutes


I wonder if Mac vulnerabilities would be found this easy if we put effort towards it or does everyone just like to pick on Microsoft?

Virus test file (it is save to use)

In case you write a code to test your anti-virus software you will need a "test virus file" that does not actually wipe out your computer, you can download it from this site...

http://eicar.org/

How to fetch total record count using Hibernate Criteria




Criteria criteria = getSession().createCriteria(getReferenceClass());

criteria.setProjection(Projections.projectionList().add(Projections.countDistinct("id"))

Twitter had enough...

Changing mysql password

I was getting below error when I run jUnit tests:


WARN 2010-02-15 13:39:25.602 org.hibernate.util.JDBCExceptionReporter.logExceptions() 
        SQL Error: 0, SQLState: null 
ERROR 2010-02-15 13:39:25.627 org.hibernate.util.JDBCExceptionReporter.logExceptions() 
        Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES)) 
WARN 2010-02-15 13:39:25.629 org.hibernate.cfg.SettingsFactory.buildSettings() 
        Could not obtain connection metadata 
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

Solution:

I needed to change mysql server password using command line:

mysqladmin -u root -p'oldpassword' password newpass

"Google Buzz", social networking

Google, which has faltered in its attempts to break into the booming social networking business, is making another bid to counter the growing influence of Silicon Valley rival Facebook and San Francisco upstart Twitter with new products that make it easier to share with friends on its Internet e-mail service Gmail.

The Internet giant held a press conference at its Mountain View, Calif., headquarters Tuesday to show off "Buzz," which incorporates social media tools such as photo and video sharing and status updates in Gmail. Google Buzz, which launches Tuesday, will also be accessible on mobile phones. And Google will eventually also debut a version of Buzz for businesses.

Google co-founder Sergey Brin, vice president of product management Bradley Horowitz, vice president of engineering Vic Gundotra, and product manager Todd Jackson were on hand to show it off. The tagline for Google Buzz is "a Google approach to sharing."

Buzz is perhaps Google's boldest effort yet to get social. The new service has five features, Jackson said. You will automatically follow the people you e-mail and chat with on a regular basis. You will be able to share content from around the Web, including YouTube videos, Flickr photos, site links and others. You will be able to share your thoughts in a public way and in a private way. You will get social updates in your inbox. And Google will help you find only the stuff that matters by recommending popular content. The mobile version of Buzz can figure out where you are and show you nearby buzz posts.

"Google has long said their goal is to organize the world's information. With the introduction of Buzz, you can see the company recognizes how social has become a 'Google scale' problem that needs improved discovery and real relevancy," said technology blogger Louis Gray. "People are sharing their content in a wide variety of social sites online, and Buzz is the first product from Google that looks to harness this data in one place and provide a platform for discussion."

Last month, Google introduced a new feature that displays search results related to their friends and other members of their social networks. Google has been trying for years to gain a foothold in social networking as its smaller, more nimble competitors steal some of its thunder. Orkut, its social networking service, gained a mass following in Brazil and nowhere else. Attempts to buy its way into the arena also failed, when Google acquiring -- then ultimately scrapped -- the services offered by Twitter competitor Jaiku and Foursquare forebearer Dodgeball.

Analysts remain skeptical that this effort will catapult Google into the social stratosphere. Meanwhile, Facebook has exploded in popularity. It has become such a central part of many people's lives that it's replacing e-mail. That's exactly what Facebook founder Mark Zuckerberg is looking to do: turn his site into the starting point and focal point of the Internet experience. Facebook's strategy of connecting the world's people, versus Google's strategy of organizing the world's information, seems to be resonating. So now Google says it's going to organize the world's social information.

The Silicon Valley showdown is heating up. Google is still the Web's No. 1 most-visited site, with 173 million U.S. visitors in December, according to ComScore Media Metrix. But Facebook is gaining. Facebook was the fourth-most visited site in December, with 111.8 million visitors.

-- Jessica Guynn

read more: 

http://latimesblogs.latimes.com/technology/2010/02/google-facebook-social-networking.html

iPad Revolution?

Those who know me know that I have been a strong convert to the world of Mac. Over the past two years, I have had a personal Mac overhaul for all of my tech needs (except my phone, which I recently purchased the DROID and have enjoyed it thoroughly). So, when it came time for the fabled Apple tablet, I was extremely excited about the next piece of Mac-ness that I was going to be enjoying. But I was a little disappointed in the iPad initially. Where was the wow? Where was the pizazz? I was troubled.

But since that fabled day, I have picked up the pieces of my shattered dreams and started to reevaluate all of the potential that exists with the iPad. I initially fell into the trap of looking at this new piece of technology from the definitions of "nerd-dom". What I failed to see was this product from the point of view of the person who uses their computer to check email, browse the internet, look at photos, and that is it.

Here is an article and an essay that I thought were very interesting in seeing what could be the iPad revolution:

http://www.macworld.com/article/146040/2010/02/ipad.html
http://northtemple.com/2010/02/01/on-ipads-grandmas-and-gam

Let me know what you think!

Chicago Android Google conference and eco hackathon

Saturday Feb. 6, 2010,
hurry up we are closing the registrations!

http://chigtug6.eventbrite.com/

How to create a label with an image background in GWT

In order to create a label with an image background, you will need to use an AbsolutePanel with an image background defined in CSS and add a Label to it. The reason behind using an AbsolutePanel is because this type of panel allows for positioning all children absolutely, allowing them to overlap. Keep in mind however that you will have to resize the panel to allow room for all its children because it will NOT resize automatically.

Here is a sample implementation of how this worked for me:

Java code in Samle.java:

AbsolutePanel absolutePanel = new AbsolutePanel();
absolutePanel.setStyleName("my_css_def");

Label myLabel = new Label("Hello world!");

absolutePanel.add(myLabel);

mainContainer.add(absolutePanel);

CSS definition in Sample.css file: 

.my_css_def {
background-imageurl("../images/myPath/bg_image.png"); !important;
height: 73px;
width: 108px;
}

Great Analytics Tool

If you are looking for a great analytics tool for your website, check out Woopra. It is now out of beta. I have seen it used a little and it looks pretty impressive. The basic plan is free, but if you are needing a little bit more information, here are the plans offered (http://www.woopra.com/plans/)

Transparency Setting for ALL Browsers

Below is CSS definition that creates transparency for all browsers:


.opacity_70 {
filter:alpha(opacity=70);     /**for IE8*/
-moz-opacity:0.7;             /**for Mozilla*/
-khtml-opacity: 0.7;          /**for Safari 1.x*/
opacity: 0.7;                 /**for FireFox*/
}

Solar Powered Skins for iPhone and iPod

Solar power iPhone skins are getting more popular for everyone. Apple devices with solar powered chargers are already available in the market, but solar powered skins are not. These skins are capable of charging an iPhone or iPod using solar energy. According to Heimbuch from TreeHugger, one of the solar power skins is capable for providing 30 minutes talk time on a 2G network with 2 hours of solar energy charging. Also these skins are shipped with a solar planner application which helps estimating the needed solar charge time during the day in order to have a working phone in the evevning.

Solar powered chargers can provide few minutes of talk time, however with high consumer demand, these devices may gain wider popularity leading to more competition and better quality overall.

Color Palette Generator

Here is a very nice color palette generator that creates both a dull and vibrant color palette based off of a photo url.

http://www.degraeve.com/color-palette/