Bob Rudis (@hrbrmstr) is a famed expert, author and developer in Data Security and the Chief Security Data Scientist at Rapid7. Bob also creates the most deliciously vivid images of his meals documented by the #nom hashtag. I’m going to use a similar method used in my previous projects (Hipster Veggies & Machine Learning Flashcards) to wrangle all those images into a nice collection - mostly for me to look at for inspiration in recipe planning.

Source Repository: jasdumas/bobs-noms


library(rtweet) # devtools::install_github("mkearney/rtweet")
# get all of bob's recent tweets
bobs_tweets <- get_timeline(user = "hrbrmstr", n = 3200)

#filter noms with images only
bobs_noms <- 
  bobs_tweets %>% dplyr::filter(str_detect(hashtags, "nom"), !
bobs_noms$clean_text <- bobs_noms$text
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text,"#[a-zA-Z0-9]{1,}", "") # remove the hashtag
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text, " ?(f|ht)(tp)(s?)(://)(.*)[.|/](.*)", "") # remove the url link
bobs_noms$clean_text <- str_replace(bobs_noms$clean_text, "[[:punct:]]", "") # remove punctuation
# let's look at these images in a smaller data set
bobs_noms_small <- bobs_noms %>% select(created_at, clean_text, media_url)

bobs_noms_small$img_md <- paste0("![", bobs_noms_small$clean_text, "](", bobs_noms_small$media_url, ")")
data.frame(images = bobs_noms_small$img_md) %>% 
kable( format = "markdown") %>%
  kable_styling(full_width = F, position = 'center') 

|images | |:———————————————————————————————————————————————————-| |Moroccaninspired lamb meatballs prepped. Naan dough is kneading. Going to be a  sup tonight. | |Tsukune with tare tonight | |Lamb roast isnt too shabby either | |The pain de mie thankfully came out well | |Sage rosemary & espresso infused salt rubbed roast lamb. Goose fat roasted potatoes _almost _ done | | | |Ham amp; turkey frittata time! | |Postconfit | |PostPBC | | | | is home
#2's Wedding Sunday.
20 ppl over tonight for 🦃
#nom | |Definitely an Indonesian spring rolls kind of night | |Homemade breadsticks for the homemade pasta and meatballs tonight | | | |Bonein PBC smoked pork roast | |Prosciutto de Parma Cacio di Bosco & spinach omelettes this morning | |Our Friday night is shaping up well How’s yours going? | |Pork tenderloin on the PBC tonight | |Overnight nutmeg-infused yeast waffles with sautéd local picked Maine apples & Maine maple syrup |

# create a function to save these images!
save_image <- function(df){
  for (i in c(1:nrow(df))){
    image <- try(image_read(df$media_url[[i]]), silent = F)
  if(class(image)[1] != "try-error"){
    image %>%
      image_scale("1200x700") %>%
      image_write(paste0("../post_data/data/", bobs_noms$clean_text[i],".jpg"))
   cat("saved images...\n")

## saved images...