Code Monkey home page Code Monkey logo

crush_curve's Introduction

Crush the Curve

site preview

Each cell shows the number of positive test results that day. Green is winning. Visualization inspired by Yaneer Bar-Yam from endcoronavirus.org. The data is retrieved from RIVM using a cron job.

Develop

Prerequisite

Setup

Install Ruby gems:

bin/bundle install

To create and prepare the PostgreSQL database:

bin/rake db:create
bin/rake db:seed
bin/rails db:migrate

To fetch and process data:

bin/rake data:fetch
bin/rake data:process
bin/rake data:fetch_provinces

Run the server:

bin/rails s

Contribute

The site is designed around Dutch data, but pull requests are welcome to make the code more abstract, import data from other countries and display text in different languages. However you will have to host it yourself.

Deploy

The site is currently deployed on an Ubuntu server roughly based on this guide. It's hosted on TransIP.

A cron job and bash script take care of syncing and processing data:

[email protected]
# m h  dom mon dow   command
39 * * * * /usr/bin/cronic ~/rake_sync.sh

rake_sync.sh:

PATH=$PATH:/usr/local/bin:/home/crush/.rbenv/bin:/home/crush/.rbenv/shims
eval "$(rbenv init -)"
cd ~/crush_curve/current
RAILS_ENV=production bundle exec rake data:fetch data:process data:notify

To enable Safari push notifications, you need register a Website Push Identifier as well as a Website Push Certificate. Import the certificate into your keychain, export it as p12 and then convert to pem:

openssl pkcs12 -in crush.p12 -out crush.pem -nodes

Put the certificate password in .rbenv-vars on your server:

RAILS_MASTER_KEY=...
DATABASE_URL=postgresql://crush:[email protected]/crush_curve
EXCEPTION_FROM_EMAIL=bugs@...
[email protected]
CERT_PWD=...

Create a directory shared/certs and upload crush.pem and crush.p12 to it. Also download Apple's intermediate cert:

wget https://developer.apple.com/certificationauthority/AppleWWDRCA.cer

Finally run a rake task to prepare your application:

RAILS_ENV=production bundle exec rake safari:register_app

Afaik it's not possible to test push notifications on your local development machine. But you can check for problems with your certificate in the Rails Console, by trying SafariSubscription.generate_package(SecureRandom.hex).

On production you can monitor your log for requests to /push/v for errors reported by Apple's server.

crush_curve's People

Contributors

sjors avatar dependabot[bot] avatar hbokh avatar taylan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.