Compare commits

..

23 Commits

Author SHA1 Message Date
filifa 3f45e0fbc0 slight restructure 2024-02-24 23:13:26 -06:00
filifa a4da825b8e change module path 2024-02-24 23:06:49 -06:00
filifa a286eb3759 add makefile 2024-02-24 20:33:41 -06:00
filifa b09e915d9e remove prepared statement 2024-02-24 20:28:19 -06:00
filifa 9c4d4aa037 make n flag uint 2024-02-24 19:19:38 -06:00
filifa 191b10175f move limits logic to main 2024-02-24 19:13:06 -06:00
filifa 831d4f78e3 split limit determination into separate function 2024-02-24 18:21:24 -06:00
filifa 2d742ce3f7 add -a and -b flags 2024-02-24 17:59:36 -06:00
filifa cbd92a8d42 add -n check 2024-02-24 01:04:11 -06:00
filifa fdd7a7bb98 have output() return errors on null data 2024-02-24 00:47:54 -06:00
filifa 35cd759205 fix runtime error when -n is larger than number of rows in query 2024-02-23 23:54:54 -06:00
filifa 1260930b76 add flag for outputting multiple events 2024-02-23 23:04:35 -06:00
filifa bafbc3578c return errors 2024-02-22 23:36:57 -06:00
filifa 2925fb174c print "years ago" instead of date when not yearknown 2024-02-22 22:54:45 -06:00
filifa 76a56879b0 split output code into method 2024-02-22 22:33:54 -06:00
filifa 1ecf16bd0a add infra for unknown dates 2024-02-22 22:25:51 -06:00
filifa 990c9a66bd add basic go program 2024-02-21 22:17:02 -06:00
filifa 4d42e6cae8 add timestamps 2024-02-18 19:04:41 -06:00
filifa 3d381b1a4e don't track db files 2024-02-12 23:51:15 -06:00
filifa f0daafc5a8 add index on timestamp column 2024-02-12 23:41:35 -06:00
filifa ab910e266f restructure table 2024-02-12 23:30:11 -06:00
filifa d997666bc6 delete some bad rows 2024-02-12 23:10:09 -06:00
filifa ad76ffcff4 initial commit 2024-02-12 22:47:58 -06:00
3 changed files with 12 additions and 46 deletions
+11
View File
@@ -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
-39
View File
@@ -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.
+1 -7
View File
@@ -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)
}