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.