Tuesday, December 14, 2010

SWIG and fstream

I have a love/hate relationship with swig.
I have had some success wrapping C and C++ libraries so they can be called from python. The real plus with swig is that is not invasive to existing code, with a little work you can usually create good wrappers without having to change underlying code.
However, when it fails it can be hard to spot why. I've found that looking at the C++ wrapper code that swig produces can help a lot, but still there can be a lot of thrashing around.
My latest battle was with fstream. I had a method that need a C++ stream to read from and I wanted to open a specific file, so I needed fstream. Unfortunately, I had no joy wrapping the fstream header file. Some googling suggested that C++ streams are one area where swig struggles.
In the end, my solution was to just create a function that takes a filename and returns an istream:
%inline %{
#define SWIG_FILE_WITH_INIT
istream & open_stream(const char *filename) {
istream *infile = new ifstream(filename);
return *infile;
}
%}
istream & open_stream(const char *filename);
Armed with this I can open files and get the istream objects I need to pass into methods that read streams.
I'd be interested to hear of any better solutions.

Wednesday, December 1, 2010

Wikileaks: most startling revelation

The dump of diplomatic cables from wikileaks has provided some interesting insight into diplomatic communications. So far I've not really heard anything earth shattering.

The most surprising thing I've heard is that 2.5 million US citizens had access to all this data. Now if I was one of the diplomats involved I'd be more than a little miffed that what I considered confidential conversations were being dessiminated so widely.

This piece explains some of Assange's motivations in publishing this material. I had originally thought he was just interested in exposing illegal and immoral behaviour in governments, but his motivations are much wider than that, hence the dump of data rather than publication, allowing others to mine the data.

Whilst nothing I've heard so far seems to threaten security seriously (although some of the revelations re: Saudi Arabia might have potential to increass tension in the Middle East). My guess is that most of the data just confirms stuff that people already suspected. In many cases, it actually might increase trust between nations, since they now have confirmation of what they have up to now only suspected.

However, it is going to be hard for diplomats to be so candid in the light of these revelations. The US can actually help heal this damage by accepting that the wide internal dissemination of this information was itself a breach of trust.

Meanwhile, there are some pretty scary ideas about how to deal with the perpertrators of the leaks.

Update: this piece in the Guardian sums up what I was trying to say above.

Tuesday, November 30, 2010

Upgrading cable modem with built in wireless router

I had a cable modem with built in wireless router. Unfortunately, it did not support the faster wireless protocols. Since I want to use it to stream video from mythtv I needed to upgrade.
Now the simple (famous last words) thing to do was just to get a new wireless router and then just use the old one for its cable modem.
Of course, it isn't that simple. I had hoped I could just take a lead from one of the modem LAN ports and plug it in to the wireless router's WAN port.
What did work was the following set up:
  • Set both routers to use the same private network (192.168.0.*)
  • Have the modem serve DHCP, with local IP address 192.168.0.1
  • Set the wireless router IP address to 192.168.0.50 (really just anything to avoid the modem IP address)
  • Turn off DHCP on the wireless router.
  • Cross fingers
This seems to work ok. New machines connecting to the wireless router get their IP addresses served by the modem, which happily sets the default gateway, DNS etc correctly.
The only downer is that I'm forced to use the modem configuration for firewall etc. and its firewall configuration is less powerful. Also, it doesn't seem to support assigning static IP addresses in its DHCP set up.

Friday, October 15, 2010

Maverick Meerkat initial impressions

I am not really a fan of reviews where the reviewer throws on a new distro, plays with it for 3 hours and then does a write up. I find it takes much longer to get a proper impression about a new distribution.

So, having said that I'm nonetheless going to give my initial impressions of Maverick Meerkat. I started switching a couple of weeks ago.

So far I have upgraded (or re-installed) 2 laptops, a netbook and 3 mythbuntu boxes. All bar the netbook have gone pretty smoothly (more on that below).

The new installer has some good improvements, such as doing work in the background while you are still answering questions, resulting in faster installs.

shotwell has replaced f-spot as the photo manager. I'm finding shotwell much, much faster than f-spot and all round a pleasure to use. Migration from f-spot is trivial as shotwell has an "import from f-spot" option. This worked a treat for me.

Ubuntu Software Centre has two new features I have already found very useful. History allows you to see the history of your package installs. Installed Software splits stuffup according to which repository they have come from. I've already found both these features invaluable.

Software sources has been moved from a standalone entry in the System->Administration menu to being part of the ubuntu software centre. You will find it under the Edit menu.

I do think Ubuntu releases could do with some more comprehensive release notes which list changes like this, it took me a while to track things down.

Upgrading the Acer Aspire, 11.6" ZA3

The problem with this netbook is that it has the poulsbo video chipset. Despite being an intel chipset, the drivers are closed source. However, there is now reasonable support and repositories with the necessary fixes were already available.

After upgrading, just:

add-apt-repository ppa:gma500/ppa

and install the poulsbo goodies from there.

My upgrade on the netbook ran into a few problems. First, the installer told me it could not figure out the upgrade and told me it was probably due to third party stuff I had installed, but gave no clues as to which. If only I'd had the new softwar centre to allow me to browse what I'd installed from strange sources.

Happily, synaptic has a similar option. Using that, I guessed that it was the poulsbo goodies causing problems, so removed them and then fired up the installer. Success!

Now the install was going ok until I looked at the netbook and saw that everything seemed to have frozen. The window manager had crashed. Note to self, don't do a gui based upgrade after removing a bunch of the packages that your X server is using ;)

Sadly, I ended up killing the upgrade before I found the window asking me some question about which version of a config file I wanted. This had been hidden behind another window and, without a window manager running I couldn't see it.

The good news was that I was able to complete the upgrade using apt-get commands from the command line. A reboot got me to a console, I then added the poulsbo goodies, rebooted once more and all was good.

Wednesday, September 15, 2010

Thanks Ubuntu

Mark Shuttleworth recently responded to criticism of the Ubuntu project with a very thoughtful piece: "Reflections on Ubuntu, Canonical and the march to free software adoption"

As someone who has been using Ubuntu for mary years (since Breezy Badger), I have nothing but admiration for what Mark has enabled the Ubuntu people to achieve.

Sure, there have been problems along the way, but the result is an operating system that is a pleasure to use. A few years back I introduced my sister to it, she's been running it fine on her laptop for some time. Just this weekend I helped her fix a printer issue using the desktop sharing in empathy (she is in the UK, I'm in Canada).

This weekend I installed Ubuntu on a friends laptop and an old pc tower. The laptop was taking 15 minutes to boot into windows (probably malware issues, but I'm not the person to fix that). So I installed Ubuntu along side, had it import the user's documents and settings and now they are delighted: 30 seconds and they have a machine that is snappy and fun to use.

The pc tower was her son's. Or at least that was what I thought. It was failing to boot at all. It booted fine from a Lucid Lynx disc, so I asked if it was OK to wipe the disk and install. He said, "Yes, go ahead". So about an hour later it was up and running. Only later that day did I discover her son had two pc towers, one was his, one a friend's he had in his room. No prizes for guessing which one I'd upgraded. Oops. Happily, the friend came by later and was delighted with his new, snappy computer, loaded with useful software.

Thanks Mark and everyone involved in Ubuntu.

Sunday, August 29, 2010

Nexus One and Orange UK pay as you go

I am currently in the UK. Last time I was here I bought an Orange UK pay as you go card.

First off, the deal with Orange is pretty good if you are an occasional visitor here. I can get 250MB of data for £5.00. In fact, if I'd subscribed to Dolphin as my Orange animal I'd get this for free with a £10.00 top up each month.

However, when I put the SIM card in the phone I got no data connection. The display just showed the signal strength indicator with no 3G, G or E indicator.

Initially, I assumed this was due to incompatibilities with the frequencies that Orange uses and those my handset can use. I have the version that works on the Rogers network in Canada. See this article for more information on that.

However, when I put my Rogers SIM in the phone, selected Orange as the network and turned on data I got a GPRS connection.

So it seemed the problem was something to do with the Orange SIM card. A long support call didn't provide any solutions, just lots of frustration. The Nexus One wasn't on their list of phones and the support person hadn't heard of it, so I was pretty much on my own.

Today, I made it into an Orange shop. Initially, things weren't going much better, but just as I was about to give up the resident Android expert came to help.

He was excellent and explained I needed to configure an Access Point Name for the 3G and GPRS to work. Sure enough, once I went to:

Settings->Wireless & Networks -> Mobile Networks -> Access Point Names

and added an access point with Orange WEB as the name and orangeinternet as the APN, the phone got a full 3G connection.

So, I can confirm that the Nexus One, Rogers Canada version works fine on the Orange network.

Monday, June 14, 2010

World Cup miscellania

Happily, CBC has the World Cup coverage here in Canada.

This leads to my "Getting things done" tip of the day: watch the football in the gym.

If I head for a run 20 minutes from the end of a game I can watch the game and run at the same time.

Only problem is I have a slight tendency to try and kick or head the ball, not ideal when on the treadmill.

Tim Bray's blog is an unexpected source of good World Cup punditry.

Tuesday, May 11, 2010

Music industry: how being sensible makes you money

So this morning I came across this Ubuntu video.

Someone asked in the comments if the Twisted Sister track is available in the Ubuntu Music store.

Sure enough it was. With the music store nicely integrated with rhythmbox on Ubuntu it was trivial to purchase.

So, this video has achieved at least one sale.

No doubt there'll be a take-down notice shortly ;)

Monday, May 3, 2010

Electoral reform

With the UK election likely to produce a hung parliament there is likely to be much discussion of electoral reform there. Indeed, the Liberals are likely to demand this in order to form a coalition.

To my mind, this is long overdue. I'm not sure of the exact figures, but for the last few elections a 30% share of a 60% turnout has given a huge majority in parliament. Now, whilst you can argue that those that don't vote don't deserve their views to be represented, it can't be right that 80% of the population end up with their views not represented by the party in power.

Proportional representation would be a good start. A single, transferable vote system would certainly improve things. One key benefit of this is that it largely eliminates the need for tactical voting, each voter can express their preferences, in order of preference, rather than have to guess which parties actually have a chance of winning and voting tactically.

PR though is just a beginning. The opponents of PR point out that it will lead to hung parliaments. Well, yes it will if there is no clear majority for any one party in the population. Now the problem here is that a minority party can then have more influence than maybe they should in a coalition.

A second problem is that even with PR, suppose there are just two parties sharing most of the votes, one has 52% share, the other 48% share. The 52% party will get a majority in parliament, the significant minority won't have their views represented.

The problem is that once in parliament, simple majority rules.

How can you address this?

Well one way is as follows. Once the election is complete, any group with 5% of the MPs can select a representative to go to a meeting. At this meeting the 20 representatives come up with an agenda for parliament and pick a prime minister.

Each MP is allocated a number of votes for the session. The MP can place as many votes as they want on each issue, so if there is one issue they really care about they can put all the votes on that issue.

In this way, minority issues can get an airing and can get pushed through once on the agenda.

The key to this working is of course the meeting of the representatives. At this meeting there will be a need for debate, consensus, compromise etc. I'm not sure current politicians are capable of this, but if they were I believe it would result in much better goverment.

Saturday, May 1, 2010

350% increase in Ottawa Ubuntu in just 6 months

Last night was the Lucid Lynx release party for Ottawa.
The attendence was up a massive 350% on the Karmic party, just 6 months ago.
At this rate we'll need to book the new Ottawa congress centre for the 11.04 release.
Here are some photos from the party.
A good time had by all celebrating a great release.

Monday, April 5, 2010

Lucid Lynx Beta

I upgraded my primary machine to Lucid the other day.

So far I've been pretty impressed.

I'd heard a lot of stuff about the 'me' menu and the messaging integration, without really knowing what it is all about.

Under karmic, my experience with empathy had been more than a little disappointing.

With Lucid, things are much better. The envelope in the top panel which goes green when a new message comes in is working really well for me.

The Super-m keyboard accelerator takes me to the messaging indicator and allows me to switch easisy if I want to talk to a contact.

I took a look at the code, the Super-m key binding is hard-wired into the indicator code, so I've had to re-train my fingers which, since I've had that bound to minimize windows.

Super-s takes you to the logout menu, again no way to configure this though.

On balance, I'm a big fan of keyboard support for everything.

This is probably one reason I don't really care about the buttons moving to the left. I don't use the things as a rule (I use the keyboard). One thing I do like on the buttons is the close window one is red -- easy to spot and hit if I need to.

In other news, so far sound has behaved itself. Hopefully the days of 'killall pulseaudio' are numbered.

Tuesday, February 9, 2010

What do you do if your gas pedal gets stuck?

So the press is having a field day with Toyota's gas pedal problems.

Maybe I have missed it, but I haven't come across any advice from the press (or Toyota for that matter) as to what you should do if you encounter this problem.

I've heard a few tails from people who did, most recount tales of having both feet on the brakes trying to slow the vehicle.

Putting the car into neutral would seem a good option, failing that I would think the thing to do would be switch off the ignition, but then you have to worry a bit about power steering and steering locks.

So why isn't the press interested in educating the public?

Saturday, January 2, 2010

The Pants Bomber

Another (failed) terrorist attack, once again the solutions being proposed involve more inconvenience, more invasion of privacy and little in the way of true increased security. Chalk up another round to the terrorists.

It is more than a little annoying that having had to give fingerprints to travel to the US, submitting all those details they so love, with talk of countries passing on credit card information and the like, that this attack was done by someone on their 500K list of people to watch.

See this article for more on the information that was available about the terrorist. It seems that this attack was an intelligence failure, as indeed was 911: there was information out there that might have stopped the attack if the pieces had been put together.

Of course, it isn't quite this simple, with hindsight you can look back and find the pieces that needed putting together. 500K is of course rather a lot of people to keep an eye on, OK as a table that computers can check names against, but you're not going to be able to keep track of them all.

It would be interesting to know where in the 500K people he ranked in terms of risk. A single list is less useful than a prioritised list, 500K might be manageable for singling out for special searches (depending on how many are frequent flyers). It is no use having so many on the list you can't afford to check any of them at an airport -- some prioritisation is in order.

Fancy new search equipment isn't the answer to stopping someone on your high risk list getting on a plane, that stuff is there to catch the ones you don't know about yet and to discourage the nutters. Sure, it helps when your intelligence fails, but the solution to an intelligence failure is not to beef up plan B.