I gave myself an hour to add multi-line search-and-replace support in my code.  It took 3, and C++11 std::regex_replace() gave me a hard crash with inline replacement.  The syntax can be annoying (for example, using double escape), so for reference, here’s a jumpstart.

Given:

using namespace std;
string str = "Lots of text to search\nacross lines";
string from = "text[\\s\\S]*lines";
string to = "rainbows";

Boost happily did the job:

#include 
 boost::regex reg;
 reg.assign(from);
 str = boost::regex_replace(str,reg,to,boost::match_default);

C++11 is even simpler, but it crashes with gcc 4.9.2 if you use the same string for source and target, like this:

#include 
 std::regex reg(from);
 str = std::regex_replace(str,reg,to);

You can fix that by using a swap string:

#include 
 regex reg(from);
 string newstr = regex_replace(str,reg,to);
 str = newstr;

But it isn’t working across lines, with this particular syntax, and I’ve seen others complain that they couldn’t get multiline syntax going.  I’ll stick with boost for now until this smooths out a little bit more.  Onwards.

 

Note to self: get into this phabricator command line fu.

At some point, refind stopped booting up my Macbook, and I had to use the Option (read: Alt if you’re not drinking the koolaid) key on startup to get back into OS X.  For which the drive was completely full.  Some things I went through to get going again:

  • deleted my partition table during a fit of aggressive frustration.  That was useful!  Fortunately I had gparted up and running when I did it, so with a litle math, I was able to rebuild the partition using sfdisk (also sgdisk and gdisk and … but sfdisk instructions here were clear).
  • I need to boot my Macbook with no keyboard or mouse plugged in (I suspect the mouse was nonstandard and causing driver issues)
  • Reinstall refind, and actually follow the instructions to put the boot driver in the specified place.
  • Use [nouveau.noaccel=1] with ANY recent ubuntu on my Macbook to get past nvidia hardware lockup – follow these steps to get a real nvidia driver installed that won’t lock up:
     sudo ubuntu-drivers devices      # get list of drivers
     sudo apt-get install nvidia-###  # choose ### from list
  • Make the call and reinstall OSes as needed.  Ubuntu was fairly painless to reinstall on top of existing install, now that I have great notes on setting it up, and I am getting pretty good at saving my configurations.  Remember to keep config files pushed to repo as you change them!

Down to three OSes now, ubuntu, windows, OS X.

Why do people use Github?  Oh, because they are lazy.

Rant is on the wiki about typical problems.

I played around enough with different git repository structures to know what works best for my uses (a central repo that I can pull and work on anywhere, that may or may not need to actually be updated live on the central server).  The “git central shared repository” pattern on the wiki has the details.