I recently finished working on a thing; it was about a two week project. That doesn't sound very long, but most of the tasks I do are more like 1-2 day efforts from start to finish. Actually even that's overstating it; I just looked at my past dozen commits or so and most of them were about 3 or 4 hour chunks.
Anyhow, it was an interesting task and I was pretty locked in on it. I could tell that I was fully engaged because when I wasn't sitting at the computer I was churning the thing over in my mind. "Oh what if the blah is nil, how about if that's longer that 255 characters, hm I should add a test to ensure the frobnicator is getting set when that happens". So when I'd sit down with my laptop I could usually flip right to a particular file in the project and start transcribing whatever code I'd been thinking about. Even if I just had 5-10 minutes I could move the task forward a little bit.
Ideally this is what would happen all the time. It was like this when I was working on Deploying Rails also; whatever chapter section I was working on would percolate while I was away from the computer and then I'd unload when doing my daily pomodoro or three.
I'm not sure how to force my way into this state, and sometimes I'm working on a bunch of different things at once and each of them digests at a different rate. Somewhere I read about a technique for something like this; the guy suggested always leaving an easy thing undone so that when you go back to the computer you can say "oh I'll just knock this simple thing out" and then once you're done with that you're in the flow.
It's also helpful if I'm honest with myself about what I don't understand about the task. If I can say "huh, I really don't know what happens when x is in state y and z happens" I can then nail down that exact scenario next time I sit down at the computer. But if I sort of mentally handwave and think "oh yeah, that's all pretty straightforward" without knowing exactly how it works, then I can expend an hour or so of flailing around before admitting that I don't understand a particular thing.