Evernote API Binary Error - Ruby on Rails - OAuth - ruby-on-rails

I am trying to take the Evernote Ruby example https://github.com/evernote/evernote-sdk-ruby which uses Sinatra and integrate it into Rails.
I have everything working fine until pulling a list of notebooks in the callback.
notebooks = noteStore.listNotebooks(access_token.token)
result = Array.new
notebooks.each do |notebook|
result << notebook.name
end
#notebooks = result
It's getting this error: (which isn't helpful at all)
RuntimeError in CallbacksController#callback
--- !binary |-
U1NMX2Nvbm5lY3QgcmV0dXJuZWQ9MSBlcnJubz0wIHN0YXRlPVNTTHYzIHJl
YWQgc2VydmVyIGNlcnRpZmljYXRlIEI6IGNlcnRpZmljYXRlIHZlcmlmeSBm
YWlsZWQ=
The Sinatra app works correctly. So my guess is that some file is not being loaded to parse this. But I have tried everything.
I will post the full controller here: http://paste.codebasehq.com/pastes/7frtcdhyncwb0emznj
Thanks for the help.

I guess to_yml makes your error message unreadable like:
--- !binary |-
U1NMX2Nvbm5lY3QgcmV0dXJuZWQ9MSBlcnJubz0wIHN0YXRlPVNTTHYzIHJl
YWQgc2VydmVyIGNlcnRpZmljYXRlIEI6IGNlcnRpZmljYXRlIHZlcmlmeSBm
YWlsZWQ=
Can you replace to_yml with inspect?
It seems simply your message is outputted as binary and you could figure out the cause of error from messages if it is outputted as text.
Related post:
Thor & YAML outputting as binary?

Related

RubyGem 'steam-condenser' - .fetch method only time and fetch_games undefined method `[]'

I am trying to get some basic information from the Steam Community via the steam-condenser gem and so far the Steam.new seems to work just fine with all the players information.
however when I do this (example)
player = SteamId.new("tiger")
stats = player.fetch_games
I get the following error message
Traceback (most recent call last):
1: from lib/assets/ruby/test.rb:15:in `<main>'
/home/zigs/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/steam-condenser-1.3.11/lib/steam/community/steam_id.rb:326:in `fetch_games': undefined method `[]' for nil:NilClass (NoMethodError)
A lot of the information I need seems to be connected to the fetch_games (for example the method total_playtime(id))
Not sure why this is not working. I am lost. Any help or ideas are highly appreciated! Thank you!
TLDR; it looks like this gem no longer works.
the particular module that you're having trouble with is:
def fetch_games
games_data = parse "#{base_url}/games?xml=1"
#games = {}
#recent_playtimes = {}
#total_playtimes = {}
games_data['games']['game'].each do |game_data|
app_id = game_data['appID'].to_i
#games[app_id] = SteamGame.new app_id, game_data
recent = game_data['hoursLast2Weeks'].to_f
total = (game_data['hoursOnRecord'] || '').delete(',').to_f
#recent_playtimes[app_id] = (recent * 60).to_i
#total_playtimes[app_id] = (total * 60).to_i
end
true
end
with the particular problem statement being games_data['games']['game'].each
If we were looking to get information for a particular user, it downloads an XML document about the user from a URL looking like:
http://steamcommunity.com/id/demomenz?xml=1
and this file does not seem to contain any games objects in it.
Having looked at the codebase for the steam-condenser gem; it hasn't really been updated in about 6 years. I can only assume that the XML format has been modified since this time and that the gem will no longer work.
Valve has added more privacy options to Steam Community profiles which are not reflected in the old XML APIs.
Apparently, the profile in question (tiger) has it‘s game details set to “Friends Only” or ”Private” as games are also unavailable in the browser.
The code from the released 1.x versions is no longer guaranteed to work when it comes to Steam Community. Valve deprecated the old XML APIs several years ago. Sadly, the modern Web API hasn‘t gotten much attention from Valve‘s side either. So development of Steam Condenser has mostly come to halt, too.
You might have more luck using the code from the master branch of the GitHub repository which uses Web API for most of the Community features.
You will have to register for a Steam Web API key, though: https://steamcommunity.com/dev/apikey

How to run a Regex expression in an uploaded log file using Ruby on Rails?

I'm building a web-based log parser system using Ruby on Rails. I already finished the function for uploading log files and I also already have the Regex Expression for capturing the information that I need from each log file entry. As you know, a log file may contain thousands of log file entries and they usually follow the same pattern.
For instance:
Processing NameofController#index (for 999.999.999.999 at 2019-01-24 00:12:00) [GET]
Session ID: aaaaaabbbbbbcccccc11112222333
Parameters: {"controller"=>"sample_invoices", "action"=>"index",
"before"=>"2019-01-24T12:00:00Z", "soap_id"=>"0001",
"s"=>"sample", "format"=>"xml"}
Sample chain halted as [:example] rendered_or_redirected.
Completed in 0.00022 (4588 reqs/sec) | Rendering: 0.00010 (44%) | DB: 0.00000 (0%) | 401 Unauthorized [http://www.iwantsoaps.com/pages/sample.xml?s=sample&soap_id=0001&before=2019-01-24T12:00:00Z]
Can someone recommend a way for me to read each log file using regex after they have been uploaded? I simply don't know where to start. I need to store the captured values inside a database as well.

Elasticsearch 6.2.4 [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"}]

I am using Elasticsearch 6.2.4 with my RoR application using elasticsearch-rails and elasticsearch-model.
My indexation is runninng without getting any errors. but when I try to perform a search from the application I am getting this error from Elasticsearch
<Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"}],"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"},"status":400}>
Everything was working normal prior to the upgrade of Elasticsearch from 1.5 to 6.2.4
I simplified my search query to try narrowing down the problem.
q = { "query" => { "match_all" => {} } }
But I still getting the same error. Probably I am not specifying a type in the query but wouldn't be unnecessary since I have a match_all condition ?
> {"query":{"match_all":{}}}
< {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"}],"type":"illegal_argument_exception","reason":"text is empty (possibly HTTP/0.9)"},"status":400}
I am brand new to Elasticsearch so excuse me in advance if there are some evident stuff that I am missing
Do you have any idea what is causing this error ? If you need more specific info just ask and I'll update this question.
Thanks.
Search request from application is resulting in HTTP 400 Bad Request. Are you able to perform a search request from outside the application i.e. invoking a curl command from your local etc ?

HOW TO: View Redis Data inside Rails application (using Soulmate)

I am new with ruby on rails.
Currently I am using Redis/Soulmate for an autocomplete feature. I am starting up a new loader and putting in my appointments model like so:
loader = Soulmate::Loader.new("appointments")
puts loader.inspect
I get the output:
#<Soulmate::Loader:0x007fdca25bd840 #type="appointments">
But if i begin adding to the loader like so:
loader.add("term"=>"randomappointment", "id"=>1)
HOW do i view the output of this command inside my rails application - I want to see the data that I have just input inside the loader (the soulmate hash). I am trying something like this, but nothing is working:
puts soulmate-data:appointments 1 or
puts soulmate-data["appointments"]
NOTE: I can do this in my terminal using
$ redis-cli
hget soulmate-data:appointments 1
which gives the output:
"{\"term\":\"randomappointment\",\"id\":1}"
Any Ideas? Im using Redis 2.8.19, Rails 4.1.6
I figured it out, i did this using the Soulmate::Matcher class like so:
term = "randomappointment"
result = Soulmate::Matcher.new("appointments").matches_for_term(term)

OpenURI::HTTPError (420 unused):

I have a Rails 3 application. One of the controller method is for parsing large number of Twitter search results and storing them to the database. All works fine if the number of URLs to parse is small. But once the URLs reach 1000 or more, I have the following error after a few seconds (copied from the log file):
Address: http://search.twitter.com/search?q=+Chas%20Salon+near:%22Baltimore%22+within:15mi
Completed in 111436ms
OpenURI::HTTPError (420 unused):
app/controllers/twitter_reviews_controller.rb:41:in block in new'
app/controllers/twitter_reviews_controller.rb:20:ineach'
app/controllers/twitter_reviews_controller.rb:20:in `new'
I am using Hpricot to parse the Twitter search results.
The line number 41 in the above message is this:
doc = Hpricot(open(address))
Does anyone knows where is the problem?
Thank you very much for any help.
Cheers,
Tony.
You are being rate limited by Twitter server. read more here: http://dev.twitter.com/pages/rate-limiting
Manage your code so it should not exceed the rate limit in an hour. and look at this response code return by http://apiwiki.twitter.com/w/page/22554652/HTTP-Response-Codes-and-Errors

Resources