Skip to content

Instantly share code, notes, and snippets.

@hugosenari
Last active August 18, 2021 05:25
Show Gist options
  • Save hugosenari/f0e7495872dc9c2f00f5acfa26eb6dd0 to your computer and use it in GitHub Desktop.
Save hugosenari/f0e7495872dc9c2f00f5acfa26eb6dd0 to your computer and use it in GitHub Desktop.
random gif from giphy
{ token, rating ? "pg-13", tag ? "so-excited", timestamp ? "n" }:
let
random_gif_response = builtins.fetchurl {
url = "https://api.giphy.com/v1/gifs/random?api_key=${token}&tag=${tag}&rating=${rating}&t=${timestamp}";
name = "random_gif_json";
};
random_gif_json = builtins.readFile random_gif_response;
in builtins.fromJSON random_gif_json
@hugosenari
Copy link
Author

hugosenari commented Aug 14, 2021

Usage:

let
  randomGif = import (builtins.fetchGit {
    url = https://gist.github.com/f0e7495872dc9c2f00f5acfa26eb6dd0.git;
    ref = "master";
  });
  result = randomGif { token = "AAAAAAAAAAAAA"; timestamp = "1628911280"; };
in result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment