Wednesday, 14 November 2012

Sucky Samsung

I have been using the Samsung Galaxy S3 for a couple of months now. There are a couple of fundamantal problems with Samsung's bundled software and Samsung offers no fix.
  1. browser dims by itself - even after you manually set the colors settings and disable the system's auto-adjust brightness, the browser will still dim the screen next time you start it. Plenty of S3 users are suffering from it. My workaround it to install Dolphin browser instead. I also tried Chrome, but it freezes sometimes, so I replaced it with Dolphin.
  2. Samsung has stuffed up the docking bar at the bottom of the home screen with its latest firmware upgrade. You can no longer configure this docking bar. If you have uninstalled the app in the docking bar, you will not be able to put another app there. So you are left with an ungly gap. What is Samsung's solution for that? - to factory reset your phone! Oh, in Samsung's response letter, they forgot to mention to do a back up of your installed applications or downloads.
If you are a S3 owner and not suffering the above, then don't upgrade the firmware when Samsung offers you. My advice to new smart phone shoppers - avoid Samsung, they simply are not good at software development or testing, at least until they can offer a decent firmware. For me, I will look into rooting my phone and replacing the ROM.

Thursday, 7 June 2012

My LinkedIn Password

This morning as I read news on my mobile phone, I was alarmed by the news that 6.5 million LinkedIn user passwords were stolen. Some say 8 million, but according to my count it is exactly 6458020 SHA-1 hashed passwords contained in the file.

According to the news article, the culprit seems to be LinkedIn iOS app which collects passwords and sends them back to the servers without users’ knowledge.  Although I am not a fan boy of anything Apple and don’t use LinkedIn on my wife’s iPhone, I still scrambled to change all my online passwords first thing this morning, knowing that cracking passwords is extremely simple to do (not necessarily easy, but simple). When I was a freshman in Uni, I stumbled upon a cracker, which was essentially a Unix shell script plus some rules and dictionary files. I tried it on the password file (those were the days before shadow was made mandatory), within the first few seconds a dozen also passwords were revealed (out of a list of only couple of hundred).

Only after I changed all my passwords, then I caught my breath to start investigating whether my password was stolen. I found some comprehensive instructions on checking that in this blog. However, I couldn’t be bothered to learn the syntax of how to use openssl. So I dusted off my good old Eclipse Indigo and decided to write a few lines of Java to SHA-1 hash my password. I borrowed the source code from here. The code I used is listed below:

import java.security.MessageDigest;

public class HashMyWord {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		String password = "password";
		 
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        md.update(password.getBytes());
 
        byte byteData[] = md.digest();
 
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
         sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
 
        System.out.println("Hex format : " + sb.toString());
}
Luckily, my password was not among the stolen ones.

Thursday, 26 April 2012

BF3 Freezing Problem

There are many complaints about BF3 freezing after a few minutes, usually during loading/saving or in the middle of a mission.

I have not seen any solution posted any where. There were suggestions that RemoveWAT used on Windows 7 may be the culprit. But that does not apply to this problem.

Actually, the solution is very simple. In BF3, just go to Options –> Game Play and disable PunkBuster. That’s it!

Wednesday, 4 January 2012

A Simple Property Viewer with Reflection and ZK

Sometimes I need to display a POJO’s properties/attributes. These POJOs may contain dozens of properties making it tedious to invoke all the getXxx() methods. So Java Reflection is a perfect candidate for such a use case.
In the following example, the LoginResponse class contains dozens of fields that I want to display. The formatMethodName() method beautifies the getXxx() method names into more human user friendly names.
import java.lang.reflect.Method;
import com.laws.acc.ws.*;
import com.laws.acc.model.*;

LoginResponse loginResponse=AccSoapClientProxy.getLoginResponse();
void populateRows() {  
 if(loginResponse!=null) {
  Method[] methods = LoginResponse.class.getDeclaredMethods();
  for(int i=0; i<methods.length; i++) {
   
   
   Method method=methods[i];
   //Object arglist[]={};
   if(method.getName().startsWith("get")) {
    Row row=new Row();
    Label label=new Label(formatMethodName(method.getName()));
    label.setStyle("font-style: italic;");
    label.setParent(row);
    new Label(method.invoke(loginResponse, null).toString()).setParent(row);
    row.setParent(rows);
   }
  }
 }
}
/**
 * turn strings such as 'getUserName' into 'User Name'
 */
private String formatMethodName(String name) {
 // the method name should start with 'get' followed by the property name
 // otherwise, ignore the method.
 if(name==null || name.length()<4) return null;
 StringBuffer sb=new StringBuffer();
 
 // skip the first 3 characters, they are 'get'
 for(int i=3; i<name.length(); i++) {
  char ch = name.charAt(i);
  if(i>3 && ch>='A' && ch<='Z') {
   sb.append(" ");
  }
  sb.append(ch);
 }
 return sb.toString().replace("Id", "ID").replace("Dt", "Timestamp").replace("Lre", "LRE").replace("Mvno", "MVNO");
 
}
The GUI component I am using is a ZK Grid with each row showing a property value.


 
// put the above java code here.

 

populateRows();

Server Error 500 on Saturday Lotto!

I tried to check my New Year’s eve NSW Saturday Lotto results on their official website, and one group of my numbers consistently resulted in server error 500.

Try this: http://www.nswlotteries.com.au/cgi-bin/results.pl?numlookup=1&game=satlotto&draw=3177&num1=4&num2=37&num3=1&num4=2&num5=3&num6=6

It turns out that as long as the group of numbers only match the supplementary numbers and nothing else, then it will result in errors. In the above example, the actual result of the Lotto draw was: 7, 8, 28, 33, 38, 41 with supplementary numbers 4 and 37.