Skip to content

Instantly share code, notes, and snippets.

@petekeen-cf
Forked from peterkeen/eval_gist.rb
Last active February 1, 2023 21:45
Show Gist options
  • Select an option

  • Save petekeen-cf/6a68b116d37d5fa0855b3a19306a0ed1 to your computer and use it in GitHub Desktop.

Select an option

Save petekeen-cf/6a68b116d37d5fa0855b3a19306a0ed1 to your computer and use it in GitHub Desktop.

Revisions

  1. petekeen-cf revised this gist Dec 20, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@ def eval_gist(token, gist_id)
    req = Net::HTTP::Get.new(uri)
    Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    resp = http.request(req)
    pp JSON.parse(resp.body)
    # eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
    eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
    end
    end
  2. petekeen-cf revised this gist Dec 20, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    def eval_gist(token, gist_id)
    uri = URI("https://api.github.com/gists/#{gist_id}")
    req = Net::HTTP::Get.new(uri)
    Net::HTTP.start(uri.host, user.port, use_ssl: true) do |http|
    Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    resp = http.request(req)
    pp JSON.parse(resp.body)
    # eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
  3. petekeen-cf revised this gist Dec 20, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ def eval_gist(token, gist_id)
    req = Net::HTTP::Get.new(uri)
    Net::HTTP.start(uri.host, user.port, use_ssl: true) do |http|
    resp = http.request(req)
    eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
    pp JSON.parse(resp.body)
    # eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
    end
    end
  4. petekeen-cf revised this gist Dec 20, 2022. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,11 @@
    # Step 3: run `eval_gist("the-gist-id-from-the-url")`
    # Step 4: GOTO Step 3

    def eval_gist(gist_id)
    eval(JSON.parse(Net::HTTP.get(URI("https://api.github.com/gists/#{gist_id}"))).dig("files", "__script__.rb", "content"))
    def eval_gist(token, gist_id)
    uri = URI("https://api.github.com/gists/#{gist_id}")
    req = Net::HTTP::Get.new(uri)
    Net::HTTP.start(uri.host, user.port, use_ssl: true) do |http|
    resp = http.request(req)
    eval(JSON.parse(resp.body).dig("files", "__script__.rb", "content"))
    end
    end
  5. @peterkeen peterkeen revised this gist Mar 31, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@
    # Step 4: GOTO Step 3

    def eval_gist(gist_id)
    eval(JSON.parse(Net::HTTP.get("https://api.github.com/gists/#{gist_id}")).dig("files", "__script__.rb", "content"))
    eval(JSON.parse(Net::HTTP.get(URI("https://api.github.com/gists/#{gist_id}"))).dig("files", "__script__.rb", "content"))
    end
  6. @peterkeen peterkeen revised this gist Mar 31, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Step 1: write a gist with a file named __script__.rb
    # Step 2: copy and paste the function def below into a shell
    # Step 2: copy and paste the function def below into Rails console
    # Step 3: run `eval_gist("the-gist-id-from-the-url")`
    # Step 4: GOTO Step 3

  7. @peterkeen peterkeen created this gist Mar 31, 2022.
    8 changes: 8 additions & 0 deletions eval_gist.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Step 1: write a gist with a file named __script__.rb
    # Step 2: copy and paste the function def below into a shell
    # Step 3: run `eval_gist("the-gist-id-from-the-url")`
    # Step 4: GOTO Step 3

    def eval_gist(gist_id)
    eval(JSON.parse(Net::HTTP.get("https://api.github.com/gists/#{gist_id}")).dig("files", "__script__.rb", "content"))
    end