Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h

gr33n7007h/foo Secret

Created October 25, 2018 20:35
Show Gist options
  • Save gr33n7007h/84f84ad7dbb289cb4ee4cff627abf07a to your computer and use it in GitHub Desktop.
Save gr33n7007h/84f84ad7dbb289cb4ee4cff627abf07a to your computer and use it in GitHub Desktop.
carc.in
>> require 'typhoeus'
=> true
>> require 'json'
=> true
>>
>> url = 'https://carc.in/run_requests'
=> "https://carc.in/run_requests"
>> code = "p [1,2,3]"
=> "p [1,2,3]"
>> payload = {run_request: {language: 'ruby', version: "2.4.1", code: code}}
=> {:run_request=>{:language=>"ruby", :version=>"2.4.1", :code=>"p [1,2,3]"}}
>> headers = {'Content-Type': 'application/json; charset=utf-8'}
=> {:"Content-Type"=>"application/json; charset=utf-8"}
>> JSOPN.parse Typhoeus.post(url, body: payload.to_json, headers: headers).response_body
NameError: (┛ಸ_ಸ)┛ ┻━┻) --> uninitialized constant JSOPN
from (pry):7:in `__pry__'
>> JSON.parse Typhoeus.post(url, body: payload.to_json, headers: headers).response_body
=> {"run_request"=>
{"run"=>
{"id"=>"5c8n",
"language"=>"ruby",
"version"=>"2.4.1",
"code"=>"p [1,2,3]",
"stdout"=>"[1, 2, 3]\n",
"stderr"=>"",
"exit_code"=>0,
"created_at"=>"2018-10-25T20:33:57Z",
"url"=>"https://carc.in/runs/5c8n",
"html_url"=>"https://carc.in/#/r/5c8n",
"download_url"=>"https://carc.in/runs/5c8n.cr"}}}
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment