Compare commits
23 Commits
main
..
3f45e0fbc0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f45e0fbc0 | |||
| a4da825b8e | |||
| a286eb3759 | |||
| b09e915d9e | |||
| 9c4d4aa037 | |||
| 191b10175f | |||
| 831d4f78e3 | |||
| 2d742ce3f7 | |||
| cbd92a8d42 | |||
| fdd7a7bb98 | |||
| 35cd759205 | |||
| 1260930b76 | |||
| bafbc3578c | |||
| 2925fb174c | |||
| 76a56879b0 | |||
| 1ecf16bd0a | |||
| 990c9a66bd | |||
| 4d42e6cae8 | |||
| 3d381b1a4e | |||
| f0daafc5a8 | |||
| ab910e266f | |||
| d997666bc6 | |||
| ad76ffcff4 |
@@ -0,0 +1,11 @@
|
||||
.PHONY: all build fmt
|
||||
|
||||
all: timeline.db xbit
|
||||
|
||||
xbit: build
|
||||
|
||||
build:
|
||||
go build
|
||||
|
||||
timeline.db: timeline.sql
|
||||
sqlite3 timeline.db < timeline.sql
|
||||
@@ -1,39 +0,0 @@
|
||||
# xbit
|
||||
`xbit` (xkcd backward in time) is a program for outputting historical events
|
||||
while completing a task, inspired by [xkcd](https://xkcd.com/1017). The program
|
||||
reads a SQLite database that stores event descriptions and timestamps, allowing
|
||||
you to easily add your own events of interest.
|
||||
|
||||
The provided SQL file will pre-populate the database with thousands of events
|
||||
scraped from
|
||||
[Wikipedia](https://en.wikipedia.org/wiki/Detailed_logarithmic_timeline). Of
|
||||
these events, over 300 were manually given timestamps.
|
||||
|
||||
## How to use
|
||||
First create the database:
|
||||
```
|
||||
sqlite3 timeline.db < timeline.sql
|
||||
```
|
||||
|
||||
Then set the `XBIT_DB` environment variable to the database file.
|
||||
```
|
||||
export XBIT_DB=./timeline.db
|
||||
```
|
||||
|
||||
Call the program with `xbit -p <percentage>`, like `xbit -p 0.25`. This will
|
||||
calculate a timestamp using the formula from the xkcd comic, then output
|
||||
information about the event in the database closest to that timestamp. See
|
||||
`xbit -h` for more args.
|
||||
|
||||
## Database details
|
||||
* Due to the time-consuming nature of manually assigning timestamps, there are
|
||||
many events that were scraped from Wikipedia but not given timestamps. You
|
||||
may wish to skim through these and add timestamps to events you personally find
|
||||
interesting.
|
||||
* For an event to be output by `xbit`, it must have an entry in the database
|
||||
with a unix timestamp of when the event occured. You can optionally set bools
|
||||
in the "known" columns to indicate how precise your timestamp is. These may be
|
||||
used to modify how the event is output.
|
||||
* There are a few other columns that mainly exist as artifacts from the
|
||||
scraping process. These are not used by `xbit` and do not need to be
|
||||
populated.
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -111,14 +110,9 @@ func main() {
|
||||
ulimit = t
|
||||
}
|
||||
|
||||
dbpath := os.Getenv("XBIT_DB")
|
||||
if dbpath == "" {
|
||||
log.Fatal("XBIT_DB not set")
|
||||
}
|
||||
|
||||
var db TimelineDB
|
||||
var err error
|
||||
db.DB, err = sql.Open("sqlite3", dbpath)
|
||||
db.DB, err = sql.Open("sqlite3", "./timeline.db")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user