mako132 notes that he does some of his best thinking in the bathroom.
Many of us are similar. As Dana Carvey noted in Opportunity Knocks, important decisions are made not in the boardroom, but the bathroom.
It's to the point where if I have a difficult problem to solve, and I run into a mental block, I go to the bathroom, and almost inevitably, I have the solution before I leave, often within a few minutes.
Today I could not figure out a regex problem, so I finally gave up on my own powers and trusted the Magic Bathroom to help me. Well, "trusted" is a bit strong: I brought Camel 3 with me. But after a few moments I put it down, and trusted in the Bathroom. A minute or so later, I had the answer.
I washed my hands and returned quickly to the computer and typed it in, and it worked. And then I had to have a coworker help explain to me why it worked. I think the Bathroom revealed this to me, but it didn't stick. Or maybe it didn't reveal it all to me, but just what was necessary.
Whatever. I love you, Magic Bathroom.
Re:and the regex problem/solution was?
pudge on 2004-12-14T19:39:16
It had to do with alternation and backtracking. We were matching any consecutive nonwhitespace chars, and treating HTML entities as single chars, for the purpose of counting (we were breaking up strings of $n chars) and to make sure we don't split in the middle of the entities. So something like this (simplified):Consider $foo = 'abc&' and $n = 3. I would want 'abc' to match, and '&' to not match, since it is not 3 chars long. '&am' matches, but I don't want it to to match. So how to make it not match?$foo =~/\G (( &\w+; | \S ){$n}) /gx;
I added negative lookahead:This way, when it backtracks after the &\w+; fails, it will try to proceed with \S, but fail because the lookahead sees the '&'.$foo =~/\G (( &\w+; | (?!&\w+;)\S ){$n}) /gx;
It's not the most complicated thing, but sometimes we have mental blocks... and bathrooms are where you relieve blockages ... (sorry :)