Coder Social home page Coder Social logo

All I get is "nil". about gist HOT 14 CLOSED

defunkt avatar defunkt commented on June 21, 2024
All I get is "nil".

from gist.

Comments (14)

indirect avatar indirect commented on June 21, 2024

Maybe try the gem version of gist, via gem install gist? At least then you can try loading up the gist library in IRB and use it to see what's going on.

from gist.

 avatar commented on June 21, 2024

Not sure how to do it. But the gem version outputted "nil" as well.

Oh well, copy & paste works as well ;)

from gist.

indirect avatar indirect commented on June 21, 2024

I'm sorry you're having trouble -- I don't really have any ideas. It works just fine for me both standalone and as a gem.

from gist.

 avatar commented on June 21, 2024

I would really love to know how I can debug this. Not fluent with Ruby at all. And I'm not sure how to utilize the gem.

from gist.

indirect avatar indirect commented on June 21, 2024

okay, here's how to manually use the gem:

$ gem install gist
Successfully installed gist-2.0.2
1 gem installed

$ irb
>> require 'gist'
=> true
>> Gist.write [:input => "testing"], true
=> "https://gist.github.com/e6586a128773f71e47e8"

from gist.

 avatar commented on June 21, 2024

Thank you so much!

But, yet nil is still displayed. No error message at all.

Oh well, I don't want to take more of your time :) Thank for the help. Much appreciated ;)

from gist.

indirect avatar indirect commented on June 21, 2024

Very strange. That means that, somehow, the HTTP request to gist.github.com is completing without an error, but the response is not including a "Location" header. I take it the gist that you are trying to create is not actually showing up at gist.github.com?

from gist.

indirect avatar indirect commented on June 21, 2024

Okay, this is really bugging me. So here is an example of manually putting through a request to the gist server, using the gist gem to set up the data for the request. When you do this, if you copy and paste the response to return to me, please X out the "token" value, and the "_gh_sess" value (like I did below) so that they can't be used to steal your github account.

$ irb

>> require 'gist'
=> true
>> irb Gist
>>     url = URI.parse(CREATE_URL)
=> #<URI::HTTPS:0x103293840 URL:https://gist.github.com/gists>
>>     if PROXY_HOST
>>         proxy = Net::HTTP::Proxy(PROXY_HOST, PROXY_PORT)
>>         http  = proxy.new(url.host, url.port)
>>       else
?>           http = Net::HTTP.new(url.host, url.port)
>>       end
=> #<Net::HTTP gist.github.com:443 open=false>
>>     http.use_ssl = true
=> true
>>     http.verify_mode = OpenSSL::SSL::VERIFY_PEER
=> 1
>>     http.cert = OpenSSL::X509::Certificate.new(ca_cert)
=> #<OpenSSL::X509::Certificate subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority, issuer=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority, serial=3558802160848854062232407011527417280, not_before=Wed Nov 09 00:00:00 UTC 1994, not_after=Thu Jan 07 23:59:59 UTC 2010>
>>     req = Net::HTTP::Post.new(url.path)
=> #<Net::HTTP::Post POST>
>> req.form_data = data([:input => "testing"], true)
=> {"file_contents[gistfile1]"=>"testing", "file_ext[gistfile1]"=>".txt", "file_name[gistfile1]"=>nil, :token=>"xxxx", "action_button"=>"private", :login=>"indirect"}
>> response = http.start{|h| h.request(req) }
=> #<Net::HTTPFound 302 Found readbody=true>
>> response["Location"]
=> "https://gist.github.com/5a821a0efed442100453"
>> response.each_header{}
=> {"strict-transport-security"=>["max-age=2592000"], "location"=>["https://gist.github.com/5a821a0efed442100453"], "connection"=>["keep-alive"], "content-type"=>["text/html; charset=utf-8"], "x-runtime"=>["312ms"], "date"=>["Tue, 12 Apr 2011 17:43:53 GMT"], "server"=>["nginx/0.7.67"], "content-length"=>["110"], "set-cookie"=>["_gh_sess=xxxx; path=/; expires=Fri, 01 Jan 2021 00:00:00 GMT; secure; HttpOnly"], "cache-control"=>["no-cache"], "status"=>["302 Found"]}

from gist.

 avatar commented on June 21, 2024

Using the latest commit, I where able to track down the problem to be my token were wrong :) Since I had changed my password a while back.

Thank you :)

However, when I gisted my .vimrc file it, I had the strange error Creating gist failed: 302 "Found", yet the Gist were created.

from gist.

indirect avatar indirect commented on June 21, 2024

Ah! Good catch... 302 found actually means the gist worked! Sounds like the patch I pulled doesn't handle that case correctly. :) Thanks!

from gist.

indirect avatar indirect commented on June 21, 2024

Fixed in 284dd9b.

from gist.

 avatar commented on June 21, 2024

How come I don't see the commit, nor can pull it?

from gist.

indirect avatar indirect commented on June 21, 2024

Because I'm silly, and pushed to my fork but not the main repo :) Fixed now!

from gist.

 avatar commented on June 21, 2024

Thank you :)

from gist.

Related Issues (20)

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.