In 2004, I quit my job and spent six months working on Elgg full time, burning through my savings. My living room became my office, and I quickly learned I had to find a way to stay motivated and un-distracted.
I'd worked from home once before, of course, when I was doing my degree. As a student, my brain was scattered; I never figured out how to block out the world around me and concentrate on what I had to do. Partially that was because I was still figuring myself out as a person; partially that was because the Edinburgh University environment itself was sub-optimal for me. It often seemed like nobody was concentrating on the work they had to do.
For the first month or two, I'd sit and stare at my computer, make myself some food, listen to music, go for a walk - anything but actually get started on work. It'd sometimes be 3pm before I put down a single line of code or even write an email.
For the nine years since then, I've mostly had to be self-motivating. I've learned a series of very simple techniques that keep me working, let me achieve my tasks, and allow me to stay relatively sane while spending lots of time by myself. Some of them probably work just for me; some of them might be more universally helpful. Everybody's different. Nonetheless, here they are.
Don't be macho. Burning the midnight oil on a project makes you sound like you're super hard working, and it can be pretty satisfying while you're doing it. But not taking care of sleep, exercise, nutrition and your social life will very quickly impact your performance. You'll probably find that your work from 3am isn't quite as awesome as you thought it was at the time - and you'll struggle to concentrate for at least the next couple of days. Keep relatively regular hours, and take care of the rest of your life. Take regular vacations, too; downtime is good for your creativity. (The one semi-macho thing that works really well for me: sprinkling my day with regular exercise. I always walk 10,000 steps a day, and if I start my day with 100 decline crunches and some push-ups, I feel much better than when I don't. It's not hard to work yourself up to that point, either; trust me, I'm hardly what you'd call athletic.)
Drink water. Sounds dumb, right? But drinking water improves concentration. For one thing, you're keeping your brain hydrated. But coffee - or worse, sweet drinks like cordials and sodas - will set your off on a spike-and-crash pattern that gets in the way of steady thought. Bonus: drinking plenty of water through the day will also help you sleep, which also helps with concentration. It's the little things. And for the same reason:
Don't eat junk. I mean, duh. I've found that eating lighter food during the day, with plenty of vegetables and protein, results in much better work. (If possible, cook for yourself.) Actually, my biggest problem is not eating enough: it's easy to under-consume calories when you're eating things like salad. You need to give yourself enough fuel. Meanwhile, while I think they're delicious, meals with a lot of meat or carbs tend to send me to sleep. Not useful.
Find music you love. Now that we've taken care of your body, let's talk about removing all those distractions. For me, that means plugging in some ear buds (or immersive headphones; the point is to block out exterior noise) and sticking on a playlist. Usually, I'm into artists like Ani DiFranco, Hamell on Trial and Eels, but when I'm working, those don't work for me at all. Instead, I've found - and again, this is purely subjective - that the best concentration food for me is stoner music. Groups like Nightmares on Wax, Mr Scruff, Lemon Jelly: perfect. There's something about the slow beats that block out the rest of the world and promote concentration in just the right way. I consider my Spotify subscription to be one of my most important productivity tools. I've built a coding playlist, which I often use to seed a radio station. I guess one reason why stoner music works for me is that a continuous sense of calm is helpful. (It's worth saying that I don't actually get stoned, and don't recommend it.)
Don't be interrupted. Turn IM, IRC, your phone, off off off, unless you absolutely have to be contactable. If you share your home with others, let them know that when you're working you shouldn't be interrupted unless it's really important. That can be really hard to understand, and I've seen (other peoples') entire relationships disintegrate because of it. It might seem like a small thing to people who aren't in the zone, but it can take 30+ minutes to regain your concentration after you've been interrupted. (I find that even seeing people around me doing non-worky things is disruptive.)
Sit up / stand up. Working from the sofa doesn't work. Don't try it. And get up and walk around for at least 5 minutes out of every hour.
Accept that you're human. If you're bashing your head against a problem or a piece of work that doesn't seem to be budging, there's nothing to be gained by continuously, fruitlessly hammering away at it. Go for a walk; have a glass of water; focus on something that isn't your screen. When you come back to it, you'll have a much better chance of getting something done. Furthermore, everyone has bad days, and they don't make any of us feel good; if you're really getting nothing done, it's okay to go get some fresh air instead (if you can).
Find your motivation. Finally, figure out what makes you excited to work. For me, that's getting feedback, so I'll often release my work early - sometimes a little too early. Knowing that there are people - a manager, a client, users - looking forward to seeing the work I'm doing is spectacularly motivating. Other people are motivated simply by creating something beautiful, or finding an elegant solution to a problem. Again, everyone is different. It's important to understand your own goals and desires. It may help to figure out how to mark your own progress, beforehand, so you can maintain a sense of momentum.
This is probably the most important thing for me. It's not enough to have a job; I've got to be working on something that has meaning for me, in a situation where it's possible to make an impact. If I believe that the project I'm working on isn't important, or there's no way to succeed, it's all over for me. Nobody likes working on a treadmill.
All the usual advice about working with great teams comes into play here: if you're working with other people, make sure they're great people. One bad apple can poison a team, and I've certainly seen situations where one guy's poor attitude ruined an entire startup. Working at home is still working - in addition to the above, all the usual workplace tips apply.
Finally, regarding keeping your brain running, this article from the New Scientist is pretty good. I don't think I like the idea of smart drugs, but there are some solid tips here.
Written with the help of Georgie St Clair, Jonny Miller, SamarKaushal, Jaqueline Png, Danae, Joachim, Julien Genestoux, Paul Birch, Domenico Perri, Jamie Bullock, Annalyn Aguilar, Ahmed El Gabri, Kristian Kruse, Linda Mork, Zoe M. Gillenwater, Gordo, Mike Sirrah, 不能淋雨的眉毛, Niall Thompson, olga_zagorzelska, Antonella Iselli, Jack Smith, ntlk, Aisha Rawji, Lowfill Tarmak, sanjaypoyzer, Thomas Kjemperud, Chloe Nicholls, Paul Sturrock, Stef Lewandowski, Johnathan Leppert, damnitnicole, Robin Lynch, Emarcroft, fee plumley, Jeri Dansky, and Erin Jo Richey
The photo was taken in 2007, when I was working on Elgg.