Wikitten: my own personal wiki

Wikitten

Lately I’ve been looking all over the place for a small, fast personal wiki that I could use to store my notes, ideas and code snippets. I’ve tried a lot of solutions, but none of them really fit my peculiar needs, so in the end I’ve decided to do what every developer does from time to time – reinvent the wheel.

Enter Wikitten, a PHP self-hosted Wiki that parses Markdown documents and code snippets and displays them in a friendly, clean manner. No database necessary, simply drop it somewhere where Apache can run it, and you’re good to go:

dbv.php: Database version control, made easy!

dbv.php: Database version control, made easy!

Over the years, I’ve developed quite a few tools that make my life as a developer easier. Ranging from simple scripts to full blown automatic deployment software, it started to dawn on me that it would be nice to share these tools with the Open Source community, to give something back.

One of the most useful tools I’ve ever made and used, and the one I’ve launched today, is dbv.php, a database version control application that makes it easier for teams of developers to make sure their local databases are always in sync with each other. If your database hasn’t been under version control until now, it should be.

Without further ado, head over to the project website to read about the application’s features, documentation and download links!

Performing arithmetic operations and comparisons on floating point numbers (in PHP)

Why doesn’t 0.7 + 0.1 == 0.8 in [PHP/JavaScript/etc.]?

Despite this issue having been addressed countless times until now, a variant of this age-old question still pops up on StackOverflow on a weekly basis (at least), and since I’ve bumped by own head into it before, I figured writing this down one more time couldn’t hurt, right?

The in-depth explanation for why programming languages cannot properly handle floating point precision has been too well-documented before for me to repeat it here. I strongly suggest reading What Every Computer Scientist Should Know About Floating-Point Arithmetic, but if you don’t have the time or inclination, here is a small quote from the PHP documentation on floating point precision:

[...] rational numbers that are exactly representable as floating point numbers in base 10, like 0.1 or 0.7, do not have an exact representation as floating point numbers in base 2, which is used internally, no matter the size of the mantissa. Hence, they cannot be converted into their internal binary counterparts without a small loss of precision. This can lead to confusing results: for example, floor((0.1+0.7)*10) will usually return 7 instead of the expected 8, since the internal representation will be something like 7.9999999999999991118…

So never trust floating number results to the last digit, and do not compare floating point numbers directly for equality.

The warning at the end of the quote is, of course, doubly important when you deal with numbers that represent money and prices.

The solution

Thankfully, PHP provides a set of math functions to handle arbitrary precision operations and comparisons. The example at the top of the page would therefore become:

bccomp(bcadd(0.1, 0.7, 1), 0.8, 1) === 0;

A lot wordier, I know, and more difficult to read, but guaranteed to provide precise results that you can count on.

It pays to be a statistics geek

Most people are lazy when it comes to gathering data about themselves. I’ve heard a lot of people say “I’m too lazy to track my expenses”, or “Time-tracking is too much of a hassle”. I used to say these things myself actually. Since then, I realized these arguments are only valid at a first glance because indeed, the short-term benefit of gathering any kind of data about yourself is negligible. Perseverance, however, pays in the long run, and I want to share my personal experience with data gathering and how much it actually helped me until now.

Tracking your finances

Four years ago (back in 2008), my wife and I started to keep a list of all our expenses and incomes. This way we could, over time, devise an achievable budget for each category of expenses, make predictions about our savings, etc. Tracking every expense (missing one or two now and then is not a big deal) is a trivial matter but, after four years of continuously gathering this information, the stats we can now put together are quite impressive. This has not only helped us save a little something now and then through proper budgeting, but also gave us a sort of financial security, because we always know how much money we make, what we spend it on over a great period of time (even when unexpected expenses pop up, like medical problems), and can therefore make plans for the future much more easily. We use a custom Excel document for the tracking, complete with pivot tables, dropdown lists and conditional sums (the advantages of being married to an accountant), but there are lots of great expense tracking applications out there, both online and offline.

Tracking your work

About two years ago, I started to use Toggl to track each and every work-related task I work on. When I start working on something, no matter how small a task, I start Toggl’s timer. When I finish a task or I take a break (even when simply going to the bathroom), I stop the timer. At first, I kept forgetting to either start or stop the timer, but now I have got to the point where I do it subconsciously.

Imagine that, I have a record of not only what I worked on for every single day over the past two years but, more importantly, how long each and every task and project took, time-wise. The most important aspect, however, is that I can correlate this data to the income report I mentioned before, and can decide which projects were the most advantageous for me, which customers provide too much of a hassle compared to the financial benefits their projects bring, etc. I think that, as a freelancer, tracking your budget and correlating it with your workload is paramount for a well-balanced freelancing career.

Tracking your entertainment

On a ligher side, about two years ago I decided to add every book I read or want to read to my Goodreads account. It was a small effort at first when I added them, but now adding a new book is as easy as clicking a button. What good has this done me? Well, thanks to Goodreads’s impressive recommendation engine (implemented since they acquired Discovereads), I can now discover books that are very relevant to my interests based on the books I’ve added to my account, the ratings I gave them, etc. I have bought quite a few books based on the recommendations Goodreads gave me, and I’ve rarely been disappointed.

Taking the time to gather a few simple bits of data each day has proven to be worth it time and time again until now. Things like rating each and every movie or TV show I watch (to the point where I now have about 500 movies and shows in my IMDb account), using YouTube playlists as a video archive, and so on may appear to be a hassle at first, but give it a couple of years, the benefits will be evident by then. Doubly so if you’re a stats geek like I am.

Yahoo! Messenger is a bloated piece of crap

There, I’ve said it. I had to boot into my wife’s Windows 7 machine today. While there, I thought “Hey, I should probably start Yahoo! Messenger, as long as I have to spend some time on this laptop.”

The screenshot below is exactly what the main YM window looked liked when I started it. Yahoo! has apparently been shoving layer upon layer of crap unto Messenger’s interface since I last saw it, to the point where the damn contact list isn’t even VISIBLE anymore on my resolution, without having to first close a metric crapton of useless junk:

Yahoo! Messenger sucks!

People need to know that there are alternatives out there, that Yahoo! Messenger has become a bloated piece of stinking crap that they don’t have to put up with. Even if you are tied to the Yahoo! protocol, there are still a lot of better clients that you can use. Do yourself a favor and try one today!