Giter VIP home page Giter VIP logo

bobs-noms's Introduction

Extracting data from Twitter for @hrbrmstr's #nom foodie images

Rendered on: 2018-01-16

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.

Yum! Have you ever thought about collecting all these recipes & images into a cookbook?!

— Jasmine Dumas (@jasdumas) January 15, 2018
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Source Repository: jasdumas/bobs-noms

Analysis

library(rtweet) # devtools::install_github("mkearney/rtweet")
library(tidyverse)
library(dplyr)
library(stringr)
library(magick)
library(knitr)
library(kableExtra)

# 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"), !is.na(media_url))

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, ")")

bobs_noms_small$img_md %>% 
kable( format = "html") %>%
  kable_styling(bootstrap_options = "striped", 
                full_width = F) 
![Moroccaninspired lamb meatballs prepped. Naan dough is kneading. Going to be a sup tonight.](http://pbs.twimg.com/media/DTmdeptVoAAZYpp.jpg)
![Tsukune with tare tonight](http://pbs.twimg.com/media/DTTF55oX0AMyyVL.jpg)
![Lamb roast isnt too shabby either](http://pbs.twimg.com/media/DS4_fRFU0AA3LVL.jpg)
![The pain de mie thankfully came out well](http://pbs.twimg.com/media/DS48BemVAAAN38J.jpg)
![Sage rosemary & espresso infused salt rubbed roast lamb. Goose fat roasted potatoes *almost * done](http://pbs.twimg.com/media/DR7j-HMV4AAzXpH.jpg)
![](http://pbs.twimg.com/media/DQDDt9qXcAAg_Hb.jpg)
![Ham amp; turkey frittata time!](http://pbs.twimg.com/media/DPfXiVBXkAAkKAK.jpg)
![Postconfit](http://pbs.twimg.com/media/DO34I4oXkAEvmDS.jpg)
![PostPBC](http://pbs.twimg.com/media/DO32TmIX0AAmkT7.jpg)
![](http://pbs.twimg.com/media/DO2xnqcXcAAGBZO.jpg)
![is home \#2's Wedding Sunday. 20 ppl over tonight for 🦃 \#joy \#nom](http://pbs.twimg.com/media/DO2D1HQVwAEZQzk.jpg)
![Definitely an Indonesian spring rolls kind of night](http://pbs.twimg.com/media/DNVuMHWWkAI4biV.jpg)
![Homemade breadsticks for the homemade pasta and meatballs tonight](http://pbs.twimg.com/media/DNBMw2NWAAEwGft.jpg)
![](http://pbs.twimg.com/media/DM8GWXYXcAEAFkJ.jpg)
![Bonein PBC smoked pork roast](http://pbs.twimg.com/media/DMniz1TX0AAboZw.jpg)
![Prosciutto de Parma Cacio di Bosco & spinach omelettes this morning](http://pbs.twimg.com/media/DMlFfC0X0AAPuVf.jpg)
![Our Friday night is shaping up well How’s yours going?](http://pbs.twimg.com/media/DMDWHUdX4AEJF5r.jpg)
![Pork tenderloin on the PBC tonight](http://pbs.twimg.com/media/DLz-HotX4AEVVY1.jpg)
![Overnight nutmeg-infused yeast waffles with sautéd local picked Maine apples & Maine maple syrup](http://pbs.twimg.com/media/DK-fDgRWkAAGuhe.jpg)
# 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("data/", bobs_noms$clean_text[i],".jpg")) }
  }
   cat("saved images...\n")
}

save_image(bobs_noms)

## saved images...

Contact Me

Jasmine Dumas | [@jasdumas](https://twitter.com/jasdumas) | jasdumas.github.io

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.