I just started learning ruby, and have run into the problem that the Regexp class doesn't have a search method for matching all occurances of a pattern in a string. With a little help from ruby-lang irc, I am now using this extension for Regexp:
class Regexp
def search(string, offset=0)
string.scan(self) { |txt| yield Regexp.last_match }
end
end
Ruby 1.9 has a match method that takes an offset, but it only returns a single MatchData object. The above is much simpler to use IMHO.
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
February 12, 2008
September 29, 2007
Logitech, never again
I have just spend close to a month trying to track down unrepeatable behaviour in an application I am writing. The application is pretty hairy, and contains lots of matrices that are nearly singular, and I was imagining all sorts of weird numeric problems. But no. The problem was with the software that I installed for my Logitech video/web camera.
Essentially Logitech, in their wisdom, decided it would be a good idea to inject their lvprcinj.dll into everything possible, my program included. Something in that dll was causing unrepeatable behaviour in my program. Thank you Logitech for your malware. Problem solved. I for one will never buy a Logitech product again.
Essentially Logitech, in their wisdom, decided it would be a good idea to inject their lvprcinj.dll into everything possible, my program included. Something in that dll was causing unrepeatable behaviour in my program. Thank you Logitech for your malware. Problem solved. I for one will never buy a Logitech product again.
November 28, 2006
cygwin, mingw and runtime libraries
I have been trying to get gcc to compile dll's that I can use with msvc 8.0. Turns out that the accepted practice involves taking the standard mingw/cygwin install and copying and renaming library files.
The compiler always wants to link msvcrt.dll, so to link with msvcr80 we have to create a directory containing a copy of the mingw/cygwin distribution's msvcr80.a library renamed to msvcrt.a, and then specify this directory as a library path when we link.
Wouldn't it be simpler if the distribution came set up that way?
The compiler always wants to link msvcrt.dll, so to link with msvcr80 we have to create a directory containing a copy of the mingw/cygwin distribution's msvcr80.a library renamed to msvcrt.a, and then specify this directory as a library path when we link.
Wouldn't it be simpler if the distribution came set up that way?
Subscribe to:
Posts (Atom)