What to do… what to do…?

I just couldn’t resist 😀 Had to log into Windows today and on startup was presented with this dialog:

randomdialog.png

What do you do?

Resizing NTFS Partitions

Quite simply, the very idea freaks me out. The way NTFS partitions are managed in Windows… well, let’s just say resizing appears to be less straightforward than it makes me comfortable. And yes, there are some tool$ available to do the job securely, but again, in an emerging economy, some tool$ are just not priced affordably. Hello, GParted.

Defrag your NTFS partition (mostly ‘cos it invokes a layer of warm and fuzzy doing so)
Download the GParted LiveCD, burn the ISO (while we’re on the topic of burning ISO’s from Windows, again, it really is a bit of a unaffordable freeware/shareware mission)
Boot up with the LiveCD
Resize your NTFS
Reboot back into Windows (this allows windows to do it’s own CHKDSK on the “new” partition)

That’s it. Did it work? Oh yeah, it works. No corrupt programs, data, files, nada. Even my Lenovo SecureDrive volume is still intact…

perfmap.png
… as you can see.

Fractions and Foating-Points

Floating-point arithmetic on a computer is hazardous, at best. This post is not a detail description of the problem. Varied descriptions of the problem already abound, like this one, for example. There’s also documented pain out there to understand that it’s not just your computer 🙂 No, this post is just one way of getting around the problem in a particular context.

The environment: JavaScript. The problem: convert decimals to fractions and fractions to decimals. Getting a decimal is straightforward:

function fractiontodecimal( wholenumber, numerator, denominator ) {
wholenumber = parseFloat(wholenumber);
numerator = parseFloat(numerator);
denominator = parseFloat(denominator);
return ( ( ( wholenumber * denominator ) + numerator) / denominator );
}

Obtaining a fraction was slightly more insane since in JavaScript
23.8 * 10 = 238
but
23.88 * 10 = 238.79999999999998

Not exactly what you need to work with. As you can imagine, inside a loop of sorts, and if the number becomes very small and you divide by it, you start getting bigger errors. Anyways, that’s a digression in itself. What i needed was a reliable way to multiple by a float by an integer, 10, and get a predictable response. In other words, i just needed to keep shifting the decimal point. Most immediate response might be: string manipulation. Isn’t that what JavaScript is for? :p

Another way was using e-notation. 23.88 being represented as 23.88e0. Multiply by 10: 23.88e1, and so on. The good news is you still get to do a little string manipulation, but not nearly as hectic as finding and moving a “.”

The particularly heavy looking string manipulation looking like:

newDecimal = mantissa + “e” + exponent;
That wasn’t so hard, now was it? 😀

Browse through the code for decimal.htm (HTLM page with JavaScript)

Categories
perspective

SA Bashing

i used to think that the popular pasttime of South Africa-bashing was reserved for expats living, mostly, in the UK. but the sport has caught on quite quickly within our borders. sad, but true. you’ll recognise over-indulged sentences like “the government should have” or “those people” and “you see, i told you”. And more. Everyone’s a critic it seems, and more so true than ever before.

And while we do have our share of issues to deal with, we, the ones still living in this incredibly beautiful country, still have to deal with them. Complaining without action is just complaining. It’s not a solution. Offering your unsolicited, uneducated and distanced opinion is also not a solution. Ground work is where it counts. And there are plenty of organisations, initiatives and causes to throw yourself into that can make a visible difference. That is, if you really wanted to. Especially now that you’re earning the currency so often bragged about. And if you don’t want to pitch in and make a difference, polluting our environment with negative emotions is one less problem we can do without.

There is a stark reality to what South Africa is- no one can deny it. But there is also hope.

Ok. So that’s the end of my rant in response to the never-ceasing (or so it seems) opinions of Saffers living elsewhere. I’m not negating or even want to come close to nullify reasons and experiences that may serve to wholly justify the array of negative opinion. It’s not about that. It’s about: life happens, so now what? and character, as we saw from the Super14 Final game… is what shows when the chips are down 😀

Go, Bulls!!

Categories
perspective

Shavuot, erm Pentecost

it’s that time of year where we have opportunity to celebrate just two radical gifts that God chose to give the world: the law and the Spirit. in this day, back in history, these two gifts significantly changed, and continue to shape the world we live in.

now if you’ve got a culture of Judaism, you’ll understand the meaning of Shavuot quite well.. if you’ve got more of a Christian upbringing, chances are, …well, let’s just say that it will mean different things depending on where you experienced that culture.

anyhow, so not to confuse Pentecost with Shavuot too much, there is a useful link, celebrating the giving of the torah i came across which helps explain (at least for me) some of the more biblical traditions. And yes, there are some non-scriptural traditions too. but i’m referring mostly to understanding transmitted in those pages which help shed light on origin, without the fluff of post-modern christian-oriented humanism.

the persepctive is refreshing and worth considering, even if the only thing it does is get you to open your bible and mediate upon His Word 😉

Oh, and if you think living by the Ten Commandments is old-fashioned, i bet you’d be surprised by just how many you probably agree are valuable principles for a peaceful society.

Anyhow, but let’s not forget that although “rules is rules”, without a heartfelt understanding of the Spirit of the law, the letter remains unattainable and horribly binding. But by Spirit, the application is liberating! 😀 That’s Part Deux to Pentecost, this day in history…

“And when the day of Pentecost was now come, they were all together in one place.
And suddenly there came from heaven a sound as of the rushing of a
mighty wind, and it filled all the house where they were sitting.
And there appeared unto them tongues parting asunder, like as of fire;
and it sat upon each one of them.
And they were all filled with the Holy Spirit, and began to speak with
other tongues, as the Spirit gave them utterance.”

log4net

Not gonna lie- it wasn’t altogether _that_ intuitive to begin with. Appenders, logging levels, loggers and a whole bunch of different configuration going on: it wasn’t just working. But, i thought to myself: many others are happy with it so it must be worth the initial pain. Of course, in a world of instant gratification and high-speed demands, how long exactly do you sit with a problem?

If it’s a maths problem, like something involving integrals, sometimes you can do nothing but sit with it. No amount of Google is ever gonna give you the answer. And if you think it can, i’ll happily take on the challenge 🙂 But this is code…

CodeBetter, CodeProject, Koders and even log4Net itself have plenty of sample code and tutorials designed to get you off the ground. And they all have their strong points so if you thinking about log4net, take some time upfront just to read how different people go about explaining various setups and configurations. You’re bound to find one you like. So back to this particular log4net experience…

What i wanted is to have an open console running which recorded anything i wanted while my asp.net application was executing. i love consoles ‘cos of their simplicity, power, flexibility and in-obtrusiveness. in the right place, at the right time, they definitely rock. So that’s the mission.

There’s this article which gave me a great jump start in the right direction. I made a few modifications (i am programmer) and as a result… well, this picture is worth a paragraph or two:

log4net console
More than anything, this is testimony that log4net really does work despite some of the comments and posts (and initial pain) and once you’ve got it down, you can add massive geek-value to your project. You also just might have fun, but keep that to yourself 😉

Go on… have a little fun

Worse Than Failure are hosting a little contest, which perchance happened to stumble upon. it is just for fun [eegads! don’t let anyone know you’re actually having fun programming] so my entry is up… who knows, maybe it’s a good enough attempt at winning that high quality JPEG! 😀