Book Review: Even Faster Web Sites

Today’s Web developer knows that the speed of one’s site is an important measure to its overall success, and Steve Souders’ previous book, High Performance Web Sites (O’Reilly), laid out what seemed to be every way to achieve good performance gains without the sacrifice of functionality or aesthetics. When I began reading Souders’ Even Faster Web Sites, I therefore wondered how he could possibly demonstrate fresh ways to achieve performance gains without regurgitating the content of his previous book. What I discovered as I read Even Faster Web Sites was it presented all new best practices for making your web sites “leaner and meaner” without repeating the content of his last book.

Even Faster Web Sites takes the latest techniques available to developers and organizes them into three performance areas: JavaScript, network, and browser. Though I believe Souder knows what he is talking about regarding web site performance, I found it refreshing this time around that he had the contributions of other experts in the field to give their ideas on performance gains in these areas.

I thought the chapters on JavaScript, especially those discussing Ajax and asynchronous techniques, were well written and gave good, new best practices to trim time off the loading of content on a site.  I also appreciated the chapter dealing with Comet, as these technologies are surely a driving force for future web applications, and having best practices early in their development will only help their progress.  Of the two chapters on browser performance, I found the honesty of the discussion on the downsides of using iframes most helpful, especially when their use was discussed as a viable technique for improving performance early in the book.  I did find the chapter on CSS selectors extremely useful for analyzing where slowdowns in styling may exist based on browser implementation.  The chapters on network performance gave a good background on common hindrances such as connection limits and poor image choices, but also walked through what I felt were performance gains that can be made through less utilized techniques like chunked encoding and better compression.

Souder finished this book with an Appendix on performance tools that can be used to help in the improvement of a web site, which I found to be immensely helpful.  While many tools he listed are well known to developers, there are some I was unaware of and began making use of immediately on my own sites.

Even Faster Web Sites is an excellent follow-up to High Performance Web Sites, giving new best practices for making your web sites even faster.  As I see it, even hundredths of a second begin to add up when you put all of these techniques together, and most of the techniques presented in this book are practical for any web site being developed.  I would recommend this book to any developer looking for ways to improve the performance of his web site, as Souder has certainly demonstrated his knowledge and expertise on improving the speed of a site.

***** (5 stars)

The Profitability of myFarm Plants/Trees

I have been doing a lot of thinking as to the value of purchasing plants/trees on my own for my farm instead of waiting for friends to give them to me as gifts. This led, inevitability, to wondering how profitable each type of plant/tree really was, so I decided to do a little calculating to find out.

I started with the basic knowledge of how much a plant/tree costs, how much a harvest is worth, and the fact that an initial harvest is six days after planting followed by a potential harvest every three days thereafter. The formula for calculating the break-even days for any given plant/tree is fairly simple – take the cost to buy and subtract the harvest price to give you a starting point six days out, and then divide this by the harvest price to get the number of harvests to break even. This number should be multiplied by three (the days per harvest) to give you the number of days (plus our initial value of six) needed to break even on the plant. Simple enough, right? To see this in action:

Apple trees cost $500 to buy, and have a harvest price of $58, so 6 + (((500 – 58) / 74) * 3) = 28.9 – basically 29 days to break even with the purchase of an apple tree. It becomes profitably at the next harvest (one day later), so round up to the next multiple of three to get the days to profitability. In this case, the days to profitability of an apple tree are 30 (given that you cannot harvest a tree early.)

Since I like tables and graphs, here is a table with the calculated days to profit for each of the available plant/tree types in myFarm. Note that Christmas trees become profitable on their first harvest (after six days) simply because you cannot purchase them as they are always gifts.

Plant Cost to Buy Harvest Price Days to Profit Calculation
Christmas Tree n/a $220.00 6 * profit at first harvest
Orange Tree $500.00 $74.00 23.3 (24) (((500 – 74) / 74) * 3) + 6
Pear Tree $500.00 $68.00 25.1 (27) (((500 – 68) / 68) * 3) + 6
Plum Tree $650.00 $86.00 25.7 (27) (((650 – 86) / 86) * 3) + 6
Banana Tree $550.00 $69.00 26.9 (27) (((550 – 69) / 69) * 3) + 6
Apple Tree $500.00 $58.00 28.9 (30) (((500 – 58) / 58) * 3) + 6
Peach Tree $700.00 $82.00 28.9 (30) (((700 – 82) / 82) * 3) + 6
Cherry Tree $800.00 $84.00 31.6 (33) (((800 – 84) / 84) * 3) + 6
Mango Tree $900.00 $77.00 38.1 (39) (((900 – 77) / 77) * 3) + 6
Coconut Tree $1,100.00 $88.00 40.5 (42) (((1100 – 88) / 88) * 3) + 6

This is a good table of data, but what is more important to long-term growth of your myFarm income is what plants are good to invest in. Remember, this is strictly speaking in terms of purchasing the plants/trees yourself; if the tree is a gift, refer to my plant/tree table in my previous post on myFarm. Ironically enough, after one year of harvesting from planting, the value of the plants/trees almost follows my original table of worth. For one year, in order from greatest value to least, are Plum, Coconut, Cherry, Peach, Orange, Mango, Banana, Pear, and Apple. The differences are the Plum and Coconut tree is reversed as is the Orange and Mango. If you kept the plants/trees for longer periods of time, this sorts itself out.

This final table shows the worth of trees at different intervals to the first year. This should help you determine the profitability of a plant/tree for shorter-term interests.

Plant First 100 Days Harvest Net First 200 Days Harvest Net 1 Year Harvest Net
Plum Tree 25 $2,150.00 58 $4,988.00 113 $9,718.00
Coconut Tree 20 $1,760.00 53 $4,664.00 108 $9,504.00
Cherry Tree 23 $1,932.00 56 $4,704.00 111 $9,324.00
Peach Tree 24 $1,968.00 57 $4,674.00 112 $9,184.00
Orange Tree 26 $1,924.00 59 $4,366.00 114 $8,436.00
Mango Tree 21 $1,617.00 54 $4,158.00 109 $8,393.00
Banana Tree 25 $1,725.00 58 $4,002.00 113 $7,797.00
Pear Tree 25 $1,700.00 58 $3,944.00 113 $7,684.00
Apple Tree 24 $1,392.00 57 $3,306.00 112 $6,496.00

After all this, I think I will stick with hoping my friends send me plants/trees as gifts.

Facebook myFarm Farming Guide

I know this information has been posted in other places, but it is not necessarily easy to find all of this information in one place with a Google search.  The myFarm application on Facebook is an addictive little app, and this little guide should help others who are looking to make the most of their farming experience.

First, I want to discuss crops, which is a hot debate topic amongst the players of myFarm.  The following tables shows the available crops, and the prices associated with them.

Crop Seed Cost Prod. Sell Price Per Plow Cost Harvest Days Gross Sell Price Net Sell Price Net Price For 1 Harvest Day
Strawberries $33.00 190 $0.52 $20.00 1 $98.80 $98.00 $98.00
Tomatoes $133.00 165 $1.23 $20.00 1 $202.95 $201.00 $201.00
Rice $37.00 290 $0.45 $20.00 2 $130.50 $129.00 $64.50
Corn $127.00 185 $1.27 $20.00 2 $234.95 $233.00 $116.50
Wheat $81.00 240 $0.84 $20.00 3 $201.60 $200.00 $66.67
Potatoes $144.00 220 $1.31 $20.00 3 $288.20 $285.00 $95.00

The table indicates that for single day harvest investment potential, tomatoes are the way to go.  I like to plant as many tomatoes as possible, with strawberries for the remainder, if I know I will be able to check my crops daily.  In the event (such as a weekend) that I cannot check my crops each day, I plant based on harvest time according to Net price.  Simple as that.

Crops are not the real money makers of myFarm, however.  Making money is best accomplished by getting gifts of trees and animals from friends.  This way, there is no upfront costs for your potential harvest/sale.

You will not make money from buying and selling animals on your own; there is no profit in it.  There will be potential down the road for what animals can produce, but for now, sell only what you are given as a gift, or hold on to your animals for future myFarm game developments.  The same goes for cutting down trees — it is much better to harvest trees than cut them down, especially since there is no indication that trees will die any time soon.

The following table lists the costs associated with plants, which should give you an idea of what profits you can make from them. Remember, it takes a planted tree six days to grow to fruit, and then the tree will fruit every three days after this.

Plant Cost to Buy Harvest Price Cutting Price
Apple Tree $500.00 $58.00 $175.00
Banana Tree $550.00 $69.00 $206.00
Cherry Tree $800.00 $84.00 $253.00
Christmas Tree* n/a $220.00 $660.00
Coconut Tree $1,100.00 $88.00 $263.00
Mango Tree $900.00 $77.00 $232.00
Orange Tree $500.00 $74.00 $223.00
Peach Tree $700.00 $82.00 $246.00
Pear Tree $500.00 $68.00 $203.00
Plum Tree $650.00 $86.00 $258.00

* Christmas trees are only obtained through gifts from The King

This final table lists the costs associated with animals, which also should give you an idea of what profits you can make from them.

Animal Cost to Buy Prod. Price Selling Price
Chicken, White $1,200.00 none $29.00
Chicken, Barred Rock $1,400.00 none $143.00
Chicken, Rhode Island $1,300.00 none $143.00
Cow $550.00 none $114.00
Goat $600.00 none $64.00
Horse, Black $1,000.00 none $100.00
Horse, Brown $500.00 none $71.00
Horse, Gray $500.00 none $71.00

You can imagine the potential for some of the livestock (chickens lay eggs, cows and goats produce milk), so it might be a good idea to hold onto your animals at this time. After all, we’ve been told selling eggs through the chicken coop is around the corner.

Enjoy myFarm…I know I do.

Creating a random password with PHP

I have been working on getting my domain back up and running, when I ran into the need for new functionality to automatically create a random password for a user should he or she have forgotten theirs.

The following is a partial solution to what I came up with, along with commentary on what the rest of the functionality entailed.

First confirm that the user is indeed who he or she claims to be.  Good ways of doing this are getting a full name, email address, maybe even a birthday.  Next, for my site I give the ability for a user to create their own secret question and answer to go along with it.  This affords a little more security than having canned secret questions — not much, but a little.  The secret question is presented, and when a correct answer is given, I create an email that sends the random password to their account.

Simple enough, so here is the code for the random password part of this solution:

$chars = 'abcdefghijkmnopqrstuvwxyz023456789!@#$';

srand((double)microtime() * 1000000);

$passwd = '';
for ($i = 0; $i < 10; $i++)
    $passwd .= substr($chars, (rand() % 37), 1);

You will notice that in the $chars string I omitted the characters l and 1. I did this because these two characters could be confused with one another, which is something you do not want when sending a random string to a user.

Simple enough. Enjoy.

Harumph!

I am at a loss for words to describe my feelings towards this announcement.  Stupid money-grubbing executives…

Next Page »