Categories
boost cpp My Media System Programming

Boost part 2

In the quest for improving the quality of the MMS code in 1.1.0 I’ve done several things, one of which was to convert all the source to the boost foreach statement. Since I liked the result of the foreach cleanup so much, I decided to see what other libraries could be of use. I quickly found the function and bind library which allowed me to remove the internal function pointers framework we have currently been using. While converted I was surprised to see how cleaner the code became. The bind function is truly easy to use and read and made it possible to remove several helper classes which only purpose was to capture state to create a uniform interface.

So instead of:

class FP
{
  std::list numbers;

  FP(std::list n)
    : numbers(n)
  {}

  call(int t)
  {
    int total;
    foreach (int i, numbers)
      total += i*t;
    return total;
  }
};

(I saved the part of actually creating the function pointer object). One gets:

call(int t, std::list numbers)
{
  int total;
  foreach (int i, numbers)
    total += i*t;
  return total;
}

boost::bind(&call, _1, list_of_numbers);

Voila. Now if only the wordpress code formatting didn’t suck so much 😉

Categories
boost cpp On the web Programming

The future of C++

Recently I’ve been looking a lot into boost and it’s really a great set of libraries. Although the syntax of some of the libraries could use a helping hand (assign library). Luckily I was watching a presentation by Bjarne Stroustrup on the next C++ standard and it appears that they will finally add a way to construct containers such as vectors with elements as construction time. I think it was called initializer lists and the syntax was the following:

      vector v {1,2,3}

So you can now initialize them just like regular arrays 🙂 Furthermore it appears that we’ll get threads and perhaps a common filesystem + network abstraction. Now if only they could be a little quicker at bringing forward these new standards 😉

Categories
HTPC My Media System tablet

Touch screen input in MMS 1.1.0

Really wanted to make navigating MMS on the nokia easier so I implemented mouse input which is luckily also what a touch screen is. Yay!

Categories
Free Software My Media System On the web

bzr bundles

Stumbled upon this guide today for how to create better patches when the project in question is using bzr (such as MMS :)).

Categories
My Media System Programming

It’s all the little things

Having been coding in c# for some time now, what is really nice about the language compared to c++ is the foreach statement. The syntax is really natural and easy to read:

     foreach (string s in strings)

Compare this to the standard c++ notation:

     for (vector::const_iterator i = strings.begin(),
             iend = strings.end(); i != iend; ++i)

So I decided there must be something easier and vague remembered that boost had something for this. And low and behold they had. So now instead of writing that horrible for line, one can just write:

     foreach (const string& s, strings)

It’s not quite as nice as i c# since one can’t have a pair on the leftside of the comma, so one needs to be using typedefs to fix that. And one must also remember the & as to not create unneeded copies of the string.

And the best part is that it’s written as a bunch of templates and macro’s so one can just include a header and of it goes. Doesn’t even have to change the Makefile 🙂

I’ve converted the whole MMS 1.1.0 code base to the new syntax and it’s really so much easier to read. Especially because I tend to use better names for the loop variable than i 🙂

Categories
Free Software My Media System

CXFE 0.9.2 released

A long time ago, Rett D. Walters created a console frontend for Xine so that we could use that in MMS. I’ve since the last release created quite a few patches for it, and because Rett wasn’t actively maintaining it anymore I decided to roll all my patches into a new release:

http://people.iola.dk/anders/cxfe/

Categories
On the web Personal

Welcome to the 21th century

I received a letter today from my insurance company about a service where one can access account information using their web site. What I noticed was, in the letter, they specifically mentioned that the site was only open from 7am to 10pm. Why would such a web site ever be closed? If they need to run some maintenance they can always just schedule it. Sometimes I wonder if some people didn’t realize that we are now in the 21th century?

Categories
Free Software

Even your daemons can have usability problems

Today I decided to change nic in my server because the onboard NIC wasn’t working properly. And so again I hit the problem that udev can assigns a NIC a different ethX name than what the kernel is printing in dmesg. So one modprobes the module and gets the following output:

e100: Intel(R) PRO/100 Network Driver, 3.5.17-k2-NAPI
e100: Copyright(c) 1999-2006 Intel Corporation
ACPI: PCI Interrupt 0000:01:07.0[A] -> Link [LNKB] -> GSI 10 (level, low) -> IRQ 10
e100: eth1: e100_probe: addr 0xdcfff000, irq 10, MAC addr 00:A0:C9:E6:3E:75

Tries to start the NIC using /etc/init.d/net.eth1 start only to find that the device is not found! Luckily I had this problem before so I knew that I needed to clean up the file /etc/udev/rules.d/70-persistent-net.rules. I seriously doubt that this “feature” of remembering the ethernet binding of old NICs brings more “joy” that headaches.

Categories
HTPC My Media System

My Media System 1.0.8.4 released

A new stable release of MMS is out. This is a bugfix release and so 15 bugs have been fixed and no new features implemented. Upgrading is recommended.

Categories
Movies

Very interesting documentary about Copyright

I bumped into this documentary (Good Copy Bad Copy) about copyright yesterday. The documentary is made by 3 danish guys and is really interesting in that it tells the story about copyright from the view of countries in four different continents (USA, Russia, Nigeria and Brazil). In case you havn’t read the wonderful inspiring books by Lawrence Lessig this video is an excellent introduction and will only steal away one single hour of your life 🙂