Sunday, May 17, 2009

Making a C++ object printable to standard output

You want to make a C++ object printable to the standard output. For example you have an object call ScoredSequence and you want do be able to do: ScoredSequence s("BLAHBLAH"); cout << s; You need to add a << operator to ScoredSequence, for example:

class ScoredSequence {
public:

ScoredSequence(string s) : sequence(s) {
}


string get_sequence() {
return s;
}

/// \brief Extractor which prints the whole sequence.
inline friend std::ostream& operator<<(std::ostream& out, const ScoredSequence& s) {
out << s.get_sequence();
return out;
}

private:
string sequence;
};

Tuesday, May 12, 2009

delete all linefeeds from a file

like this:

tr -d "\n" < gaps2 > nogaps

Thursday, May 7, 2009

Connect to Freerunner Android from Opensuse

Plug in the freerunner, and yast2 should prompt you to configure a new network device of type usb. Follow the instructions, and configure using ifup (Not network manager) and use a static IP address for the freerunner. Assign it to 192.168.0.200.

The adb program is available here: http://people.openmoko.org/sean_mcneil/adb

Download it and put it somewhere and make it executable.

Then save this set of commands as a bash script with a name like connect or whatever.

#!/bin/bash

$/usr/local/share/adb kill-server
$ADBHOST=192.168.0.202 /usr/local/share/adb devices
$/usr/local/share/adb shell


Make this executable and then run it. It should drop you automatically into the shell interface on your freerunner.