Add command for creating table in README, add fish helper scripts
This commit is contained in:
parent
63f04f0041
commit
97722764e8
|
@ -4,7 +4,9 @@ This is a C port of [SD](https://git.exozy.me/a/SD), a very efficient (and a tin
|
|||
|
||||
## Usage
|
||||
|
||||
Flash cards are stored in the `cards` table of a SQLite database. There are four columns: `idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING`. The `idx` is a unique index for each card, starting at 0. The weight is how often the card should come up. The key and value are the front and reverse sides of the card. You can use the `sqlite3` CLI to create a card deck. You may be able to get twice as fast performance by enabling WAL with `PRAGMA journal_mode=WAL` because WAL only writes the content once instead of twice.
|
||||
Flash cards are stored in the `cards` table of a SQLite database. There are four columns: `idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING`. The `idx` is a unique index for each card, starting at 0. The weight is how often the card should come up. The key and value are the front and reverse sides of the card.
|
||||
|
||||
To create a card deck, use `sqlite3 cards "CREATE TABLE cards (idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING)`. You may be able to get twice as fast performance by enabling WAL with `PRAGMA journal_mode=WAL` because WAL only writes the content once instead of twice.
|
||||
|
||||
Now build this project with `gcc sd.c segmenttree.c -o sd -lsqlite3 -O2 -march=native` and run `./sd` to enjoy a fast flash cards experience! The program will display the `key` of a randomly selected card. Press any key to show the `val` of the card. Now press either `y` or `n` depending on whether you got the card correct, and the program adjusts that card's weight.
|
||||
|
||||
|
|
5
sd-add.fish
Normal file
5
sd-add.fish
Normal file
|
@ -0,0 +1,5 @@
|
|||
function sd-add
|
||||
set cardfile cards
|
||||
set idx (math 1+(sqlite3 "$cardfile" "select max(idx) from cards"))
|
||||
sqlite3 "$cardfile" "insert into cards values ($idx, 256, '$argv[1]', '$argv[2]')"
|
||||
end
|
4
sqlitevi.fish
Normal file
4
sqlitevi.fish
Normal file
|
@ -0,0 +1,4 @@
|
|||
function sqlitevi
|
||||
mv "$argv" "$argv.bak"
|
||||
sqlite3 "$argv.bak" .dump | $EDITOR | sqlite3 "$argv"
|
||||
end
|
2
test.py
2
test.py
|
@ -3,7 +3,7 @@ import sqlite3
|
|||
con = sqlite3.connect("test.db")
|
||||
con.execute("PRAGMA journal_mode=wal")
|
||||
cur = con.cursor()
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS cards (idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING)")
|
||||
cur.execute("CREATE TABLE cards (idx INTEGER PRIMARY KEY, weight INTEGER, key STRING, val STRING)")
|
||||
for i in range(10**8):
|
||||
cur.execute("INSERT INTO cards VALUES(?, ?, ?, ?)", (i, 1, i, i))
|
||||
con.commit()
|
||||
|
|
Loading…
Reference in a new issue