Review: The Ugly Truth About Small Business

Just finished The Ugly Truth About Small Business by Ruth King. I was deeply disappointed by this book. To sum up the entire book: Running a small business is hard so become a motivational speaker instead.

Read More

The Benefits of Profiling

I run the Fake Name Generator, a fairly popular website that generates fake names and addresses. The website offers free bulk orders of up to 40,000 names.

For years I’ve been struggling to make this feature run quickly. The best I’ve been able to get it down to is about 40,000 records in 37 minutes. ~1,000 records per minute isn’t that great.

So yesterday I decided I’d try doing some profiling using xdebug. I set up the test to generate a 40,000 record file. Within a few minutes, the profiler generated a 2GB file and promptly crashed. Hmm. Something was definitely not right.

I dropped the test to 100 records. Within just a couple minutes, a 300MB profile file was generated. Hmm. That seems odd. 300MB profile file for generating 100 records? Hmm…

I loaded it up in WinCacheGrind (which took 15 minutes) and was shocked to see that a date generating function was taking up 90% of the script’s execution time. What the heck is going on?

So I opened up my code and found a glaringly obvious, horrific mistake. My code generates a random month number, day number, number of seconds, etc. However, instead of doing a mt_rand(1,12) — min month to max month– my code was doing mt_rand(1,86400) — min month to max seconds. It then checks if the date is valid, and tries again if it isn’t. This means this function had to run thousands of times before it came even close to generating a valid date.

So the results of fixing the bug? 40,000 records in 3.2 minutes (even better under PHP 5.3: 2.2 minutes).

Moral of the story? Profile your code!

Read More

Painting Pictures

Painting Pictures

A few months ago, I bought my lovely wife some paints and a few blank canvases to go with the easel I made her for Christmas. Well, things have been busy, and my wife hasn’t gotten a chance to use the paints yet.

Well we finally got everything set up, and got her going on her first painting since we’ve been married. While she painted, I read to her from a book off of our bookshelf. We hope to make this a normal Sunday activity.

This is Becca just getting started on the new canvas:

IMGP2446

This is the end of her first day on the new painting:

IMGP2447

Pretty nice so far, huh?

Read More

Review: Negotiating Your Salary

I just finished Negotiating Your Salary: How to Make $1000 a Minute by Jack Chapman.

Although a lot of the information was outdated (the book has a “What to say in Y2K!” promo on the front…), it was an amazing read. I loved it! Chock full of easy and useful tips, sample dialog, and easy to understand explanations, I’m positive this book will help me make more money in the future.

For example, when your prospective employer tells you they are willing to pay (for example) $30,000, instead of being bummed at the crappy pay, you should contemplatively say “$30,000”. You should then “contemplate” that salary for 30 seconds. The person doing the hiring will, most likely, get nervous, and may up that number on the spot, indicate that they can work the number some, offer other benefits, etc. (This is, of course, assuming you waited to talk salary until they actually want to hire you for the job, as you should.)

I’d recommend every employee and employer get a copy of this book. Click here to find it on Amazon.com.

Read More