Phine Solutions web work notes

A nice feature on Bing

Filed under: my 2 cents — 1.618 @ 3:01 pm

Bing is the new search engine from Microsoft, although they call it “Decision Engine” we all know it is just a branding trick. I used it a little bit and I was pleasantly surprised.

The feature I really like is the preview feature. For example if you search for “PHP tutorial” you get this page:

http://www.bing.com/search?q=php+tutorial&go=&form=QBRE

A page from php.net is listed as the first entry, which is in my opinion, beats the result from Yahoo. What’s more, you can hover your mouse on each entry of the result page, a little link will appear on the side and you can use your mouse to activate it to show a preview of the page. I tested several queries and the previews are very accurate. The preview also shows other links on the page that are relevant to the subject, which help to decide whether this page is “click through worthy”.

I don’t know if Bing can dethrone Google on web search, and as long as Google continues delivering the relevant results it is hard for anyone to make a legit threat on its dominance. But MS seems to have some nice things going in Bing just off the bat. Since Google relies on its search engine for most if not all its revenue, MS has an advantage here to make some bolder move, and be more innovative, like a real decision engine that was just released: hunch.com.

Trying out Google Web Toolkit

Filed under: javascript — 1.618 @ 9:08 pm

After watching some Google IO keynote videos I got interested in Google Web Toolkit and played with it a little bit. It is quite an interesting tool. Basically the tool helps Java developers to develop JavaScript using the familiar Java programming language on familiar development IDE such as Eclipse. And probably more importantly, it takes care of the nittygritty details such as browser compatibility and code optimization. So one can write it once and be pretty comfortable about running the code on different type of browsers.

Unlike other Java to JavaScript frameworks (jMaki for example) that require actually to be hosted in a Java VM container, GWT produces the client side JavaScript code as a final product. So Java, in this case, is just a tool, not part of the end result. Of course, if there is server in the backend to handle the RPC calls,  Java Servlets can be used to facilitate that, but it is not mandatory.

GWT is not just a tool for Java developers who don’t like coding JavaScript. It also put AJAX into better perspective by separating the client and service code in the code base. Using JSON as the messaging protocol between the client and server, a GWT client application can talk to any web server that speaks the language, which doesn’t have to be implemented in Java. GWT also provides a way to work around SOP - the Same Origin Policy.

SOP is the security policy that is in the web browser to stop a client script to communicate with web server that the script is not originally from, in another word, any arbitrary web server. This is a necessary security measurement, but it makes the client less distributive. For example, a web service provider would like to distribute a small version of client script, which can be embedded in any web sites, and get the dynamic information from the service host. GWT handles this by requiring server to return JSON output in a “<script>” tag, and a callback function will also need to be defined to handle the output.

With the advance of web technology, JavaScript will play much bigger part in rich web applications in the future. I think the biggest strength of GWT is its capability to scale up the size of a JavaScript project. Following the Java’s footprint a project created using GWT can be better managed, tested and collaborated among developers.

One drawback is that one has to be familiar with Java. And obviously there is a little bit of learning curve on those GWT GUI APIs. Nonetheless it is a great tool for Java developer to natually adopt and use to create some great JavaScript applications.

I gave up on Vista

Filed under: my 2 cents — 1.618 @ 10:50 am

So all of sudden my wireless connection stopped working and I couldn’t “repair” it no matter what I tried. So I hit the reset button and guess what, Vista wouldn’t start. It just froze in the midway. I tried to repair the OS with the installation CD but it couldn’t fix it either. No errors reported, just stuck.

Luckily safe mode did work so I was able to back up all my files and made decision to re-install the OS.

I do have some decisions to make.

1. Re-install Vista. No way after this.

2. “Upgrade” to WIndows 7 RC. I don’t think I can trust this OS yet since it is just out of the oven.

3. How about Ubuntu? I do like it. However, I don’t want to have to load a “Windows” inside it so I can use some Windows Apps that I use every day.

So in the end I chose the good old XP.

It turned out I probably have a broken wireless adapter. It is a Buffalo WLI2-PCI-G54S card. In XP, when I tried to install the driver the system froze again and the installation screen shows “copying cbg54.sys”. Hard reboot is the only way to bypass this, but at least XP starts.

So the story pretty much ends here. It was probably a hardware issue and I don’t know if Microsoft is the one to blame here. Nevertheless it doesn’t seem Windows OS is handling this in a graceful way, or anyway at all. An OS with a good kernel should at lease prevent this kind of issues from making the whole system useless.

Oh by the way, I can’t believe I would say this, after a few monthes use of Vista, XP feels so clean and easy. I wouldn’t go back to Vista again even all the issues and concerns are addressed.

A great book to learn JQuery

Filed under: my 2 cents — 1.618 @ 9:18 pm

Being a half-baked JavaScript developer for a long time it wasn’t easy for me to grasp the concept like “selectors”, “traversing” and “utilities” in JQuery, and every time I started to write something using JavaScript it was always a series of events of Googling for sample code, checking the API, and Googling again for the right syntax if it doesn’t.

Recently I found this book “JQuery In Action” from Amazon and I was quite pleased after reading it. The information in the book is well organized and illustrated. And the authors explain the concept before digging into syntax and examples, so you not only know how to do code in JQuery, but most importantly, why to do it in this way.

My favorite subjects in this book are “understanding browser event models” (chapter 4) and “JavaScript that you need to know but might now”, the later is actually an appendix. They fill the gaps in my JavaScript knowledge and brought some new but important perspective on how it really works.

The lab code is great and it will probably help me quite a bit for my future projects.

So if you want to get serious about JavaScript programming, get this book. It’s definitely worth the read.

Mac OS X Time Machine saved my day

Filed under: my 2 cents — 1.618 @ 8:38 pm

I had a couple of files on my Macbook which I accidentally deleted without knowing it until a couple of days ago. They are quite important files and without them I might have to spend hours to recover the loss. So I gave the Time Machine a try. It was simply amazing. I went into the Time Machine and typed in the key words that I vaguely remembered and hoped for the best. The Time Machine started to search all the saved points and in seconds it found those files out and I was able to restored them.

I keep my files on my machines regularly backed up, but I honestly can’t think of anything else that can do this good job on keeping different backup points of the system and make them easy to retrieve. I guess this is especially useful for me since I love doing cleaning up on file that I don’t recognize :).

IE session cookie problem

Filed under: my 2 cents — 1.618 @ 7:18 pm

So I ran into this issue. It appears under certain set up, IE will reject a session cookie, or randomly drops them. I use PHP session to store user authentication information and some of my IE users were not very happy about not being able to log in or getting kicked out of a login session randomly.

The biggest challenge is to duplicate the issue. IE’s security and privacy settings can both affect the way it handles the cookie, and even the same settings on different PCs can have the different result. It is absolutely frustrating to have users shouting at you “This doesn’t work!” while everything works perfectly fine on my own machine.

After a lot of research I ended up completely abandon the session approach and use a database back end to handle the user authentication sessions. A regular cookie is still necessary to store a token (ex. a user id) to identify the user, but instead of using the SESSION variable, I use a database table to store the user token and the last access time. This will certainly complicate the setup - a cron job has to be installed to perform the database clean up; and the increasing the database queries - basically for each access from a “tokened” user I’ll need to update the last access time - will also add some tolls to the performance. However the payoff is also obvious. I don’t have to worry about the different IEs out there, who may behaves differently and sometimes in unexpected mysterious ways thanks to Microsoft, to reject my delicious cookies.

Just for the sake of discussion, there may be a number of reasons that cause IE to reject session cookie:

1. To many cookies from a site, or IE runs out of temporary space. There is a max number of cookies that a site can send. I think 20 is the limit. A lot of good discussions can be found on this thread.

2. IE’s P3P implementation might also have something with it. This is a good article about IE’s Eye of Sauron. There are some suggestions to bypass this by adding a P3P header, which is as simple as a line of characters to your pages. I don’t like the idea mostly because this is not the right way to fix a problem which shouldn’t exist in the first place.

3. There might be a slightly chance that your server time stamp is out of sync. For example when you set a regular cookie use something like “time() + 28400″ in your PHP code to specify the expiration time, wrong time stamp might put your cookie in the history already. This issue is a lot easier to spot since none of your sookies work, not just the session cookies.

Problem loading the Google map API javascript

Filed under: my 2 cents — 1.618 @ 9:00 am

It’s interesting. Firefox has problem loading a page with this line in the html header:

<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=google_api_key” type=”text/javascript”></script>

At first I was suspecting Google server was down but it turned out the page would load just fine if I disable (suspend) Firebug extension (1.3.3).

However if I put the line toward the end of the page as inline Javascript everything seems fine even with Firebug on.

Deleting files from a network shared drive - Vista vs. Mac OS X

Filed under: my 2 cents — 1.618 @ 10:20 pm

I have a Buffalo LinkStation on my network which I use as a back up for all my house hold PCs. Recently I was doing some house cleaning on the drive and saw a “trashbox” folder in each configured shared drive, and it stores all the previously deleted items from shared drive. The “recycle bin” feature can be disabled by going to the LinkStation configuration page, and uncheck the feature in each shared drive which is quite simple. But deleting the actual “trashbox” turned out to be a painful process in Vista.

Like the way I perform file deletion everyday, I right clicked on the folder and select “delete” from Vista. A usual popup window started and showed the progress. However it seems Vista can’t make up its mind in terms of how many files are there to delete and how long it’s going to take. The information changed back and forth and the deletion process went on and on. At some point it became painfully slow and I started to suspect there was something wrong with my network, or the shared drive.


Looking at the number of minutes left on the progress window really frustrated me so I decided to use my MacBook to give it a try.

It’s pretty simple to connect to a shared drive from a Mac. Since AppleTalk protocol was enabled in the drive Mac recognized the IP and connected to it immediately. Deleting the files was also a lot smoother. Mac didn’t change its mind on how many files it needed to delete and the process went just like it promised.

I believe the LinkStation is actually Linux based and used Samba for file sharing protocol. Maybe because of the nature of the OS, Mac handles this kind of device better. But Vista was just disappointing. WIth the flux of the rich web applications today, a reliable and simple OS which has great attentions to details will be the ultimate winner.

Google search result problem

Filed under: my 2 cents — 1.618 @ 10:16 am

This morning I wanted to search some Ringling Brothers tickets and I hit the big G. For some reason almost all the top search results have this warning “This site may harm your computer”. And a warning page would display if I click through it.

This is weird. I know those sites are very legit. So I tried some other keywords it seemed all the organic search results on the top are “labeled”. Using another data center showed the same result.

This became very annoying very quickly. This is probably a Google glitch. With people increasingly relying on search engine to look up information maintaining the service quality becomes more and more important.

Update:

Here is why.

Generate a sitemap for your site

Filed under: my 2 cents — 1.618 @ 6:49 pm

I have been ignoring the sitemap for a long time. It is nice and easy for the Wordpress powered site since there is plugins for that but for other sites I have to write a script to do it. Finally I decided to add it.

Google has a nice sitemap generation tool here. It is written in Python but don’t be scared away if you don’t know Python. I don’t. And it took me about 2 hours of work to set it up (including other scripts that I had to do). Here is what I did:

1. Wrote a PHP script to generate multiple URL files. They are basically text files which have URLs in them. It is one of the ways to feed the Python script to generate the file sitemap.xml. There are other ways too, but this one is the most suitable choice for my situation. The “feed”, among others, can be configured through a config.xml file and the Python script will pick it up. So there is no need to mess with the Python code at all, at least at this point.

2. First I ran my own URL generation script, and then the Py fella. The script can be run from the command line and at the end it will automagically ping Google to notify the updated sitemap.xml. Oh, did I mention you have to have Python installed on your server? I really don’t see why it’s not there if it is one of the Unix cusines but it doesn’t hurt to verify it.

3. I manually submitted the sitemap.xml to Yahoo and Live search. If you haven’t signed up your site there you’ll need to login (assuming you have an account) and add your site.

4. After some staring at my Unix console I started thinking, “since the Python script can notify Google, why not the other two?” So I dig a little bit into the Python script. Although I didn’t know the language it didn’t take me long to find out the location of “NOTIFICATION_SITES”. It is an array that has the notification list of the sites. This is what you can change it to to make it ping Yahoo and MSN/Live as well (while they are still two companies). :)

NOTIFICATION_SITES = [
('http', 'www.google.com', 'webmasters/sitemaps/ping', {}, '', 'sitemap'),
('http', 'webmaster.live.com', 'ping.aspx', {}, '', 'siteMap'),
('http', 'search.yahooapis.com', 'SiteExplorerService/V1/ping', {}, '', 'sitemap')
]

5. Combine these command lines into a shell script and stick it into the cron.

So there you have it. Now I am just waiting to see the floor of traffic that will be brought in by using a sitemap. :)

Next Page »

©phinesolutions.com