Act without doing, work without effort.
Think of the small as large and the few as many.
Confront the difficult while it is still easy;
accomplish the great task by a series of small steps.
- Lao-Tze
Sometimes, the code you don't write is more important than the one you write.
Whenever I start on a new task, my first question is "how can I do this without coding?".
Here's a small (true) exmaple:
We had a problem that serving files on an NFS mounted volume was slow for the first request and them it was good. Probably the mount went "stale" after a while.
First option of learning the inner working of NFS mounts was dropped immediately - you can never know how much time this tinkering will take and if it'll work eventually.
So I decided to keep the NFS mount "warm" by periodically accessing it.
First Version:
from time import sleep
from os import listdir
while 1:
listdir("/path/to/nfs")
sleep(10 * 60 * 60)
and in crontab
@reboot /usr/bin/python /path/to/script.py
Then I thought - "cron", and second version came:
from os import listdir
listdir("/path/to/nfs")</code></pre>
and in crontab:
*/10 * * * * /usr/bin/python /path/to/script.py
And then last version (just crontab):
*/10 * * * * /bin/ls /path/to/nfs
So down from 6 LOC to 3 LOC to 1 LOC - that's what I call produtivity :)