Saga
.

This entry is about a tool called Saga,
https://github.com/cratuki/standard/blob/master/saga


:: Chronological tracking

You work on many projects over many years. It would be easy to lose data in a
fog of lost disks and subdirectories. Saga allows you to keep track of your
data over a career of work.

I think about data chronologically. I might forget the name I gave a project,
but will remember that I was working on it in August around the same time as
another project that I do remember.

The code length of saga is shorter than the text of this post.


:: Usage

Saga creates directories which are named so that when you sort them all you
get them back in chronological order.

Basic usage:

```sh
$ 
$ # default usage echos the complete list of files
$ saga
[...]
20111031.cturner.bump.aa.python.twisted.standardio.insults
20111108.cturner.bump.aa.freepascal
20111205.cturner.bump.aa.curses.client
20111221.cturner.bump.aa.golang
20111226.cturner.bump.aa.roguelike.messaround
20111230.cturner.bump.aa.moria
$
$ # this creates a new directory and echo the filename
$ saga sample
/home/cturner/saga/20120101.bump.cturner.ad.sample
$
$ # echos the name of the most recently created dir
$ saga -z
/home/cturner/saga/20120101.bump.cturner.ad.sample
$
$ # dash z makes it easy to change to the most recent dir
$ cd `saga -z` 
$ pwd
/home/cturner/saga/20120101.bump.cturner.ad.sample
$ 
```

Browsing the filesystem from the console, so we can see those structures,

```sh
$ cd $HOME/saga
$ cd saga
$ ls -lF
[...]
/home/cturner/saga/20121115.memlab.cturner.aa.hotels.for.florida                                           
/home/cturner/saga/20121115.memlab.cturner.ab.bash.dialog.notes                                                
/home/cturner/saga/20121116.memlab.cturner.aa.work.out.how.to.deal.with.longs.in.python                     
/home/cturner/saga/20121116.memlab.cturner.ab.python.pattern.access.a.shared.lib.from.ctypes
/home/cturner/saga/20121121.memlab.cturner.aa.whitenoise                                    
/home/cturner/saga/20121121.memlab.cturner.ab.vastness                               
/home/cturner/saga/20121122.memlab.cturner.aa.python.pattern.drop.server.OBSOLETE       
/home/cturner/saga/20121122.memlab.cturner.ab.python.pattern.client.socket.echo           
/home/cturner/saga/20121123.memlab.cturner.aa.square.measurements                     
/home/cturner/saga/20121123.memlab.cturner.ab.python.doc.socket.programming.howto             
[...]
```

Note use of the aa, ab and ac tokens where multiple directories are created on
one day. If we create several entries on the same day, these tokens retain
chronological order.

It is good to have the date, username and host encoded into the directory.
Imagine you are looking through your records in five or ten years time. You
can know exactly the circumstances in which the entry was raised.

You may have copied the directories between several computers in that time.
All the unix times will have changed. But the directory is named to give you
good context.


:: Searching

Searching:

```sh
$ saga | grep python
20090506.craig.xussbaum.aa.python.getopt
20090507.craig.xussbaum.aa.couchdb.python
20090707.craig.xussbaum.ac.cocos.python
20090717.craig.xussbaum.aa.bpython
20101031.cturner.bump.aa.python.wikitools.pattern.dev
20101031.cturner.bump.ac.python.fuse.pattern.dev
20101204.cturner.bump.aa.python.threading.roguelike.sir_lewk.tetrisrl
20110611.cturner.bump.aa.extending.python.with.c
20111031.cturner.bump.aa.twisted.standardio.insults
$ cd 20111031.cturner.bump.aa.twisted.standardio.insults
$ ls
example.py
$ cat example.py
#
# http://twistedmatrix.com/pipermail/twisted-python/2007-October/016109.html
#
# start with twistd -noy example.py
#
import os, tty, sys, termios

from twisted.application import service
[etc]
```


:: Links keep track of frequently-used directories

You will find that you use some saga directories regularly, and do not want
to type in the full name regularly.

Create a directory, /home/username/l.

L is short for 'link'.

Make symbolic links from ~/l to you favourite saga directories.

This creates a clean home directory,

```sh
$ cd $HOME
$ ls -1
bin
l
saga
tmp
$
```


:: Backups

It is easy to keep backups for this system. Get two large usb disks and a fire
bucket. Put the fire bucket in your garage. Create an encrypted partition on
each of the usb disks. Keep one disk in the machine. Use cron to rsync your
saga structure to it once a day. Switch this disk to the fire bucket once a
week.


:: Close

I created this system originally because on any given day I would deal with
data from multiple customers and wanted to have perfect retention with a
responsive system. No web bug tracking system could match this for speed.

Since writing Saga, a commercial tool has emerged that serves a similar
purpose, Evernote. Saga is far simpler. With tools like Evernote, I worry what
happens when I need to access data, and find they have gone out of business.

Since creating it, I have also found it useful for capturing code snippets,
and pretty much everything else in my life also.

Here is the tool: https://github.com/cratuki/standard/blob/master/saga