Skip to content

Instantly share code, notes, and snippets.

@nwalberts
Last active December 6, 2023 00:03
Show Gist options
  • Save nwalberts/41d0c87e3172c3960c07d840af67bdca to your computer and use it in GitHub Desktop.
Save nwalberts/41d0c87e3172c3960c07d840af67bdca to your computer and use it in GitHub Desktop.

Giphy Practice OOP Challenge

This request goes to the Giphy trending api endpoint. https://api.giphy.com/v1/gifs/trending?api_key=YJX6Vs4kayAeOM4etN7P5ueL4ie4wU5D https://developers.giphy.com/docs/api/endpoint#endpoint

Using got or an HTTP client of your choice, write a program that can be run from your terminal to evaluate trends in the latest popular gifs.

Define a function or series of functions to evaluate the titles of gifs, to find the most common keyword in the title. Exclude articles (grammar) such as [the, and, an, a, my, by]

  • We need analysis on gif sizes, particularly as it pertains to the widths of images, which lead to the biggest headaches. Define a function or series of functions that gives a summary of patterns we see in gif widths.
    • For all images that a given gif can have available, determine the most common width .
    • For all images that a given gif can have available, determine the average width
    • We need to generate recommendations for how many gifs can be displayed on the average screen size. If the average computer screen is 1024×768px, determine how many gifs can be displayed side by side if all gifs are the average width. Assume that we will have a margin of 10px between each gif displayed.
    • write a second implementation that only takes into account the average width of the original gif (rather than downsized , fixed_preview etc)

We need to better determine how which gifs to display based on internet connection. For this part, focus only on the original gif properties

  • Low speed internet shall be said to be 60mbs download speed. Medium speed is 135mbs. High speed is 200mbs.
  • Define a function or series of functions that can take the internet speed, and determine which gifs should be displayed based on the original gif's number of frames. You do not need to take into
    • when the internet speed if low, return only gifs that have fewer than 50 frames.
    • when the internet speed is medium, return only gifs that have 125 frames or fewer.
    • When the internet is high, return gifs up to 200 frames or fewer. Exclude gifs with more frames than 200 regardless of internet speed.
  • output the number of gifs displayed based on each internet speed. Then, based on the average width of gifs from problem #2c, determine how many rows of gifs we will need to generate to display all of the gifs. No need to consider the height of gifs

Bonus: experiment with using Array.from() , the ternary operator or the optional chaining operator. Though occasions to use these may not arise, so take that into account

Acceptance Criteria

  • Please use Postman to issue test requests to the Giphy endpoint. Fluency in this program will stand out, even if you only know it at a cursory level
  • Its important to abstract as much of this as possible by making numerous functions for each segment of the implementation. Don't worry about making classes until you are sure it would serve the implementation.
  • All output must be displayed in the terminal.

Bonus

We believe this assignment is best accomplished by NOT adding it to a backend web server like Express (or in adding React for that matter). However, if you have an upcoming evaluation that is data structure/OOP AND internal web api centric, you might decide to add this to an Express React app.

Bonus #1

Make an GET "/gifs?internet-speed=low/medium/high" API endpoint in Express (or a framework of your choice) that when visited, returns a JSON response containing the output from the last step of the above assignment

  • The api endpoint should return the number of gifs to be displayed based on internet speed
  • it should contain the average gif width
  • it should contain the number of rows that will be needed for the display
  • it should contain a list of the gifs objects containing the gif url and the gif title output the number of gifs displayed based on each internet speed. Then, based on the average width of gifs from problem #2c, determine how many rows of gifs we will need to generate to display all of the gifs. No need to consider the height of gifs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment