2017: new website withπ
β‘οΈ collect social media time series: facebook, twitter, mailchimp subscribers
Cron is one of the most useful utility that you can find in any Unix-like operating system. It is used to schedule commands at a specific time. These scheduled commands or tasks are known as "Cron Jobs". (Source)
Cron is one of the most useful utility that you can find in any Unix-like operating system. It is used to schedule commands at a specific time. These scheduled commands or tasks are known as "Cron Jobs". (Source)
50 23 * * * /usr/lib/R/bin/Rscript '/home/frie/correlaid-utils/correlaid-analytics/run.R'
Note: Slide adapted from Alex Kapps presentation, see here. Image source: https://ostechnix.com/wp-content/uploads/2018/05/cron-job-format-1.png.
Raspberry Pi + R + mlab, cf. talk at OODM
AWS Lambda, Serverless & Python, cf. talk at OODM
β
Raspberry Pi + R + GitHub + GitHub actions
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. [...] The purpose of Lambda, as compared to AWS EC2, is to simplify building smaller, on-demand applications [...] ((Wikipedia)
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. [...] The purpose of Lambda, as compared to AWS EC2, is to simplify building smaller, on-demand applications [...] ((Wikipedia)
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. [...] The purpose of Lambda, as compared to AWS EC2, is to simplify building smaller, on-demand applications [...] ((Wikipedia)
event-driven: it only runs responding to an event - the event can be a cronjob π
serverless: underlying servers are automatically started + stopped by AWS (-> RIP fripi)
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. [...] The purpose of Lambda, as compared to AWS EC2, is to simplify building smaller, on-demand applications [...] ((Wikipedia)
event-driven: it only runs responding to an event - the event can be a cronjob π
serverless: underlying servers are automatically started + stopped by AWS (-> RIP fripi)
AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. [...] The purpose of Lambda, as compared to AWS EC2, is to simplify building smaller, on-demand applications [...] ((Wikipedia)
event-driven: it only runs responding to an event - the event can be a cronjob π
serverless: underlying servers are automatically started + stopped by AWS (-> RIP fripi)
correlaid-analyticsβββ daily.pyβββ deploy-analytics.shβββ every_monday.pyβββ package-lock.jsonβββ requirements.txtβββ serverless.ymlβββ setup.sh
The serverless framework allows to define Lambda functions in a yml file (serverless.yml
) and makes deployment to AWS very easy.
functions: daily_correlaid_analytics: handler: daily.get_correlaid_data events: - schedule: rate: cron(56 22 * * ? *)
Deployment with:
serverless deploy -v
## cronR job## id: daily_analytics## tags:## desc: Get daily CorrelAid Analytics50 23 * * * cd '/home/frie/correlaid-utils/correlaid-analytics' && /usr/lib/R/bin/Rscript '/home/frie/correlaid-utils/correlaid-analytics/run.R' > '/home/frie/correlaid-utils/correlaid-analytics/run.log' 2>&1
set up with the very helpful {cronR} π¦
## cronR job## id: daily_analytics## tags:## desc: Get daily CorrelAid Analytics50 23 * * * cd '/home/frie/correlaid-utils/correlaid-analytics' && /usr/lib/R/bin/Rscript '/home/frie/correlaid-utils/correlaid-analytics/run.R' > '/home/frie/correlaid-utils/correlaid-analytics/run.log' 2>&1
set up with the very helpful {cronR} π¦
library(here)print("==============================")print(Sys.time())source(here::here("correlaid-analytics/01_get_daily_analytics.R"))source(here::here("correlaid-analytics/02_git.R"))
correlaid-analytics/βββ 01_get_daily_analytics.Rβββ 02_git.Rβββ cron.Rβββ dataβ βββ all_daily.csvβββ run.logβββ run.R
library(smcounts)smcounts::collect_data
## function (slack = TRUE, facebook = TRUE, twitter = TRUE, mailchimp = TRUE) ## {## df <- tibble::tibble(date = c(), platform = c(), n = c())## if (slack) {## slack_df <- ca_slack()## df <- rbind(df, slack_df)## }## if (facebook) {## facebook_df <- ca_facebook()## df <- rbind(df, facebook_df)## }## if (twitter) {## twitter_df <- ca_twitter()## df <- rbind(df, twitter_df)## }## if (mailchimp) {## mailchimp_df <- ca_newsletter()## df <- rbind(df, mailchimp_df)## }## return(df)## }## <bytecode: 0x7ffd289e57e8>## <environment: namespace:smcounts>
# gert (https://docs.ropensci.org/gert/index.html)library(gert)gert::git_pull()print(gert::git_status())gert::git_add("correlaid-analytics/data/all_daily.csv")gert::git_commit(message = "π€ CRON - update daily data", author = git_signature("raspi3", "raspi3@pr130.dev"))gert::git_push()
ca_counts <- readr::read_csv("https://raw.githubusercontent.com/friep/correlaid-utils/main/correlaid-analytics/data/all_daily.csv")
## ## ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ## cols(## date = col_date(format = ""),## platform = col_character(),## n = col_double()## )
all_daily.csv
in last 24 hoursThings you can learn: git, cron jobs, ssh, scp, basics of networking, command line, bash scripting, to write code that works not only on your machine...
Buy a Raspberry Pi, if...
Things you can learn: git, cron jobs, ssh, scp, basics of networking, command line, bash scripting, to write code that works not only on your machine...
Buy a Raspberry Pi, if...
Don't buy one if...
Keyboard shortcuts
β, β, Pg Up, k | Go to previous slide |
β, β, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |