Sunday, December 20, 2009
Reading List
Book 1. Learning Python, Mark Lutz and David Ascher, O'Reilly
Book 2. Beginning Unix, Paul Love, Joe Merlino, Jeremy C. Reed, Craig Zimmerman, Paul Weinstein, Wrox
Sunday, December 13, 2009
Get Request Header in Restlet
Calling getRequestAttributes().get("org.restlet.http.headers"); will return all the headers in the request. However, the type of returned result is "org.restlet.data.Form". Consequently, we need to convert it into the Form format, and then using the getFirstValue("") method to retrieve the value. One catch there is the key is always start with capital letter, for instant even is "location" in the header, you have to use "Location" instead.
Form headers = (Form) getRequestAttributes().get("org.restlet.http.headers");
location = headers.getFirstValue("Location");
Wednesday, December 9, 2009
Solve the annoyance with Eclipse Access Restriction
is not accessible due to restriction on required library /usr/lib/jvm/java-6-sun-1.6.0.15/jre/lib/rt.jar.
After several times checking, there is no reason to properly explain and your program gets to stuck since no compilation is allowed when error existed.
One way to work around this issue is by resetting the configuration in the Eclipse project properties. Right click the project name, get into its properties and the Java compiler tab. There is an Errors/Warnings line listing there, select it, and update the Forbidden Reference (access rules) into Warning in the Deprecated and restricted API. Then rebuild the project, and problem solved.
Similar errors can be handled in the same way.
Monday, December 7, 2009
How to invoke a remote web service in GAE
You are not allowed to use any library related to .net package which may possibly generate more threads. But in order to make any invocation of other RESTful web services, we need to do something to both satisfy the requirement of Google and us.
In the official document, GAE recommends to use the HttpURLConnection class, which is a little bit too simpler to use, which means it brings various problems when dealing with complicated data types.
Here I will invoke a remote RESTful web service which will accept the format of JSON. Here is the code:
try {
URL url = new URL("http://localhost:8183/users/" +user+"/content");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
String json = content.toJSON().toString();
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(json);
writer.close();
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("sssssss");
} else {
System.out.println(connection.getResponseMessage());
System.out.println("ffffffff");
}
} catch (Exception e) {
e.printStackTrace();
}
Looks easy, ha, yep, quite straightforward. Remember to add those content-type in the connection for the receiver to recognize the format you are sending. While you are only allowed to send String or Char[], so hurry up and write your own parsing functions.
Sunday, November 1, 2009
Kick off my new career path
Anyway, I have never try to use Linux before, and after one day living with Ubuntu, I guess in the future I might be a big fan of the Linux family although Win7 has just come out of the water. I prefer this feeling with professional study and work, and I'm more happy to get payed by this.
I'm going to write more in this blog to record my working life in Melbourne, and also some technique skills or tips or summaries as I walk through this project.
Wednesday, July 8, 2009
Download All Mails to Client Mail Box
It is a great application with email receiving and sending. However, two problems blocks me a little while for configuration. One is each time you close the box, it will really exit but not minimize to the system tray. Actually this is pretty annoying that at first I just feel strange how can I not receiving any mails for half a day. OK, so what you need to do is download a plug-in to enable the minimize ability. Just Google it and you will definitely find it.
Another serious problem is I can only download those unread emails from GMail which always affects my working when I try to fetch those old mails. At first I thought it is a problem with the configuration of Thunderbird, and finally I figured out I owe an apology to Thunderbird. Yep, it is just one single click on the setting with GMail.
Log into your GMail account, in the setting panel and Forwarding and POP/IMAP tab, you will see a POP Download option, select it to enable POP for all mails, then start your client to receive. Done.
I guess this solution will be suitable for all kinds of client applications.
Monday, June 29, 2009
SEO Strategies – from “Building Findable Website”, Aaron Walter
2. Decrease the ratio of markup to content, improve the page load time and improve the communication of the information hierarchy of your page.
3. Image Replacement:
Replace the img tag which shows the logo or the most important information of this page with a <h1> tag. The content of <h1> tag will be the details introduction of the page or the logo, with indentation to place that can not display on the screen, and a background image setted to be the real image file with its name renamed to be more meaningful. This strategy can only be used once for any certain page since it is better to limit the <h1> tag into only once for a page.
4. Signals of Quality:
1) Number of inbound links to the page from reputable sources, which is the way Google does.
2) Web standards are not 100 percent gurantee of top page ranking, but important to it. Therefore pages should follow the standards as closely as possible.
5. Highly valued tags for search engines:
1) <title>, keep it concise and natural. <title> page title | organization or site name | short keyword-rich phrase </title>
2) <strong> and <en>, elevating certain part of the content’s ranking within the information hierarchy
3) <a>, title attribute inside <a> tag, and also include target keywords in the link labels. An inbound link with the same keyword in the label as your site target is extremely effective.
6. Meta:
1) keywords in <meta> is useless, while description is still important. Limit the characters in <description> between 100 to 150 which is better for search engines to display.
2) use lang for multilingual site, like <meta name=”description” lang=”en-us” content=”" /> and <meta name=”description” lang=”zh-cn” content=”" />
3) No need to use robots in tag. <meta name=”robots” content=”all” />
4) Never use refresh attribute since it might be penalized for bait-and-switch strategy.
5) Always include content-type.
6) Use <meta name=”robots” value=”noindex,nofollow” /> to prevent certain page be indexed by the search engine.
Add class=”robots-nocontent” to those tags that you wish to hide like ads.
7. Making Images Visible:
1) When the image is just used for decoration, apply it to css file as a background.
2) Always use alt attribute to give short introduction of the image
3) If alt is not long enough, use longdesc instead, which can link to a footnote to have more details.
Thursday, June 11, 2009
Recently
A lot of incidents happened recently, like the air crash AF447, swine flu, bus burning in China, and curry bashing. I think the world, right now, is in a very unstable status that even a little touch may change the whole situation. Similar like the butterfly effect, but more disastrous. I believe everybody can feel the difference in our environment compared to just decade ago. Maybe all the things happened to us is just a punishment from the nature and also a warning for us to pay much much more attention to our behaviors. I'm a little bit afraid of what will going to be in 50 years or so, it will be very difficult to deal with such a complex problem in such a late time.
Back to my personal stuff, even it is a vacation, I have to stay at Melbourne without any outing plan until now. My parents had cancelled their trip to Australia because of the swine flu, which also cancelled my trip to Perth or Brisbane. Anyway, I still got lots of opportunalities to fullfil my desire. Yep, my flight from Singapore to Hong Kong and return have been upgraded to A380, which is the first time for me to taste the giant superjumbo. I'll definitely shoot many photos and really looking forward to it.
During this two months vacation, I will try to finish my MEDC project with Dr. James, and another VOIP project for SUN with Dr. Ariff. I hope things will turn out to be better than my nowadays condition that I have waste too much time on unnecessary matters. Now it is time for me to cheer up.
Melbourne is cold though, I'm ready to the coming chanllenges. And I will also add several functionalities recently to make my blog more powerful, and also increase the frequency to update my English blog.