BUG: Fix bug that killed YVBKeystrokesDataManager

Callbacks received in YVBKeystrokesDataManager were executed on the main
thread; while most of the times these callbacks were fairly quick to
execute, there gets to be a point where this is no longer the case and
the program ends up generating a timeout error as the code to be
executed in each block took a relatively long time.

This code has been moved to exist in a separate thread with a low
priority. The previous threading approach only executed "time-consuming"
operations in a different thread, with this approach we guarantee the
tasks in the main thread are all very light.

Memo
====

Finding this bug was not easy, though the solution was rather "clear" if
you look at the block that gets executed with every keystroke, the
structure looks like this:

BLOCK:
    UPDATE GUI
    ADD ENTRY TO DB

Given that we cannot move the GUI operations to a separate thread, it
was rather clear that adding the entry to the DB was the only thing that
could be moved, the callback now looks like this:

BLOCK:
    UPDATE GUI
    ADD NEXT OPERATION TO A LOW PRIORITY THREAD:
        ADD ENTRY TO DB

I have also changed the mask of the things that the keylogger responds
to, we now only respond to kCGEventKeyDown events, making the usage even
lighter on the main thread.
Merge branch 'fix-key-tap'
DOC: Enhance readme and add a license.
ENH: Improve query performance

Converting into date objects tooked a lot more time than using strftime
to format the necessary dates:

Here's how the old queries performed in a 6,365,487 database:

sqlite> .timer on

sqlite> SELECT COUNT(*) FROM keystrokes WHERE DATE(timestamp) =
DATE('now','localtime');
1727
Run Time: real 3.175 user 2.926497 sys 0.247691
sqlite> SELECT COUNT(*) FROM keystrokes WHERE timestamp >=
strftime('%Y-%m-%d 00:00:00', 'now', 'localtime');
1727
Run Time: real 1.368 user 1.137941 sys 0.230452

sqlite> SELECT COUNT(*) FROM keystrokes WHERE DATE(timestamp) >
DATE('now','-7 day','localtime');
94769
Run Time: real 3.171 user 2.922923 sys 0.248817
sqlite> SELECT COUNT(*) FROM keystrokes WHERE timestamp >=
strftime('%Y-%m-%d 00:00:00', 'now', '-7 day', 'localtime');
113116
Run Time: real 1.400 user 1.161024 sys 0.238614

sqlite> SELECT COUNT(*) FROM keystrokes WHERE DATE(timestamp) >
DATE('now','-30 day','localtime');
572174
Run Time: real 3.289 user 3.029394 sys 0.258767
sqlite> SELECT COUNT(*) FROM keystrokes WHERE timestamp >=
strftime('%Y-%m-%d 00:00:00', 'now', '-30 day', 'localtime');
603311
Run Time: real 1.387 user 1.155033 sys 0.232043

In summary:

*=============================*
| query |   old    |    new   |
*=============================*
| today |  3.1750  |  1.3680  |
*-----------------------------*
| week  |  3.1710  |  1.4000  |
*-----------------------------*
| month |  3.2890  |  1.3870  |
*-----------------------------*

https://i.imgur.com/969iean.jpg
TST: Add Travis hook to Keystats

Had to convert the scheme into a shared scheme.
ENH: Add icon to README.md
DOC: Add missing license for FMDB
ENH: Add frontmostApplication to the database

Update data manager to the an application name along with the keystroke
and other information in the database. This required the tests to be
updated as well, along with the database files.

Fixing any existing database should be a matter of:

$ sqlite3 ~/Library/Application\ Support/Keystats/keystrokes
SQLite version 3.8.4.3 2014-04-03 16:53:12
Enter ".help" for usage hints.
sqlite> ALTER TABLE keystrokes ADD COLUMN application varchar(32);
ENH: Use bundle identifier instead of name

Using the application's bundle identifier gives us the opportunity to
later on retrieve more information about the program itself. While if we
were storing the application's name tracing back the binary would have
been harder.
Change bundle id to be com.eldeveloper.Keystats
ENH:Add retrieval of earliest date to data manager

The data manager will fetch whichever the earliest known date is in the
database.
TST: Add tests for getEarliestDate method
ENH: Add GUI elements for earliest known date

This required the interface structure to change a little big.

In summary the major changes are:

- All results are now displayed on screen using a gray color instead of
  a black color.
- The summary view uses the full window.
- There's a label that indicates what the earliest known date is.

Additionally the necessary logic has been added to show a message of "no
collected" data when the earliest date is (NULL).
DOC: Fix typos and update screenshot
ENH: Use argument substitution fo DB inserts

Using a dictionary of key-value pairs allows us to sanitize the inserts
and don't have to worry about statements with weird characters.
MAINT: Use low priority thread for insertions
MAINT: Add NSAlert for failed inserts
MAINT: Remove NSLog from tests
ENH: Add base work on retrieving ks per day

There are still tests that need to be added and make sure that this will
be compatible with Core Plot.
BUG: Fix crash caused by locked threads

Stocastically the application would crash and get to a point where more
than 64 threads were being executed. Analyzing the application using
Activity Monitor showed that it was a call to
[[[NSWorkspace sharedWorkspace]  frontMostApplication] bundleIdentifier]
that was locking the threads.

From the documentation it seems like frontMostApplication is not a
thread safe method.

This is an example of the relevant piece of the trace that I got when
the app crashed:

2317 Thread_5993572   DispatchQueue_4: com.apple.root.low-priority  (concurrent)
+ 2317 start_wqthread  (in libsystem_pthread.dylib) + 13  [0x7fff8e9d0fb9]
+   2317 _pthread_wqthread  (in libsystem_pthread.dylib) + 314  [0x7fff8e9cdef8]
+     2317 _dispatch_worker_thread2  (in libdispatch.dylib) + 40  [0x7fff90678177]
+       2317 _dispatch_root_queue_drain  (in libdispatch.dylib) + 326  [0x7fff90677082]
+         2317 _dispatch_client_callout  (in libdispatch.dylib) + 8  [0x7fff9067528d]
+           2317 _dispatch_call_block_and_release  (in libdispatch.dylib) + 12  [0x7fff906781bb]
+             2317 __45-[AppDelegate applicationDidFinishLaunching:]_block_invoke_2  (in Keystats) + 251  [0x10bc7075b]  AppDelegate.m:180
+               2317 -[NSRunningApplication bundleIdentifier]  (in AppKit) + 96  [0x7fff937d8468]
+                 2317 -[NSLock lock]  (in Foundation) + 145  [0x7fff962428bb]
+                   2317 _pthread_mutex_lock  (in libsystem_pthread.dylib) + 372  [0x7fff8e9cf779]
+                     2317 __psynch_mutexwait  (in libsystem_kernel.dylib) + 10  [0x7fff8efc2746]