Coronavirus disease 2019 (COVID-19) information on Telegram Messenger @corona_cases_bot
The Internet interprets censorship as damage and routes around it.
- John Gilmore
- Java on GuixOS:
guix install openjdk:jdk. Thanks to awb99 - Clojure
- Heroku for Clojure
# on Ubuntu:# The `sudo snap install heroku --classic` doesn't work on Ubuntu# See https://github.com/heroku/cli/issues/822 curl https://cli-assets.heroku.com/install.sh | sh # on Guix: npm install -g heroku sudo rm /usr/local/bin/heroku sudo ln -s /home/bost/.npm-packages/bin/heroku /usr/local/bin/heroku- Babashka
- postgresql:
## on Ubuntu: sudo apt install --yes postgresql postgresql-contrib # TODO see the the proposition given by the installation process:# You can now start the database server using:# pg_ctlcluster 13 main start sudo systemctl status postgresql.service sudo systemctl stop postgresql.service pgdata=./var/pg/data pglog=./var/log/postgres.log mkdir -p $pgdata sudo chmod --recursive u=rwx,g=rwx,o=rwx ./var/ sudo --shell --user=postgres # when using fish shell:set --export PATH /usr/lib/postgresql/*/bin $PATH initdb $pgdata# dropdb postgres && rm -rf $pgdata pg_ctl --pgdata=$pgdata --log=$pglog start # see also: postgres --pgdata=$pgdata &## on Guix: pg_ctl --pgdata=$pgdata --log=$pglog startOpen new console and log in
# in case of:# psql: error: FATAL: role "username" does not exist# sudo --user=postgres createuser -s <username># or:# createuser --shell postgres # on guix psql --dbname=postgres # or:# sudo -u postgres psql --dbname=postgres\conninfo -- list databases: \l \l+ SELECT datname FROM pg_database; - Telegram Chatbot
- Heroku App, optionally add the Papertrail add-on
Create .env in the project root directory and set the CLOJURE_CLI_VERSION:
echo \ "# See also .custom.env# The value must be one of `(keys corona.envdef/environment)`;# lower-cased and not surrounded by the double quote chars \"\".CORONA_ENV_TYPE=hokuspokus# (keyword corona-cases)# (keyword hokuspokus)# (keyword \"local\")# (keyword \"devel\")# https://clojure.org/guides/getting_started#_installation_on_linuxCLOJURE_CLI_VERSION=0.0.0.0PAPERTRAIL_API_TOKEN=\$PAPERTRAIL_API_TOKEN_HOKUSPOKUSTELEGRAM_TOKEN=\$TELEGRAM_TOKEN_HOKUSPOKUS# PAPERTRAIL_API_TOKEN=\$PAPERTRAIL_API_TOKEN_CORONA_CASES# TELEGRAM_TOKEN=\$TELEGRAM_TOKEN_CORONA_CASES"> .env heroku_clj updateClojureCliVersion- Define Heroku config vars See https://dashboard.heroku.com/apps/<HEROKU-APP-NAME>/settings. It should contain:
heroku config --app <HEROKU-APP-NAME> CLOJURE_CLI_VERSION: ... COMMIT: ... CORONA_ENV_TYPE: ... PAPERTRAIL_API_TOKEN: ... REPL_PASSWORD: ... REPL_USER: ... TELEGRAM_TOKEN: ...- Get the test data and start the mockup data service Initially, copy the whole project to a separate directory:
cd .. cp -r corona_cases/ corona_cases.data cd corona_cases.data- Repeatedly
heroku_clj getMockData clj -X:mockup-server- Start the nREPL from the command line:
clojure -Sdeps '{:deps{nrepl/nrepl{:mvn/version "0.9.0"} refactor-nrepl/refactor-nrepl{:mvn/version "3.5.5"} cider/cider-nrepl{:mvn/version "0.28.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware"]'Then in Emacs M-x cider-connect-clj
- Start the telegram chatbot long-polling:
(require '[corona.telegram]) (corona.telegram/start)- Start the web server:
(require '[corona.web]) (alter-var-root #'system component/start)and check the http://localhost:5050/ if it's running.
On PostgreSQL 13.3 no var/pg/postgresql.conf changes needed.
On PostgreSQL 13.6, in the var/pg/postgresql.conf:
- activate:
unix_socket_directories = '/tmp' # comma-separated list of directories - comment out:
# lc_messages = 'en_US.utf8' # locale for system error message # # strings # lc_monetary = 'en_US.utf8' # locale for monetary formatting # lc_numeric = 'en_US.utf8' # locale for number formatting # lc_time = 'en_US.utf8' # locale for time formatting # start Postgres pg_ctl --pgdata=./var/pg --log=./var/log/postgres.log start # on Guix# pg_ctl --pgdata=./var/pg stop bin/build && heroku local --env=.custom.env # or:# bin/build && heroku local --env=.custom.env --set COMMIT=...heroku_clj deploy --heroku-env hokuspokus # heroku_clj promotesudo apt install postgresql postgresql-contrib # Switch over to the postgres account: sudo su postgres createdb postgres # or: dropdb postgres# psql --dbname=postgres --echo-all --file=dbase/my.sql | rg "ERROR\|NOTICE|WARN"# psql --dbname=postgres --quiet --file=dbase/drop-everything.sql psql --dbname=postgres --quiet --file=dbase/my.sql # get the psql prompt: psql --dbname=postgresthen
-- help \? -- list roles / show users \du -- list tables \dt -- list sequences \ds -- list indices \di heroku_clj updateClojureCliVersion # like `lein ancient`# see also https://github.com/practicalli/clojure-deps-edn# clojure -Spom # generate the pom.xml clojure -M:outdated --upgrade # --force# Inspect logfile:# heroku plugins:install heroku-papertrail heroku pt ":type -'ssl-client-cert' -'$MY_TELEGRAM_ID'" --app <HEROKU-APP-NAME>| grep -v -e '^[[:space:]]*$# Inspect memory:# sudo apt install visualvmvisualvm -J-DsocksProxyHost=localhost -J-DsocksProxyPort=1080 & disown# get command line accessTODO it reads the .bashrc and/or .bash_profile HUH!heroku run bash --app <HEROKU-APP-NAME># postgres database command lineheroku pg:psql --app <HEROKU-APP-NAME> <DATABASE>


