Phine Solutions web work notes

Is Linux ready for home PC?

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

I have a Dell Inspiron 1000 laptop which was mainly used by my wife for checking emails and some casual web surfing. I installed Xubuntu on it hoping to get the best performance out of the limited horsepower that this old laptop has. It worked OK, until I changed my wireless network security from WEP to WPA.

I found out Xubuntu doesn’t have the support for it. To better phrase it, to get WPA working in Xubuntu, I have to install some 3rd party software like wpasupplicant and make some configuration changes to get it working. Later versions of ubuntu might “just works” as described in this doc, but there seems to be issues around it.

After following the steps in one of the forum thread and failed to make it work I quit. I have to say I didn’t try very hard at it but I didn’t think spending hours on this laptop just to make wireless working made much sense, with work, business and my 2 year old I am not that kind of geek who spend days to get dialup modem working on my Linux machine any more. So I ended up putting XP (Gasp :) back on this machine. As a matter of fact, when XP runs with least graphic candy the performance is on par with Xubuntu running in graphic mode.

I am a person who is pretty familiar with Linux, as a matter of fact I use it every day. I like it. I would recommend it. But do I think it is ready for a average home PC user? No. It is just not simple enough to get some basic things to work. It could be a great OS to be installed in a more uniformed environment, like a lab in a university or an office environment.

A follow up on using Amazon A3

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

Last week Amazon A3 was down for 4 hours and made a lot of webmasters unhappy. It further proves that it is quite risky to design your site solely relying on A3 to provide the essential functionalities, at least for now.

One way to reduce the risk is to have a copy of the files, for example images, saved in your server and design a flag in your code to pull the file from your own server if A3 downtime was detected. The flag can be controlled by some parameter in a configuration file so it can be easily switched.

One might argu this defeats the purpose of using AWS storage since the load copies take up the space. But I believe the storage cost will worth it in the event of the A3 hiccups. By using A3 service when it’s up and running, you will still save the bandwidth when serving those files, which is a lot more expensive than the storage cost.

Document your site with a wiki

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

Good documentation can save a lot of time to look for the information that you have once obtained. I had been looking for some documentation system that can help me to write down notes and finally decided to use a wiki.

Using a wiki can provide some great benefits:

  • It is web based can I can access anywhere.
  • My documents can be organized by sites and category so I have a central place to look for things that I have done but not necessarily memorized.
  • Easy collaboration with others.

There are several free wiki softwares and I chose DocuWiki after some research and test run. Since I only need a simple interface to create structured content DocuWiki was a good choice for me. This is a nice comparison on some popular wiki software that I also used to help me make my decision.

A PHP boolean variable note

Filed under: PHP development — 1.618 @ 10:40 am

I am by no means a PHP know-all so this might have been documented.

If I have a boolean variable, say

boolean x = true;

and if I use it in a if statement like:

if ( x == ‘abc’)

The result will always return “true”.

I believe the PHP version I am using is 5.2.

Is Yahoo making the wrong move?

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

There are a lot of talks around Yahoo’s move recently. Y’s decisions to reject the Microsoft deal and partner with Google on search advertising market don’t sit well with a lot of people. Some think Yahoo is making stupid decisions.

I beg to differ.

Being bought by Microsoft will make a lot of shareholders happy today. But if bought by Microsoft, 3 years from now, will Yahoo still be relevant at all? Choosing to remain independent will give Yahoo a chance. But what about the shareholders? Well shareholders don’t RUN the company. They can make their influence by choosing the board, or cast their vote by selling the stock. I don’t own YHOO so this might sound insensitive. But company shareholders having disagreement with management team is not new and opinions from shareholders who want to sell the stock and cash in should not be used to judge the company’s direction.

Will Yahoo+Google deal hurt Yahoo in the long run? It might hurt Yahoo’s advertising network. But Google is already so dominant in search market and Yahoo may never be able to catch on with its technology today. The key is for Yahoo to innovate and find new ways to establish a stronger brand, not necessary all in the search market though.

Some also have concerns that Yahoo is helping to create a monopolistic Google which will turn evil in no time. Google has 60% search market share because so far its search technology is the best. And it is not so dominant in other areas and Yahoo’s deal will not make it be. I think the key is to believe that technology is alway moving forward, today’s big players will be replaced if they stay still, and there will always be newer and better things coming out. Technology is simply not a business that can be established upon monopoly.

Having said that, the challenges ahead of Yahoo are obvious and I wish them the best of the luck.

Use JQuery to adjust the iframe height

Filed under: javascript — 1.618 @ 2:21 pm

Although frame is generally not recommended on most of the web pages, iFrame can still be useful in some occasions, especially as an Ajax alternative. One strength of Ajax is that it greatly reduces (or at least it appears so) the page response time by only changing a small part of the page. Using Ajax to submit a form is a great example. This usability improvement doesn’t come free though. In order to use Ajax to send the form data back to the server, the JavaScript code has to be written to collect the form data and append them to the request URL as GET or POST parameters. Frameworks like JQuery or Prototype make this process a lot easier.

However there is some limitation to use Ajax to post a multi-part form. Although it might be possible, it is definitely not a clean implementation, and it is not supported by most of the browsers. In this case, iFrame may be a good alternative. The inner frame page will handle the multi-part form and the parent page will have the similar Ajax effect. That being said, iFrame’s biggest problem is that its width and height are set right from the start and it won’t adjust based on the source content. This will leave the ugly scrolling bars around the iFrame, or some content will be hidden if the scroll bar is disabled. For most of the pages, the width is somewhat less of a problem but the height is harder to control and set correctly.

The good news is there are ways to dynamically adjust the height of the iFrame based on the inner content. There are different ways to achieve this using JavaScript. I found this approach is the best:

Using jQuery, we can add the following code in the iframe source content:

<script type=”text/javascript”>
$(document).ready(function() {
var theFrame = $(”#iFrameToAdjust”, parent.document.body);
theFrame.height($(document.body).height() + 30);
});
</script>

The JavaScript will get the iframe object from the parent DOM and change its height according to the size of the current document after the document is loaded (very important to get the true size). I like it because it is less intrusive to the page where the iframe is on, and the iframe source kind of “take care of its own size” when being displayed. If the source page is displayed as regular page, there simply will not be any adjustment. With the help of jQuery the code is quite clean and simple. Of course the iframe source has to be an internal page and the developer has the permission to add the code.

From my testing result, this works in FF2, IE7 and Opera 9.25, not in Safari 3.1 for Windows though.

Some updates:

I found it work better to put the JavaScript which adjusts the frame height in the body onLoad attribute. Basically “ready” function will be kicked off when the DOM is loaded, at which point the page may or may not be completely loaded. The onLoad event will be a better bet in this case since we need the actual size of the page including all the images.

Amazon AWS web service

Filed under: programming in general — 1.618 @ 1:08 pm

Amazon’s AWS webservice has been around for a while now and recently I implemented one of my web site to use the Simple Storage Service (A3). The idea is to utilize the storage space in Amazon’s computing cloud to ease the actual loads on my own web server. In this case, I store the user uploaded images into Amazon A3 storage as backup; and when the images are loaded on a page, they are pulled directly from Amazon A3. By using A3 the web site uses the distributed computing/storage resources and save the bandwidth.

Some of the good reasons to use A3:

  • The service is cheap. We are talking about GBs on the pennies here.
  • The service is quite reliable. I know earlier this year when A3 went down and a bunch of sites that were built using A3 as part of core infrastructure went down with it. But overall the down time is very rare. And A3 load time has also been pretty fast based on my experience.
  • Easy development. The A3 development community is a great place to find resources. For example, this standalone S3 php class pretty much has everything you need to start using the A3 storage.

Although we have a lot of good reasons to use AWS, I still wouldn’t embed too much of it into the infrastructure. The A3 storage in my case is used as a backup source and the actual data can be retrieved from local server by simply flipping a property value in the configuration file. The data update is also initialized by the scheduled cron jobs instead of building into the code. The benefit of this is that A3 is never something that my site has to reply on to stay up. And A3’s performance will not heavily influence the web site’s performance.

I have to say AWS is a brilliant idea and the fact that it came out from an online retail site makes it even more interesting. Here is a brief interview on Jeff Bezos who talked about Amazon’s cloud computing service during the D6 conference in May 2008.

FCKEditor vs. TinyMCE

Filed under: usability design — 1.618 @ 9:59 pm

I am preparing to add WYSIWYG editor to one of my project and looking for some library code to use. The selections narrowed down to FCKEditor and TinyMCE. Both of them look great and perform nicely in the demo. Now comes to the question which one to pick. This article has a nice comparison between the two.

Just found out that default editor in Wordpress is also based on TinyMCE, which is quite an endorsement. I particularly like the capability to resize the editor’s size in TinyMCE.

Use the third party DNS

Filed under: server setup — 1.618 @ 10:47 am

Using a third party DNS have some great benefit:

  1. By outsourcing the DNS look up the load is reduced on your own server, especially like a VPS or dedicated box which runs everything: Apache, MySQL, Named.
  2. Well know DNS operates on a backbone and provide each DNS request with complete redundancy.
  3. Taking the Named service off from your server not only reduces load but also reduces the open port and maintenance work.
  4. An external DNS server will provide better control. This really applies to the domain or sites on shared hosting service and the capability of updating the DNS zone info such as TTL is limited. When it comes to changing the hosting provider, the delay of switching hosting DNS can be unpredictable.

I tried out dnsmadeeasy.com for one of my site and the result was great. It was amazingly simple to create domain name record in dnsmadeeasy account and the change was propagated in a matter of minutes. Another site dyndns.com also provides this kind of service with the similar fee structure. Using the free DNS check service from intodns.com (dnsstuff.com requires fee now) is also recommended to make sure everything is in order.

Simple command to find out the directory disk usage

Filed under: linux goodies — 1.618 @ 8:37 am

ls -F | grep “/” | xargs du -hs

For admin to snoop everybody, try

ls -F | grep “/” | sudo xargs du -hs

« Previous PageNext Page »

©phinesolutions.com