Skip to content

Finds items from your Pocket library that are relevant to trending news.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rgardner/memory-jogger

Repository files navigation

Memory Jogger

Memory Jogger CI

Ways to organize and a reason to read to your saved Pocket items.

Finds items from your Pocket library that are relevant to trending news. I have thousands of unread Pocket items and Memory Jogger enables me to find new meaning in articles and videos I saved years ago. I deployed Memory Jogger to Heroku and set up a daily job to email me unread Pocket items based on Google Trends results from the past two days. Memory Jogger is written in Rust.

Table of Contents

Features

  • Uses Google Trends to find trending news and tf-idf to rank unread Pocket items
  • Can be run locally (typically using the SQLite backend)
  • Can be run in the cloud (typically using the PostgreSQL backend)
  • Can be configured to send emails (via SendGrid)
# View relevant Pocket items based on Google Trends
$ memory_jogger relevant --user-id 1
[2020-07-09T17:23:39Z INFO  memory_jogger] finding trends
[2020-07-09T17:23:39Z INFO  memory_jogger] syncing database with Pocket
[2020-07-09T17:23:40Z INFO  memory_jogger] searching for relevant items
Trend Mary Kay Letourneau: https://trends.google.com/trends/explore?q=Mary+Kay+Letourneau&date=now+7-d&geo=US
        Hacker News Highlights, The Alan Kay Edition: https://app.getpocket.com/read/1310095698
        Excerpt - Japan\'s Decision for War in 1941: Some Enduring Lessons: https://app.getpocket.com/read/89684589
Trend Ninja: https://trends.google.com/trends/explore?q=Ninja&date=now+7-d&geo=US
        Full Spectrum Engineer Or Why The World Needs Polymaths: https://app.getpocket.com/read/350991133
Trend Roger Stone: https://trends.google.com/trends/explore?q=Roger+Stone&date=now+7-d&geo=US
        Roger Federer as Religious Experience: https://app.getpocket.com/read/1250394
        The world’s biggest telescope is ready. The problem: staffing it: https://app.getpocket.com/read/2374120153
# View Google Trends
$ memory_jogger trends
Hamilton
Canada Day
Pokemon Unite
# View full help output
$ memory_jogger --help
memory_jogger 2.0.0
Finds items from your Pocket library that are relevant to trending news.

USAGE:
    memory_jogger [FLAGS] --database-url <database-url> <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
        --trace      Shows trace messages, including potentially sensitive HTTP data
    -V, --version    Prints version information

OPTIONS:
        --database-url <database-url>     [env: DATABASE_URL=]

SUBCOMMANDS:
    completions    Generates shell completions
    db             Retrieves items from the database
    help           Prints this message or the help of the given subcommand(s)
    pocket         Interacts with Pocket
    relevant       Shows relevant Pocket items for latest trends
    saved-items    Syncs and searches saved items
    trends         Shows latest trends

Getting Started

Memory Jogger can be installed and run locally or deployed to a server.

Server Setup

See docs/heroku.md for instructions on deploying Memory Jogger to Heroku.

Local Setup

Local Installation

By default, Memory Jogger requires libpq and sqlite. Once these dependencies are installed, you can install Memory Jogger locally via Rust's package manager, cargo:

cargo install --git https://github.com/rgardner/memory-jogger.git

To install with SQLite support only:

cargo install --git https://github.com/rgardner/memory-jogger.git --no-default-features --features sqlite

To install with PostgreSQL support only:

cargo install --git https://github.com/rgardner/memory-jogger.git --no-default-features --features postgres

Local Next Steps

Once Memory Jogger is installed, you need to setup the database, get a Pocket user access token, and create the user in the database.

# For SQLite
export DATABASE_URL=<path/to/sqlite_db.db>
# For PostgreSQL
export DATABASE_URL=<postgres_connection_string>

With the DATABASE_URL environment variable set, Memory Jogger will create and/or configure the database on start-up.

Next, obtain a Pocket app consumer key by creating an application in their Developer Portal:

  • Permissions: Retrieve
  • Platforms: Desktop (other)

Set the MEMORY_JOGGER_POCKET_CONSUMER_KEY environment variable to the obtained consumer key.

Finally, create a user and set their Pocket access token.

$ memory_jogger pocket auth
Follow URL to authorize application: https://getpocket.com/auth/authorize?request_token=<redacted_request_token>&redirect_uri=memory_jogger%3Afinishauth
Press enter to continue

<redacted_user_access_token>
$ memory_jogger db user add --email <your_email> --pocket-access-token <redacted_user_access_token>
id: 1

With the required setup complete, try out Memory Jogger:

memory_jogger relevant --user-id <user_id, 1 above>

Email Setup

Email setup is optional and typically used when running Memory Jogger on a server. Memory Jogger uses SendGrid internally for sending emails. Create an account on the SendGrid website and then set the MEMORY_JOGGER_SENDGRID_API_KEY environment variable to your SendGrid API key.

Documentation

  • API documentation via rustdoc
    • Run cargo doc locally
  • Usage guides in the docs folder
  • Developer notes on the GitHub wiki

Contributing

Memory Jogger is a typical Rust application and can be built and tested via cargo (e.g. cargo build, cargo test). It also follows the xtask conventions.

$ cargo xtask -h
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/xtask -h`
xtask 0.1.0
Memory Jogger build system.

USAGE:
    xtask <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    build-docker-image
    help                  Prints this message or the help of the given subcommand(s)
    lint
    test

Large tests are disabled by default as they are slow and require Pocket test credentials. Create a separate Pocket application in the Pocket Developer Portal:

  • Permissions: Add, Modify, Retrieve
  • Platforms: Desktop (other)

Then, create a test Pocket account and authorize the test application:

MEMORY_JOGGER_POCKET_CONSUMER_KEY=<test_pocket_consumer_key> memory_jogger pocket auth

Finally, set the environment variables and enable the large_tests Cargo feature:

export MEMORY_JOGGER_TEST_POCKET_CONSUMER_KEY=<test_pocket_consumer_key>
export MEMORY_JOGGER_TEST_POCKET_USER_ACCESS_TOKEN=<test_pocket_user_access_token>
export PG_DATABASE_URL=<pg_database_connection_if_postgres_feature_enabled>
cargo test --features large_tests

Third Party API Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Finds items from your Pocket library that are relevant to trending news.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages