Fixed Point Decimal Class for C++

June 17th, 2007

I recently needed a fixed point decimal support in C++ for an inventory program I’m writing. Why doesn’t one already exist? I don’t know. There’s one for boost, but since I’m already using Qt, I don’t really see a need to pull in yet another (big) dependency.

It’s public domain, and appears to work (for me, anyway). It’s all standard C++ with no extra dependencies, and should work on all operating systems (although I’ve only tested it on Linux/g++-3.4). Please shoot me a mail (tajmorton@gmail.com) or leave a comment if you find a problem. See this page for it if you’re interested (hello Google bot):

Fixed Point Decimal Class for C++

buying abilify
acai powder
accutane xr
aciphex generic
Has anyone tried acomplia
order actonel online
actos generic
aleve generic
allegra price
weight loss pills alli
generic altace
antibiotics for dogs
buy aricept
buying arimidex
ashwagandha no prescription
can i get lung pain astelin
atacand best price
atarax mg
augmentin discount
no rx avandia online
order avapro
mail order avodart
Bactrim DS side effects
benadryl dosage for dogs
benicar
allergic reaction to biaxin
buspar rx
cheap cardizem
celebrex bextra
no rx celadrin
cephalexin medicine
cialis nz
Cipro dosage
CLA TONALIN
clarinex medicine
claritin uk
When Does Ovulation Occur After Clomid
clonidine overdose
cost of colchicine
coreg cautions
Coumadin Therapy
cozaar pills
creatine slow loading
crestor rx
buy cymbalta online
order cymbalta
Depakote 250MG
Diclofenac DSG
Zinc Acne Acne Best Counter Medication Over Acne Differin
diflucan for toe nail fungas
diovan uk
doxycycline side effect
effects of effexor on newborns
flagyl no prescription
women taking flomax
glucophage for weight loss
women’s hair loss
how to get rid of a hangover
Hoodia Patch
keppra and PDR
lexapro lamictal suicide
cheapest lamisil
buy lasix online
levaquin drugs
Generic Levitra
Lexapro Side Effects
diet pill lipitor
birth defects caused by Lisinopril
5 HTP and melatonin to help dreams
metformin xr
methotrexate metabolism
generic micardis online
mobic experience
motrin best price
msm information
neurontin side effects
order nexium
nizoral tablets
nolvadex rx
omnicef buy
paxil + recovering alcoholics
how to make a home extender for your penis
Is Phentermine Safe
phosphatidylserine
buy plan b online
cheap plavix no prescription
bontril pravachol cvs pharmacy maryland
prednisone information
premarin side effects
Prevacid generic
cheapest prometrium
propecia side effects
no rx provera
prozac description
reglan side effects
what is reminyl used to treat
rimonabant tablets
risperdal
no rx rogaine
seroquel and weight gain
generic singulair
skelaxin no prescription
atlanta stop smoking hypnotherapist
strattera tablets
stress relief desktop game
synthroid interaction with other drugs
tetracycline
no rx topamax
generic toprol xl
toradol mg
tramadol price
cost of trazodone
generic tricor online
trileptal uk
Tramadol Ultracet
valtrex dosage
viagra uk
cheap voltaren no prescription
cheap vytorin online
weight loss surgery
wellbutrin and drinking
yohimbe and psychic enhancement
zantac no prescription
Zetia and Vytorin study
order zestoretic
zithromax for 10 days
zoloft mg
zovirax tablets
Zyban Depression
Zyprexa reimbursement coding
zyrtec price
how does Zyvox kill the MRSA

Thoughts on Usability

May 28th, 2007

General ramblings written when I really should have been doing other things:

  1. Applications should keep track of the data they create:
    In other words, don’t make the user save data and remember where they put it. Use the email application model where you start the program and your data (email) is right there, stored “in the application.” When people lose files, it’s because they don’t remember where they put them. Usually they remember which program they used to create them (e.g., “I’m looking for a text document but I don’t remember what I called it (or where I put it)…”).
  2. Tags over Folders:
    Folders seem to me to be an archaic way of sorting data. Tags are much more flexible because each file/piece of data can have multiple tags assigned to it. This applies to email apps too.
  3. Use Fitts’ Law!
    Very generally translated to computers, Fitts’ Law says that the corners and edges of the computer screen are the easiest to find with the mouse. Current operating systems don’t use this as much could. Mac OS X has the menu bar at the top of the screen. XP/KDE have the start button at the bottom left. openSUSE has a cool thing where the “Slab” (start menu) will automatically come up when you move the mouse all the way to the bottom-left of the screen.

    It would help to see a lot more of this. I’d like to see window switching in 2 corners and possibly quick access to applications along one edge.

  4. Quick Application and Document Access
    I spend a lot of time searching through my K Menu or browsing through folders in Konqueror to find a document. In fact, a lot of the time it’s much faster just to type the program’s name into the Run Command box and hit enter. Use one of the edges of your screen (see above) to bring up the most recently used apps and documents and allow the user to search for apps/docs (ala Beagle and openSUSE 10.2’s slab, but improved). For keyboard monkeys like me, let people type in the name of the app and just hit enter.

    The thing on the right is a rough approximation of what I’d like. It’s searchable (just type in konsole, Konsole is automatically selected and hit enter), it makes your most used accessible from the keyboard (activate menu and use keys to navigate). Make it pop up when I hit the right-hand edge of my screen and I’d be fairly happy.

    Most importantly: don’t make the user browse through the file system to find anything (this applies to attaching files to email too)! Use tags, full content searches, and “this app created it” for finding files.

And a lot more too. I really like what the OLPC team did with the Sugar interface–it’s a very cool reinvention of computer interfaces. Personally, I find the current state of usability of all computer environments (Linux DEs/Distros, Windows, and OS X) all equally appalling–and I suffer daily seeing people struggle with the basic concepts that “make sense” to nerds like you and me (because we think like computers), but not to normal people.

Kubuntu 7.04 VMware Image

May 24th, 2007

I couldn’t find a VMware virtual machine of Kubuntu 7.04 (Feisty Fawn) anywhere (I needed one for testing Autopackage). So, I created one:

VMware tools are installed. The username and password for the user are “user” (w/o quotes). Security Updates are not installed.

Any of you smart people who know how to use Bittorrent are welcome to setup a tracker.

Note: The directory inside the tarball is called Kubuntu-7.05 (which doesn’t exist). Everything really is Kubuntu 7.04.

NOTE :: I had to remove the file because it burned too much bandwidth (1.4TB!?). If someone can host it, or setup a bittorrent tracker, send me an email (tajmorton@gmail.com).

Will Linux Ever Make it to the Desktop?

April 15th, 2007

NB: When this article says “Linux,” it refers the whole gig, not just the kernel. Also, this is about Linux on the Desktop. Severs are a completely different thing. OK?

Almost every year someone declares it to be “The Year of the Linux Desktop.” Yet, these pundits are wrong–every year. Definitely, Linux has made a lot of progress since the days of Red Hat 6.0, but it still has major architectural problems that have existed since the beginning (and actually, in the pre-Linux days as well).

Will Linux ever make it to the desktop? For a long time, I was optimistic about this. Linux has a terrific community of smart people and companies built around it. With this community, we’ve built a pretty amazing free operating system that does work. Maybe not for everyone, but it works for you and me. I like Linux because it makes my computer think like I think. I like Linux because I can easily tell my computer to resize all my photos into thumbnails, to create a list of all the postal abbreviations in the US, and to replace a line in a bunch of PHP files.

However, as it is, Linux is never going to replace Windows as Joe Average’s computer. It doesn’t matter how cool AIGLX/XGL look, how pretty Ubuntu’s Gnome is, or how it doesn’t get infected with Windows malware. As I see it, Linux has 6 fundamental problems that hold it back from being up to par with Windows or Mac OS X:

  1. The Linux kernel has no way for hardware manufacturers to distribute drivers with their hardware.
  2. Namespace Conflicts: Installing everything under one prefix just doesn’t work.
  3. No Platform: Linux has no list of standard libraries/versions of libraries that all distros are guaranteed have. (ISVs need this).
  4. A lot of important projects and libraries don’t seem to understand the importance of stable APIs/ABIs (and the pain breaking them causes).
  5. ELF needs some work.
  6. Centralized repositories for installation just don’t work.

Hardware Drivers

Hardware manufacturers face two (closely) related problems:

  1. Drivers (modules) must be distributed with the kernel.
  2. The kernel has an unstable interface.

Drivers must be distributed with the kernel

While not technically true (out-of-tree modules can and do work), for hardware to work “out of the box,” the driver needs to be part of the Linux tree. As the kernel is currently, there is no way for hardware manufacturers to ship a CD with a wizard and drivers that the user can simply pop in their drive–all drivers need to be compiled against the kernel they will be loaded by.

Even the optimal hardware manufacturer who releases their drivers under the GPL and sends them upstream for inclusion in the official kernel tree still face a major problem; they must wait for their users to upgrade to the new version of the kernel. Until that happens, their hardware doesn’t work out of the box. However, the manufacturer and the user don’t want to wait, they want their stuff to work “right now.” Which brings us to number 2…

The kernel’s unstable interface

The kernel has a fairly unstable interface. The most obvious example was the 2.4 -> 2.5 change which had a large number of changes. I don’t have a huge problem with this kind of “major version” breakage. Architectures changes happen (and usually for the better). You see similar things in the Windows and Mac OS X world, with different drivers for Windows 2000, Server 2003, XP, and Vista, etc. While not these kinds of changes are not optimal, often cause upgrade pain, and add to maintenance costs, sometimes they’re unavoidable.

However, the kind of breakage I’m talking about doesn’t happen between these large releases. The “bad” breakage happens in the minor releases (2.6.8 -> 2.6.9, 2.6.17 -> 2.6.18). This causes 2 problems:

  1. HW Manufacturers need to constantly update their drivers (if they’re not maintained by the Linux community).
  2. Drivers usually can’t be backported easily.

I’m going to use a software example first, because it’s something that bit me recently:
The VMware Workstation needs to install some kernel modules on the host system (and on the guest system if you want improved performance). The VMware folks provide a nice script that tries to automatically build and install the modules. It worked fine on my Slackware 11.0 with the fairly recent 2.6.19 kernel. However, I ran into trouble trying to get the guest system modules working on Fedora Core 6 (kernel 2.6.18) and openSUSE 10.1 (2.6.17, IIRC). On both these systems, the build failed rather spectacularly with lots of compile errors flying by.

It turned out that there were a few changes in some kernel functions and structs that the kernel provided. After a few hours of Google and nano and I had the drivers working, but it was a tremendous hassle. On Windows, the guest drivers (binaries) installed with just a click of the mouse, thanks to the fairly stable Windows API.

The VMware issue is an example of how the kernel’s interface isn’t stable and how hardware manufacturers need to deal with the hassle of maintaining up to date drivers (and the users need to find and apply the patches that the manufacturers provide).

Conclusion: The kernel needs to provide a stable interface for hardware manufacturers to use.

Namespace Conflicts

Traditionally, UNIX systems have followed the philosophy of dumping all programs under one roof, namely in /usr. This inevitably leads to conflicts where two applications have the same name. The FHS tells ISVs to install into /opt/appname. This works in theory, but not in practice, because distros don’t support anything outside of /usr (and sometimes /usr/local), but certainly don’t support adding new paths.

Conclusion: Fixing this (correctly) requires a new directory layout. GoboLinux provides one option. I personally favour something more unique than just the application name–a rootname (like is used in Autopackage) is probably the safest way to namespace something: @domainname.com/project/version.

No Platform

A platform is a set of libraries and applications that are guaranteed to be available for ISVs to use. These libraries must be very, very stable with few API additions and no ABI breaks (unless dealt with properly).

The LSB’s goal is for a standard platform. However, their platform was way too small to be of any use whatsoever. Statically linking kdelibs, aspell, gecko, python, whatever, will not work. It will simply create many bloated, memory hogging applications. A useful platform should provide the majority of libraries that desktop applications need (Qt/Gtk, Gecko, *spell, libcurl, glib…the list goes on and on).

In theory, distros are platforms. However, they fail on two important points:

  1. They’re not stable
  2. Different distros have provide different platforms

Stability

One of the most important corner-stones of a good platform is that old applications continue to function. Windows is a good example: An application written for and compiled on Windows 95 will still most likely run on Windows XP. If you’re lucky, you can even get Windows 3.11 apps working.

Linux distros, on the other hand, often break backwards compatibility. For example, KDE 2 was written using Qt 2. Almost as soon as KDE 3 was released (which used Qt 3), distros stopped distributing Qt 2, and moved up to Qt 3. Suddenly, any applications that used Qt 2 no longer worked on modern distros. This kind of removal of libraries can cause immense pain in the ISV world:

Imagine you’re an ISV who uses Qt 2 in your (Linux) application. You distribute a binary linked against Qt 2. At this time, all distros ship Qt 2 (or it’s available from their repositories), so you don’t bother to include an extra 15MB of files with your application, and rely on the distro to provide Qt for you. Suddenly, Qt 3 is released, KDE 3 is released, meaning that distros can drop Qt 2 because none of the apps they ship depend on it. However, you, as the ISV, are suddenly inundated by a deluge of support calls wanting to know why your app stopped working when they upgraded to Red Hat 8.

Distros as platforms

Distros have gone in the direction of each distro providing their own unique platform [1]–that is, one with no guarantee of compatibility with any other distro. This (in my opinion) is the worst kind of fragmentation possible. As ISV will sell an application as working on “Fedora Core,” while the Ubuntu people are left totally out in the cold with no support, and possibly no working binary at all. This doesn’t work unless 1 distro is going to “win” and have all the desktop market share, which I don’t see happening.

Conclusion: Create a list of the common libraries that desktop applications use, force stability of these libraries, and make sure distros ship these libraries (including the old versions).

The Importance of Stability

This goes along with the platform, but focuses on the projects instead of the distros. Unfortunately, a lot of high-profile projects don’t seem to understand the importance of ABI stability.
Examples include gcc and Python. Unintentional breaks also occur a lot too, see libtiff, freetype, and GTK+.

Conclusion: Stability is an essential requirement for any decent platform. Educate developers about the importance of stability. Don’t allow unstable libraries into the platform.

ELF

ELF, the format that binaries and libraries are in, needs some work. Basically, instead of loading DSOs in a tree, like you’d expect, it just binds against whatever library is loaded into the image. So, you can easily get your app bound to the wrong ABI of a library if a dependency needs a different version of a dep than you do. See this for more information.

Conclusion: Fix ELF so that it loads shared libraries as expected.

Centralized Repositories

All distros currently use a centralized repository for installing software. While it looks kind of cool at first, and it kind of works at a small level, it just doesn’t work in the end:

  1. Users don’t want to wait until J. Random Hacker gets Firefox 2.2 packaged up and put into the repository, they want it right now.
  2. Application developers can’t release beta versions that users can test easily.
  3. The people doing the packaging (the distros) aren’t usually the most qualified people to package the application (that would be the app devs). Sometimes they mistakenly ship broken packages (bad patches, not including essential files, etc).
  4. Distros can and will arbitrarily drop packages from their repositories, leaving users no way to easily acquire the software.
  5. The protection that repositories provide against mal-ware is questionable at best.
  6. Centralized repositories provide a huge single point of failure. Repository servers have been cracked (Debian), and almost certainly will be in the future. All it takes is for a server to be compromised for a few hours for it to infect thousands of machines.
  7. It doesn’t work at all for proprietary vendors. “Truly Free” distributions won’t allow non-free stuff in their repositories. Non-Free as in beer ISVs (e.g., stuff you have to pay for) will probably be fairly reluctant to give their software over to these repositories.
  8. It doesn’t scale. As Mike pointed out, it fails the Microsoft test. Imagine if Microsoft suddenly said that all software needed to be downloaded through http://download.microsoft.com for security reasons to protect their users from mal-ware. a) It wouldn’t work–there’s too much software for Microsoft to keep up to date and approve, and b) It would be way too monopolistic.

Conclusion: Distros have the power and control right now and nobody likes to lose control. Hopefully one distro will see the light.

Final Thoughts

As you can see, there’s a lot of work to do. Can it be done? I don’t know–maybe it can, but definitely not without a major shift in the current “UNIX Philosophy” that Linux has (binaries? not my problem, dump it all in /usr, keep it all centralized, etc).

Perhaps a new operating system would be a better place to start. There’s a huge number of very important “Linux” projects that are not Linux dependent at all–KDE/Qt, Gnome/Gtk+, Samba, Firefox, and CUPS to name a few. All of these projects (and many, many others) are vital to any free operating system. Linux has an amazing community of companies and individuals who have all put tremendous effort into the free desktop–it would be a shame to see it go to waste.

Software Name

April 8th, 2007

I’ve written a something similar to the old USPS Shipping Assistant (creates mailing labels), but I don’t have a name for it–help, oh great internet, help!

Pandora

March 26th, 2007

Go check out Pandora, it’s cool. Same idea as Last.FM, although they have more of the kind of music I like to listen to (and that humans make the initial similarity matches).

The Great College Search

March 16th, 2007

Maybe the internet can help me…

I’m on the search for colleges. I’m looking for something with a good CS program, but also something with decent music, language, and drama. And on the Left-Hand coast is best. And not too much $$$, cuz I don’t got that much.

Anybody got suggestions? I wish I did. Leave a comment. Thanks.

Some People…

January 27th, 2007

…have waay too much time on their hands.

Like this guy:

I’m kind of wary of a Cowboy Neal version of the Hobbit…

  • Upon discovering the magical properties of the Ring, Bilbo comments, “Imagine a Beowulf cluster of these!”
  • The Elven runes read, “First Post!” The fact that it can only be read by the light of the moon is denounced as a form of DRM.
  • The Trolls are moderated -1.
  • Bilbo shows Sting to Gandalf, who asks, “Yeah, but does it run Linux?” Bilbo responds by calling him an insensitive clod.
  • When the large party of adventurers arrive in Rivendell, Elrond complains that the town has been Slashdotted.
  • Smaug’s treasure pile sparks a heated debate about such uneven distribution of wealth. Numerous replies blame George W. Bush’s economic policies for the disparity. After such an intense flame war, having the dragon literally breath flames is determined to be -1 Redundant.
  • The Battle of Five Armies is increased to six to provide a Cowboy Neal option.
  • In the scene where the group meets the Wood Elves, they approach not to ask for food, but to complain that the Elves’ song is not in Ogg Vorbis format.
  • Gollum’s pale, subterranean appearance is lost on test audiences, who when interviewed thought he had just been staying home playing World of Warcraft. Director Cowboy Neal digitally adds a Microsoft shirt and brown Zune to Gollum to emphasize the character’s wretched condition.

How come some people get all the comic genius?

Why is it so Hard to Write a Good Photo Organization App?

January 14th, 2007

Yes Isak, I stole your title.

It’s time once again for the annual printed Wild Garden Seed catalog. This means pictures. And that means we need to find the pictures. And that means they need to be organized.

Applications like Picasa, F-Spot, iPhoto, and even Flickr do a pretty decent job of making your photos somewhat organized. You can tag/label/add keywords, put the photos to sets/albums/galleries, make screensavers, and burn CDs, but you can’t keep your photo collection on removable media (read: CDs/DVDs). I don’t know if this is just a case of “it’s hard”, or if the target user doesn’t need that feature. Most applications would work fine for the normal person who wants to take pictures and then find all the pictures of their dog to put on their Christmas card.

The fabled Joe Average takes at most a 1GB or 2 of photos a year. Most new computers can easily store this amount of data for years without running out of room. The problem comes with professional photographers, who might take 2GB in a month (that’s about 22/day at 3MB/photo, which is what some of the higher end cameras take). The average computer could maybe store 2 or 3 years of photos at a stretch. After that, what do you do? Buy a bigger HDD and reinstall Windows? Get an external 300GB HDD to keep everything on? What about laptops, who always are limited for storage? I suppose if you’re a large stock art company or magazine you could setup iSCSI or ATA-Over-Ethernet, but most photographers don’t have unlimited IT budgets and full time geeks on payroll.

I can only guess that the solution most people turn to is removable media like CDs and DVDs. We used Picasa to choose photos for the catalog, it was a nice piece of software, and worked surprisingly well. First, though, we had to manually look at each CD, writing down the ones we wanted, and then copying them to the hard drive for Picasa to manage. That was a pain. It would have been a lot easier to tag each photo as “lettuce” or “spider” when it was downloaded from the camera. Then, when you entered “spinach” into the search, all your images on your CDs would automatically be listed. Wouldn’t that be cool?

Of course, maybe I missed something really basic. Maybe F-Spot or Picasa already do this and I just wasted a bunch of time. I really hope so, because that would be great! But I’m afraid probably not. Which means I need to write another piece of software, or patch F-Spot, which might not be a bad idea.

Like Isak said in his post, I sound ungrateful too. I should write a patch. Hopefully I will. Soon.

Screengrabs

January 3rd, 2007

Sometimes I’ll take fairly random screenshots on my computer. Here’s my latest selection:

Diebold Job A Job Advertisment on The Daily WTF. A little ironic, in my opinion.

Incorrect Battery Meter
When Batteries Die:

taj@moria:~$ cat /proc/acpi/battery/BAT0/info|grep mAh|head -n2
design capacity: 6000 mAh
last full capacity: 65157 mAh


taj@moria:~$ cat /proc/acpi/battery/BAT0/state|grep m[AV]
remaining capacity: 65157 mAh
present voltage: 12600 mV

Firefox Loves CPU!
That’s on a Intel Pentium 4 2GHz processor w/ 1GB of memory. Nice. (If you can’t read it, Firefox is using 93.4% of my CPU and 12.2% of my RAM)

GMail Ads
GMail shows the weirdest “related content” sometimes…

On a side note, I’ve finally gotten a Flickr Account. It’s got some of my favourite photos from 2006. Who knows, there might be one of you there. Actually not, because “you” don’t read this.

Oh, and I’ve lost 7 keys of my laptop keyboard now. 1 Ctrl, 1 Alt, 4 Arrow Keys, and End. A new keyboard (if you can find it) costs at least $100. I’ll suffer.