Tuesday, April 1, 2008

BR cleaner VS other cleaners

I've always got a bit of a mess on my hands when I'm finished CSS'ing an HTML form. With all the different forces shaping form development I sometimes find it difficult to get a form to look exactly the same in every browser, and to look pretty when degraded out of CSS.

Traditionally I've used divs or spans as a 'cleaner' element to clear the floats above it. I don't know where I learned this common trick, but for as long as I can remember now I've used the cleaner class and some empty divs round around the form to try correct line breaks and the form layout.

Completely randomely I tried something different today. I used a line break element as my cleaner. omg - Why have I never done this before? Now my line breaks act as line breaks when
CSS fails, and then they act as cleaners with CSS enabled. So far its been too good to be true,.. literally; I'm waiting to see why I haven't seen this elsewhere - Waiting to see where it breaks.

Here's a demo of what my cleaners now look like:

<style>
br {
display: none;
}
.cln {
display: block;
clear: both;
}
</style>
... blah blah fish paste ...
<div>My floated left element</div>
<div>My floated right element</div>
<br class="cln" />
<div>The rest of my content</div>



Some last notes:
I hide all line breaks by default because they are really there only for graceful degradation. If the client has CSS enabled then I don't want extra line breaks mucking up my presentation. On the other hand, when CSS is enabled then the linebreaks with the 'cln' class will be displayed and, simply put, line break over the above floated elements.

Wednesday, February 27, 2008

Time

For as long as I can remember now, time has only ever got faster. I never feel like I can do more than I used to - I'm always thinking how there just isn't as much time as there used to be.

Thursday, February 21, 2008

Powermate in C#

Well about four months ago I bought a Griffin Powermate. It's pretty much as good as they say except I think it could have been a little more solid. It looks a lot heavier in the pictures.

Now the only real gripe I had with the Powermate was the drivers. I battled for, I kid you not, days. I installed, connected, uninstalled, disconnected, reinstalled, reconnected this darn powermate so many times, that even by chance I should have got it to work.

The retailer I bought it from, SimplyMac.co.za in Johannesburg, wanted nothing to do with me. They simply denied me warranty on the item and told me to search Griffins site for help - Which I had already done by then! All I'm saying is that I will never buy from them again. Griffin was more helpfull,.. well nothing they suggested actually helped, but it didn't stop them from trying. I believe that if I carried on emailing their support team they probably would have got me to ship it over to get repaired.

I don't know how many people out there have battled with Powermates, but mine just seemed to move the cursor horizontally across the screen. The Powermate registers itself as a mouse-type device and thus without drivers will just cause the cursor to move slowly across the screen. With drivers and software you are meant to be able to assign more helpful actions to the Powermate; like changing the volume or scrolling your current document up and down. So since my Powermate made the mouse move without drivers, I reckon the problem must reside in the drivers. Surely if there was a fault in the Powermate itself then the device wouldn't register on the computer at all. Well whatever the problem is, shipping it over to the States is gonna cost be money. So some DIY was sounding good.

Yesterday I started snooping around C#, and hey,.. Presto! In half a day I managed to hack together a small app which:
1) Detects all the mouse HID's installed.
2) Links in to the data sent from the Powermate, and ..
3) Adjust the system volume or pump a page scroll.

Now I really did hack it together, I'm not even going to try take credit for the source. Having a good knowledge of Java and some C++ I managed to interpret the C# syntax without too much trouble but,... I'm not a C# guy so keep that in mind if you looking through the code.

Here's the source with binaries included: http://b22222.com/pmate.zip
Note: I coded this using MS Visual C# Express which I think uses dotNet 3.5

Directions for use:
Run PMate.exe (duh).
By default the Powermate then controls your volume.
If you press the Powermate it alternates to controlling page scroll.

The three thing's I'm not satisfied with yet in this solution are:
1) The program has a bit of delay while reading from the Powermate - Not ideal.
2) The Powermate still pumps regular mouse events. So pressing the Pmate still invokes context menus :/
3) I don't know how to properly hide the form, so it infact just minimised without a taskbar button. This allows you to still ALT-tab to the app.

At the end of the day though I'm quite happy with the solution. It gives me a bit of a geeky thrill turning the Powermate and knowing that I somehow got it to change my volume.

Wednesday, December 19, 2007

Faust, Midas, And Myself - Switchfoot

This one's about a dream I had last night.
How an old man tracked me home and stepped inside.
He put his foot inside the door and gave a crooked smile.
Something in his eyes, something in his laugh,
Something in his voice, that made my skin crawl off.

He said, "I've seen you here before, I know your name.
You could have your pick of pretty things.
You could have it all. Everything at once.
Everything you've seen, everything you'll need,
Everything you've ever had in fantasies."

"You've one life, you've one life.
You've one life left to lead."

I woke up from my dream as a golden man,
With a girl I've never seen with golden skin.
I jumped up to my feet she asked me what was wrong.
I began to scream I don't think this is me.
Is this just a dream or really happening?

What direction? I'm splitting up! This is my personal disaffection.

What direction? What direction? What direction now?

I looked outside the glass at golden shores.
Golden ships and masts with golden cords.
As my reflection passed I hated what I saw.
My golden eyes were dead and a thought passed through my head,
A heart that is made of gold can't really beat at all.

I wanted to wake up again without a touch of gold.
What direction? Death or action! Life begins at the intersection.

I woke up as before but the gold was gone.
My wife was at the door with her night robe on,
My heart beat once or twice and life flooded my veins.
Everything had changed my lungs had found their voice
And what was once routine was now the perfect joy

You've one life,
One life left to lead.

Wednesday, October 3, 2007

One virus to rule them all

How does one create the ultimate virus? well what is the ultimate virus? Some would say that it is the virus that crashes the internet. Or perhaps a virus that cripples the information infrastructure so badly that were taken back to the stone age.

There have been many noble attempts to fulfill the above goals but the internet is still around nonetheless. The ironic thing about the previously stated goals is that when the virus that destroys the net as we know it has done its work, the gentleman that wrote the virus will have nothing left to be proud of. It'll all be over. He will most likely be employed as a programmer, or at least in the IT field, so he will now be out of a job. The economy will grind to a halt in so many places. Chains of supply to consumers will be disrupted. No food, no petrol, no electricity. Well,.. sitting in a dark cold house with no food has never been a dream of mine.

So what are my attributes of the ultimate virus?
  1. Is hard to remove from a computer.
  2. Designed to survive in a networked environment.
  3. Has more reputation than any other virus.

Point 1:
So I think the ultimate virus should thwart all attempts at removing it, yet still make its presence know to the user. It should be a virus that is designed to last as long as possible - Survival for existence. Now some viruses excel at making their users aware of their presence, but do so irritatingly (pop ups, bandwidth usage) thus cause the user to format or remove the virus, thus contravening this first rule.

A virus that in no way, directly or indirectly, interferes with the user will not present any immediate need to remove the virus.

I'm still not set on how I would tell the user that they were infected, but I probably wouldn't go much further than emulating a dead pixel in the bottom right corner of their workspace. That's it. Just something small to say that the virus is present.

Point 2:
The ultimate virus should be network smart. As networks can vary in so many protocols, mediums, transfer speeds and security, it would need to carry some measure of heuristic power. It needs to be smart enough to travel from one network to the next; From file to file, virus to worm,.. It needs to be smart.

It needs to have a small, actually super small footprint. If the virus started to hog storage space or bandwidth it would start to present a need to be removed. Now the more intelligent we want our virus to be invariably the larger our footprint is going to be. No matter how smartly you design the virus,.. if you want to tap into any network and into any file, you are going to need a bit of code to make it work. Now instead of keeping all this viral goodness in one virus entity, why not split it up? Lets make this virus 'modular'. It will be conceived as one complete part, but will be able to break down into smaller segments; Each segment capable of basic viral activities and propagation.

A modular/segmented virus!.. Okay, so its got smaller parts - What else? Each segment should be able to be rebuilt from the cooperative work of other segments on the network. Something reminiscent of RAID 5 and 6 parity reconstruction. This will not only reinforce my second attribute to survive in a networked environment, but the virus is now designed to use the network to its advantage. Each segment should to some degree track from which 'parent' virus it came from, and/or where other virus segments are in its close neighbourhood. This way when it needs to perform some more complex or group viral activity it can gather the parts it needs, perform the task, then breakdown appropriately. Say a virus needs to do some brute force activity or large calculation, it should be able to distribute work to its segment friends on remote devices to help perform the task.

Point 3:
So the ultimate virus needs to be famous. What would stand out the ultimate virus from all the rest. Point 1 has ruled out all forms of destructive, indecent, or otherwise irritating behaviour. So whats left? We can't be bad... Well why not be good? Good! Sure,.. Why not make a virus that performs low level HDD defrag optimization during spare CPU time? How many virus's can lay claim to that fame?

Now here's the best for last. Here is the way to make our virus greater than every other virus. Give our virus the ability to intelligently search and destroy all other virus'. That's it; If you can't beat them, delete them. Who wouldn't want a piece of software that automagically removes all hazardous software from their computer/device?

Now although the virus coders carnal desire to destroy peoples computers isn't going to come true: He would have created, in my humble opinion, the penultimate virus.