Skip to content

Instantly share code, notes, and snippets.

View maelle's full-sized avatar

Maëlle Salmon maelle

View GitHub Profile
@maelle
maelle / get_followers.R
Created July 24, 2017 07:33
Waiting + saving intermediary results in order to be able to re-launch if script stopped
get_followers_and_wait <- function(user){
# don't re-query the same data twice
exists <- paste0("followers", user, ".RData") %in% dir("data/2017-06-03-twitter")
if(exists){
# if it already exists use it
load(paste0("data/2017-06-03-twitter/followers", user, ".RData"))
}else{
# otherwise query after checking the rate limit
rates <- rtweet::rate_limit(token = rtweet::get_tokens(),
query = "followers/ids")
@maelle
maelle / winner.R
Last active October 4, 2017 06:10
Get book winner!
library("rtweet")
set.seed(1)
these_are_locke_followers <- rtweet::get_followers("lockedata")
winning_index <- sample.int(nrow(these_are_locke_followers), 1)
this_is_a_locke_winner <- these_are_locke_followers[winning_index,]
this_is_a_locke_winner_info <- rtweet::lookup_users(this_is_a_locke_winner)
paste0(this_is_a_locke_winner_info$name, " (@",
this_is_a_locke_winner_info$screen_name,
praise::praise(") is ${adjective} and won!"))

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@maelle
maelle / unconf18_list_following.R
Last active April 26, 2018 03:02
How to follow all members of the unconf18 Twitter list
# First step is to authenticate yourself see http://rtweet.info/articles/auth.html
# your username
who <- "ma_salmon"
# Users I already follow
following <- rtweet::get_friends(users = who)
# Users from the list
unconf18 <- rtweet::lists_members(slug = "ropensci-runconf18",
owner_user = "ropensci")
@maelle
maelle / thumbs.md
Created April 12, 2018 13:11
Thumbs up via ghrecipes
@maelle
maelle / labels.R
Created April 16, 2018 08:55
Create labels for the unconf18 repo issue tracker
# not possible to change labels via V4
# https://platform.github.community/t/mutations-for-label/2144
# list labels
current_labels <- gh::gh("/repos/:owner/:repo/labels",
owner = "ropensci",
repo = "unconf18")
current_labels <- purrr::map_chr(current_labels, "name")
# delete all labels
@maelle
maelle / codemetar_ctb.R
Created April 23, 2018 06:47
Programmatically update contributor list
library("magrittr")
# get current author list
codemetar_current_desc <- ghrecipes::get_description("ropensci",
"codemetar",
branch = "dev")
# parse it to a data.frame
parse_author <- function(person){
if(!is.null(person$family)){
tibble::tibble(given = person$given,
@maelle
maelle / java.R
Created July 25, 2018 07:15
Tell me which R packages have a Java dependency https://twitter.com/mattmoehr/status/1021979537905790982
``` r
cran_db <- tools::CRAN_package_db()
cran_db <- cran_db[, c("Package", "SystemRequirements",
"Imports", "Depends", "Suggests")]
java <- dplyr::filter(cran_db,
stringr::str_detect(Imports, "rJava") |
stringr::str_detect(Imports, "rJava") |
stringr::str_detect(Depends, "rJava")|
stringr::str_detect(SystemRequirements, "[Jj]ava"))
@maelle
maelle / slides.Rmd
Created August 23, 2018 10:11
Mi codigo abieRto
---
title: "¡Mejo`r icon::fa('r-project')` ciencia con rOpenSci!"
subtitle: "Maëlle Salmon <br/> [`r icon::fa('twitter')`](https://twitter.com/ropensci) ropensci [`r icon::fa('github')`](https://github.com/ropensci) ropensci [`r icon::fa('globe')`](https://ropensci.org) ropensci.org"
date: "2018/09/05"
output:
xaringan::moon_reader:
css: ["default", "metropolis", "metropolis-fonts", "my-theme.css"]
lib_dir: libs
nature:
highlightStyle: github
@maelle
maelle / roblog_headers.R
Last active August 29, 2018 14:16
How to get headers by file
``` r
roblog <- "C:\\Users\\Maelle\\Documents\\ropensci\\roweb2\\content\\blog"
all_posts <- fs::dir_ls(roblog, regexp = "*.md")
all_posts <- all_posts[all_posts != "_index.md"]
library("magrittr")
# Headers
get_headers <- function(path){