Categories
Technology

CodeIgniter Playground

After some tinkering with CodeIgniter, i’ve setup a small playground (which will hopefully grow over time) to test drive the framework.
I like the framework for it’s lightness- and you get quite a lot of control without having to rely on helpers to do _everything_. You can learn the helpers as you need to, so getting something up and running is easy enough and requires no massive investment in a proprietary methodology, terminology, apiology or documentology.

As for rhe RoR-ish slant. It is well… erm… RoR-ish. But really, nothing beats RoR. CodeIgniter is not bad. Rails still kicks!

Categories
Technology

A Dev Environment with Trac+Subversion

Setting up development environments is something you do once in a while- hopefully. And over time, you tweak different areas and add in bits and pieces here and there and it evolves. Nicely. And then you get to do it all over again 🙂 But then you got to go back a couple of months/years and look at it all over again. Thank goodness for tutorials!

Incidentally, another good reason to make the effort to document (read blog) that learning, or even just link that learning into your own blog. You never know when you gonna need it again…

Setting up Trac and Subversion on Ubuntu

This is probably about the most comprehensive and easy to follow guide i’ve come across so far. It has all the basic necessities to serve as both a refresher and get you up and running quickly. There is one small “typo” but you should spot it quickly if you’ve done this before. It refers to the root web folder for the trac setup.

Categories
Life

All In One Month

What a month! 3 exams, a couple of teeth and a brand new baby boy. If you got kids, you’ll understand, right?

So if you ever end up having to plan something like this (not that you can always consciously time it so well) then i have a a tip for you…

Make sure you got a loving, enduring and patient wife backing you up and supporting you all the way. It makes it seem so easy. Thanks, Lolly! You simply rock! Your honorary degree is almost there 😉

Seriously. Jack was due just after the first exam, Macro Economics. So we figured it’d be alright ‘cos we’d have two weeks before starting to prep for the next two to settle in. Then Jack decided… “Neh. Too warm and cosy in here, thanks. Think i’ll stay a little while longer.”

8 days later (over due), little Jack says: “Hello, world!” That was one week before my last two exams: Financial Modeling and my major: Applied Mathematics. Oops = MC^2?

Needless to say, we -and i do mean “we”- decided to forge on and today, on my last exam, as soon as the invigilator said: “Pens down. Your time is up.” a chorus of angels hauled out the trumpets and started singing “Hallelujah!”. Shew!

Until next year…

Categories
Life

Put It In the Bond?

If you’re servicing a mortgage at the moment, and you happen to come into some money, the “best” advice you’re probably going to get is: “put it in your bond”. Not bad advice, i guess, but i’m not so sure it’s the “best”.

**DISCLAIMER: I’m NOT a financial advisor; am not pretending to be one; and certainly not qualified to be one. But i can kinda do the numbers, so this looking at it purely from a mathematical perspective.

When it’s not really the “best” advice is when you are servicing other debt, at higher interest rates. Then the numbers say: kill that debt first, and _then_ look at the mortgage. So if you’re servicing a credit card, overdraft or vehicle finance (which can typically be higher than prime) and your mortgage is sub-prime, service the higher first.

But more personally, i recently faced the opportunity of trading in my vehicle for a newer one (which would have been nice) and i was figuring out what to do with the trade-in amount and work out where it would best pay dividends. On an aside, i’m of the opinion that buying a vehicle is NOT a financially smart move at all- no matter how you try slice the numbers. You will always lose (and i’m not referring to collectors’ classics). So look after your car- treat it nice, drive nice, service it regularly so you can leave it in your will. After all, it’s __just__ a car, right 😉

So down to the maths… Note: the numbers have been changed slightly to protect the prudent.
New car: R150k at 15.5% APR over 60 months.
Existing debt: R640k mortgage (±30 months into the schedule) at 14% APR over 20 years.
Trade in on car: R50k. What to do with the R50k? A) Plough it into the bond. B) Use 100% of it as a down payment on new car. A or B, what do you do? The “best” advice i received was plough into the bond and save thousands in interest on the bond! Uhuh. That’s half the truth.

As a down payment on the new car, I reduce the repayments from R3.6K to R2.4K, and end up saving, in effect, R44k in interest over the term. Not bad, not great.
In the bond, i reduce the interest _over the same term_ by R33K. Worse. But not a surprise. And that’s the important part here: the same term. 60 months. You see, over the remainder term of the mortgage, that advance payment will save you A LOT! But now you’re comparing a value of money of two different terms: 60 months versus N years on the mortgage, so don’t be too surprised if you draw bogus conclusions. Afterall, once you’ve finished paying off the car, you’re R3.6k deeper in the pocket which you can then plough into the mortgage anyway.

So, on face value, it’s more favourable, over the same term, to service the vehicle as quick as possible and then see to the lower interest obligations. But there are better options… which is the other half of the truth: discipline.

Add in some fiscal discipline into the mix, and suddenly your options are wild. For example…

Put down the down payment on the car, saving an extra R1.2k in repayments each month on the car, but then put the saving into the mortgage over the same term. Suddenly you start to save R64K in interest. Mmmm… Or…

And then there’s this. Which really was the best option (Thanks, A)…

Take your old car for a shmancy valet at about R200, pretend it’s new and “pay for it” anyway at R3.6k per month. Now you’re saving close to double your previous best!

The bottom line is; if you’re in the market for a car and can afford X, but you’re servicing other debt, service that debt first- forget about the car*. Unless it’s an absolutely necessity (and looking better than the Jones’ is not a necessity- i checked) you probably don’t need it.

*Forgetting about the car, probably anywhere in the world, is really hard to do though. In South Africa, households spend a disproportionate amount of their disposable income on vehicle financing, which says a lot about how we feel about our cars. Somehow, cars have so (too) much appeal. So much so that having 4 reliable wheels is just never enough. There’s always going to be something really “cool” about a car that makes you just wanna have it. And the price tag is just irritating. Can you say X-Trail… or Fortuner? 🙂

Categories
Technology

Ubuntu USB

They have a saying with Ubuntu: “It Just works” and freak- it’s true, especially with the latest release 8.1 (Intrepid Ibex).

My goal was to install Ubuntu Server edition on a machine that is really, _just_ a server. No shmancy graphics card, no CD-ROM.. wait. No CD-ROM!? How do you install server software onto a *disconnected machine with no CD-ROM? USB.

Now previously, the ability has always been there, and you had to download this and do that and change this- since you were doing something out of the ordinary (at least that is, back then it was). So they simplified the whole process with Intrepid and made it ordinary.

Sooo.. on a desktop machine (an existing installation of Intrepid) select to create a USB disk; locate/select the server ISO (or CD if you’ve burned the ISO onto CD already); select the USB device you want to use and the rest is a progress bar.

Now you can boot with the USB device and install the server OS onto the machine of choice. It really does just work.

Categories
perspective

While The Politicians Dance

At home (that’s SA, not USA; although….), the politicians continue their frenzy of politicking. It’s great for them, i guess. They get to spend all their (paid) time to do what they studied to do (and perhaps the only thing they know how to do?): launch political strategies, talk about each other, spend money, campaign; pretty much everything except get down and solve the real problems.

Health, education, safety, housing, food, energy… these issues are not so important it seems. While all the politicians dance, the “guy on the street”, the ones working 8-5, 6-6 or not at all, are the ones bearing the burdens and suffering the patience of a long-awaited non-delivery. We have to be content with watching our money being diverted from the promised land into more airflights, suits, lunches, breakfasts, t-shirts, stickers, petty (and not so petty) court cases…

Of course, the argument is that these breakfasts and continued (boring) media tantrums are important enough so that the rest of the real work can start happening properly, with the right people in charge. And there’s truth to that. But the obvious responding question: “then why is there more politicking than delivery?” is never really answered. Except to say, well, because it’s really important to get that sorted so that the right people can start to do the work properly.

The irony is, the right people for the job are the ones who get busy just doing it, regardless. But they would probably never dream of being distracted from getting on with their job and “run for office”. ‘Cos, well, that’s all it is: running for an office. Maybe if we gave our politicans cubicles instead, there would be less of them “running for cubicles” :p

Categories
Rants Technology

Pending Changes

One of the great habits now ingrained into my being are doing diffs on code before committing a check in. It’s a great habit, and worth the extra quick 2 minutes. It’s also a great time to review your changes and get your head into the right space for your next move. Of course, having great tools like Subversion and Tortoise (or even git and bzr) make the job a pleasure. But then you have this…

Pending Changes

(Names have been blanked for privacy reasons)

My pending changes tells me i got a whole bunch of changes to commit but comparing each one tells me they’re the same. 😮 Not exactly conducive to keeping up a good habit, i would say. I actually only had 4 files that really changed, in case you’re wondering. No amount of refreshing, getting latest version or checking out could give me just the files i want to review before committing. Sigh.

And most people still ask me why i insist on using open source tools to do the job (properly) :p

UPDATE:

I stumbled upon Derek’s posting on TFS and it does seem that things which should be simple (and were solved moons ago) are indeed quite difficult with TFS. The “plus” side though is ian has taken the time out to do something about it: cue LizardTF. Keeping an eye on that while i simply have to use TFS…

Categories
Technology

Bzr

Bzr have just launched their latest version. And while i’ve used it for development control on my *nix, i’ve also migrated it’s use onto Windows. The earlier versions were all very command-liney and so un-windows-like, but in it’s defence, the good ‘ol command line really is pretty fast and efficient for some tasks. Anyhoooo….

The latest bzr version for Windows, really has a best-of-both-worlds feel to it. Just go get it already 🙂

Categories
Technology

Optimizing And Readability

Optimizing code is generally an expensive process (read: time-consuming) and there are established ways of getting to the bottom of “what to optimize”. Thankfully, profilers are available to help with a lot of the guesswork, so it’s generally a good idea to make sure you work with one *most of the time*. Moving along, it was high time for me to look at some Ruby profiling.

The documentation for ruby-prof is pretty neat and the library itself is quick to get up and running with. And so we start. For my initial problem, I wrote a goal-seek algorithm for accurately estimating gross earnings, given a target nett earning using a tax table- as opposed to just using a base tax-rate. Anyhow, my first stab algorithm (a simple linear search) included the lines:

def seek_annual_gross(m_nett, base_perc)
  sample_gross = m_nett * base_perc
  paye = Paye.new(sample_gross)
  p_nett = sample_gross - paye.monthly_tax
  margin = MARGIN*m_nett
  if((p_nett-margin < m_nett) && (p_nett+margin > m_nett))
    return paye.annual_gross.round_to2.to_f
  elsif(p_nett-margin > m_nett)
    return seek_annual_gross(m_nett, (base_perc - (margin)))
  elsif(p_nett+margin < m_nett)
    return seek_annual_gross(m_nett, (base_perc + (margin)))
  end
end

The profiler showed up what i kinda suspected- always a good sign. Essentially, my incremental margin for the next step was too small (fixed) and thus, getting closer to the solution was taking too long- and endangered the stack 🙂 What i needed was a better guess at how much to increment.

% cumulative self self total
time seconds seconds calls ms/call ms/call name
22.58 0.28 0.28 177 1.58 3.22 Integer#times
16.13 0.48 0.20 171 1.17 259.18 NettGoalSeek#seek_annual_gross
6.45 0.56 0.08 179 0.45 0.50 Float#round_to2

Some minor adjustments to the routine, including an adjusted guess:

increment = MARGIN*(p_nett - m_nett)/margin

and modifying the appropriate calls

if((p_nett-margin < m_nett) && (p_nett+margin > m_nett))
  return paye.annual_gross.round_to2.to_f
elsif(p_nett-margin > m_nett)
  return seek_annual_gross(m_nett, (base_perc + increment))
elsif(p_nett+margin < m_nett)
  return seek_annual_gross(m_nett, (base_perc - increment))
end

And the profiler now reports:

% cumulative self self total
time seconds seconds calls ms/call ms/call name
2.78 0.16 0.01 11 0.91 6.36 NettGoalSeek#seek_annual_gross
2.78 0.35 0.01 17 0.59 1.18 Integer#times
0.00 0.36 0.00 19 0.00 0.00 Float#round_to2

A significant difference! Incidentally, the time to run, according to the test harness, went down from 1.122316 seconds to 0.189661 seconds. The high-level indicator showing enough of a difference as well.

The by-product of this optimization included the ability to get even more accurate estimations since the stack never overflowed, despite the required margin of error.

The moral: optimization doesn’t need to sacrifice code readability. At the right time, in the right spot, for the right reasons, you can achieve a sweetspot (of sorts) between two opposing(?) constraints. But that’s not to assume i’ve found the nicest sweetspot in this little piece 🙂

So in between refactorings or when there’s a lull in production, indulge the geek inside you.

Categories
Life

It’s Officially Cold

Say no more… Cape Town is the officially the new South Pole. Ohmygollygoodnessgraciousnessme!
-6?!

And yes, i am aware that it gets colder than this in other parts of the world… but trust. For us beach addicts here, where the sun fun never sets… the 3 months of winter we have to endure, every year, this IS cold. Brrrrrr….