Sunday, March 29, 2009

Converting color spaces in C++

I recently posted my first bit of open source code on my website. It came about because I've had to do some converting of RGB colorspace into HSV for purposes of histogram matching for my research. There is code out there that can be found through The Googles but I've never been satisfied with any of them for various reasons. I've tried to make my code much more readible, straightforward, and clean than whizbang-look-at-all-the-c++-tricks-I-used code obscurity. I've also added the ability to convert RGB to HSL and back. I didn't see much use in having HSL<->HSV but this would not be hard to get by using RGB as a middle man. Have a look at it, use it, improve it, but make sure you follow the license! RGB-HSL-HSV converter project or the direct c++ code.

Saturday, March 28, 2009

Web needs a paradigm shift

I was browsing the [H]ardForum earlier today and something dawned on me. There's all kinds of buzz amongst web-heads about the new CSS/HTML/whatever standards and Apple is doing custom CSS additions to allow for animation in WebKit (bad Apple! follow the standards!). My realization is that CSS cannot be the future of the web.

CSS is an extremely powerful way of expressing design and layout for a site. However, from personal experience and seeing a bazillion posts asking for CSS help, it is just too complicated or confusing to consistently get correct. Long ago we learned tables were bad for layout, we should use div instead. However, there seems to be no agreement as to the best way to use them and sites are often accused of overusing them. That's just one example, forums are littered with people asking why they can't get item x to overlap, float, stay put, or any other number of things on their pages and it seems the solution usually ends up being something obscure or unintuitive.

Some stalwarts would write this off as people not knowing what they are doing. But isn't computer science about making things easier on ourselves? Programming languages have moved from the miserable days of low-level languages to the immense spectrum of high-level ones we have today. Why can't the web do the same thing and unburden some of the mundane work? Anyone who has looked at a CSS file from a large website cannot claim that it's easy to get the gist of immediately with a straight face. One example of a CSS failing may be that there's too many ways to do things. It should be moving more towards Pythonic thinking than C++. Yes allowing for 1, 2, or 4 arguments for, say, padding space is a good shorthand but it's not obvious as to which order they are in or how the 2 maps to handling the other two dimensions.

Right now I cannot propose a new solution or ways to fix this. But I do know that we can do better, much better.

Tuesday, March 17, 2009

Python tip: splitting strings with whitespace

This has gotten me so many times now I figure I need to write it down. Plus, it'll be here for everyone else's benefit.

Examine the following Python code:
>>> s = "foo bar spam eggs" # two spaces between bar-spam, three between spam-eggs
>>> s.split( " " )
['foo', 'bar', '', 'spam', '', '', 'eggs']
>>> s.split( )
['foo', 'bar', 'spam', 'eggs']

Note that if you split on " " as in the first command, Python will split only on the first space in a span of whitespace. After the first, subsequent spaces are placed as empty strings into the returned list. However, if you use the split with no arguments, each split eats all connected whitespace.

Marketing genius

IPhone 3.0 Features Announced

I am constantly impressed by Apple's ability to market and make their products seem like they are something from the far off future.... when they're not. And still the fanboys drool.

Some of the big news items:


MMS, Search, File Sharing, and several other features fall into this category. Apple, if you're going to market a product as basically a hand-held computer then you can't make a big deal out of simple, taken-for-granted, everyday things like this.

Sunday, March 15, 2009

Elevate America: Yes and No

Microsoft announces Elevate America initiative

I have very mixed feelings about this. On the one hand the US is in dire need of a program like this to bring the general tech skills up to par. I really hope it succeeds in its stated goal of offering training at all levels to all those in the US. We are following woefully behind the rest of the world in cell networks, internet penetration, education levels, and all sorts of other factors. Hopefully this program (or something similar) can both bring up the general education level and, as a result, make consumers push for better systems.

However, I'm extremely disappointed to see this being headed by Microsoft. Their track record squarely points this initiative devolving into a pro-Microsoft cheer fest; I have a feeling all the training will be exclusively for Microsoft products. It is true that this will improve tech skills on some level, but it is not what we need. Just as the government needs to start backing open source initiatives, so the public needs to get out from under Microsoft's thumb and learn that there is a whole universe outside the Microsoft ecosystem. Microsoft's products have their place but I think businesses and the populace could save a lot of money and headaches by trying the numerous open source offerings out there. Microsoft does not have the stranglehold on the world market as it does in the US, so if for nothing else, we should want to be able to interface with the rest of the world's countries as they mature and become our technological peers.

Tuesday, March 10, 2009

So it begins...

As part of my "100 things in 1001 days" project I decided I'd start a blog to chrnoicle my experiences. After some further pondering I have decided that two blogs is a more ideal situation. One to cover the 100in1001 and thoughts on various topics and separate one dedicated towards technology and programming.

Why the split? Well the main reason is I feel like, as one blog, it would be too jumbled and different groups of people would probably be interested in one and not the other.

So what's my focus here? It will be mostly a melding of thoughts on tech topics and programming ideas/concepts, with other related things thrown in to taste. I enjoy learning new languages--so expect tips there--and am a huge supporter of the open source software movement. If you want to know more about me and why you should care what I write you can browse the the rest of my site Hopefully I'll give plenty of good tips and thoughts that you'll enjoy reading!