Created
April 21, 2017 15:27
-
-
Save mkearney/e1bc65b89cb0c19df17cdba6f6a6a729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jlfacts <- function(dir = path.expand("~")) { | |
if (file.exists(file.path(dir, ".jeffleekfacts.rds"))) { | |
jlrtfacts <- readRDS(file.path(dir, ".jeffleekfacts.rds")) | |
} else if ("rtweet" %in% install.packages()) { | |
jlrt <- rtweet::search_tweets("\"jeff leek\"", n = 500, include_rts = FALSE) | |
jlrtfacts <- trimws(unique(gsub("@[[:alnum:]_:]+", "", jlrt$text))) | |
jlrtfacts <- grep("http", jlrtfacts, invert = TRUE, value = TRUE) | |
saveRDS(jlrtfacts, path.expand(file.path("~", ".jeffleekfacts.rds"))) | |
} else { | |
jlrtfacts <- "jeff leek doesn't use soap; he uses rm(list = ls())." | |
} | |
jlf <- sample(jlrtfacts, 1) | |
message(jlf) | |
} | |
jl <- function(total) { | |
..ctr.. <- 0 | |
function(expr, value, ok, visible) { | |
..ctr.. <<- ..ctr.. + 1 | |
active <- (..ctr.. < total) | |
if (!active) { | |
message("that's enough about jeff leek") | |
} else { | |
jlfacts() | |
} | |
active | |
} | |
} | |
addTaskCallback(jl(100), name = "jlfacts") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment