<socialcoder>
why is passwords() repeated in line 8
havenn has quit [Ping timeout: 252 seconds]
<socialcoder>
nevermind...got it haha
drbrain has quit [Ping timeout: 252 seconds]
chendo_ has quit [Quit: Computer has gone to sleep.]
loladiro has quit [Ping timeout: 252 seconds]
<thufir_>
can I get the result of %x[firefox google.com] back? Instead of having firefox actually open the webpage, I want firefox to just send the results back. Rather than nokogiri.
<heftig>
you could use lynx -dump google.com
<thufir_>
heftig: thx
<thufir_>
watir looks interesting, too
akram has quit [Ping timeout: 252 seconds]
<thufir_>
but what is selenium? not really sure what selenium is. sounds familiar. also sounds radioactive...LOL
<thufir_>
I think it is an element, actually. or not. hmm.
Nisstyre-laptop has quit [Ping timeout: 244 seconds]
<thufir_>
help correcting syntax pls: value = %x [{#lynx -dump -display_charset=utf8 google.com}] I want to run that as a command
zork_ has joined #ruby-lang
shemerey has quit [Read error: Connection reset by peer]
<thufir_>
never mind. got it: value = %x(lynx -dump -display_charset=utf8 google.com)
Paradox has joined #ruby-lang
<thufir_>
where uri is a string, how do I use the variable correctly in: value = %x(lynx -dump -display_charset=utf8 uri) having syntax trouble.
mhi^ has joined #ruby-lang
Spaceghostc2c has quit [Excess Flood]
<badeball>
thufir_: is there are reason for using lynx or do you just want to post to an url and read something back?
Spaceghostc2c has joined #ruby-lang
<thufir_>
firefox or lynx would be ok. I'd like to use the actual browser. which browser is immaterial. at the moment, I'm more stuck on the syntax. I thought it it was {uri} but that doesn't seem to be correct.
chendo_ has joined #ruby-lang
<badeball>
thufir_: value = %x(lynx -dump -display_charset=utf8 #{url})
<badeball>
thufir_: but what are you trying to accomplish?
<thufir_>
badeball: lol. thanks. I wasn't that far off.
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
<thufir_>
well, not really thought out that far ahead. for now I just want to get back the raw html. down the road use nokogiri to parse the html. (nokogiri would be best?)
<badeball>
thufir_: in that case, use something else than lynx. invoking lynx from ruby is a terrible way to just fetch html over http! :P
<badeball>
i suggest Net. Net::HTTP.get('google.com', '/index.html')
<badeball>
that will return the html.
<thufir_>
heh, yeah. well, I was reading about browser sniffing on wikipedia and so I want to use a real, actual browser. firefox would be ideal.
<thufir_>
but, yeah, using Net like you suggest will probably get me there faster. I shouldn't get caught up in perfection at this stage.
<badeball>
using lynx or mozilla to avoid browser sniffing is NOT perfection.
<badeball>
you can specify headers when using Net and make it look exactly like firefox and *that* would be perfect.
<thufir_>
right, but what about running javascript against the browser and doing client side checking?
<thufir_>
the user agent will do the server side checks, but I think it's more complex than that.
krz has quit [Quit: krz]
gix has joined #ruby-lang
tbuehlmann has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
<badeball>
for that i would suggest using capybara with poltergeist. poltergeist is a driver for PhantomJS, which is a headless webkit.
<badeball>
with that, you can open a webpage in a headless webkit instance and execute arbritary javascript on the web page, all from ruby.
gix has quit [Client Quit]
gix has joined #ruby-lang
<thufir_>
oooh, very fancy :)
<badeball>
capybara and poltergeist is some pretty awesome pieces of stuff. i used it last summer to create an automated, cucumber based test suite for an extjs application. *
drbrain has joined #ruby-lang
krz has joined #ruby-lang
<thufir_>
in terms of OOP and mixins, let's say I have three primary scripts. one uses IMAP to read e-mails and grab a URI. The second receives the URI and gets back raw html. The third parses the html, and the fourth puts it into a database. Or, do those just sound like methods in one script?
krz has quit [Client Quit]
<thufir_>
mixins confuse me. I get the justification, work-around for multiple inheritance, but the mechanics of it escape me.
<socialcoder>
in case u took a look, does F havew any significance other than what u mentioned
nick_h has joined #ruby-lang
<socialcoder>
well, I looked closely. I guess itsjust a variable
<canton7>
no. it's a variable. See line 15, current_file is set to a new File instance. Then on line 20, it's passed as the first argument to print_all. So that file instance is the first argument to print_all. Program execution jumps to line 3, where f is the name given to the first argument: that file instance
JohnBat26 has joined #ruby-lang
nick_h has quit [Remote host closed the connection]
swav has quit [Ping timeout: 252 seconds]
nick_h has joined #ruby-lang
<socialcoder>
yes, I noticed that
<socialcoder>
thanks canton
<socialcoder>
ur question wheteher I have programmed before kinda acted a catalyst to think
<Ridders24>
telemachus: im pretty sure I have, but will test again. But i think the error i got last time, was cant convert string to integer
<canton7>
right that sounds more promising
<Ridders24>
give me a sec to just check that
breakingthings has joined #ruby-lang
<telemachus>
yeah, that suggests you got the item you wanted but put it somewhere ruby expected a number (though I can't see that right off in your paste)
<Ridders24>
going to repaste
<telemachus>
btw, anything coming to you from user input is interpreted as a string (even if the user enters 42), so you must use .to_i or .to_f to make it a number (integer or float)
<telemachus>
Ruby isn't Perl (or others): it won't auto-cast the item to a number if you try to add it or whatever
<canton7>
it's often safer to use Integer() instead of #to_i, as "x".to_i # => 0, while Integer("x") # => ArgumentError
scottschecter has quit [Quit: WeeChat 0.3.9.2]
<telemachus>
canton7: good point
<canton7>
(similarly, gets.chomp can fall over, as gets can return nil
<canton7>
but it comes down to how much you care
<Ridders24>
im not after an integer though, I actually do just want the string
<canton7>
let's see your error then :P
<Ridders24>
I can't seem to get it to error now, this is daft
<canton7>
it does irritate when people rate-limit apis. Not that I'm saying they shouldn't...
<telemachus>
Well, my best guess, based on that error is that you're trying to treat an array like a hash (indexing it by a string rather than an integer)
<Ridders24>
its odd, as I have the script working when you define the argument in commmand line, but I wanted to change that and specifiy it in the script with chomp
<canton7>
telemachus, yeah, that brings up that error
<telemachus>
Is it possible the script fails when you use it too many times in relatively rapid succession?
<telemachus>
That is, it works until you get rate limited - at which point the error value is an array, not a hash of the tweet
<telemachus>
so you see a failure
<Ridders24>
I'll have to wait an hour I guess before I can try again
drbrain has quit [Ping timeout: 244 seconds]
<Ridders24>
when i test the output for tweet when I provide the argv in the command line, tweet is all of the profile from the api
<Ridders24>
from what i remember
gaveen has quit [Remote host closed the connection]
<Ridders24>
what can I do to solve the issue?
jxie has joined #ruby-lang
<telemachus>
Without knowing the API better, it's hard to say. But a first thought is to check the response code of res before trying to work with it.
<telemachus>
Presumably if you weren't authorized, you don't have a 200 response, so you can branch off of that
<Ridders24>
don't think the api is the problem, as the only thing ive change is how I provide the input
JoelMcCracken has joined #ruby-lang
<telemachus>
Ridders24: sure. But either way, with a web response, it pays to check it's response code before trying to use it, no?
srbaker has joined #ruby-lang
<Ridders24>
telemachus: yeah thats fair enough
<telemachus>
And if the response is not 200, you can use p to try to see what the object you receive looks like. Then you can figure out how to treat it (or if to treat it at all).
<Ridders24>
when I was testing the script before I got the problem, I output res and req and was getting somthing like 0x1758, what is that?
sush24 has joined #ruby-lang
burgestrand has joined #ruby-lang
mercwithamouth has joined #ruby-lang
mistym has joined #ruby-lang
<telemachus>
looks like a hex value (maybe?) but impossible to say without knowing more
<Ridders24>
and I can make requests again by the way
drbrain has joined #ruby-lang
havenn has joined #ruby-lang
davidbalber|away is now known as davidbalbert
io_syl has quit [Quit: Computer has gone to sleep.]
havenn has quit [Ping timeout: 252 seconds]
methods has joined #ruby-lang
drbrain has quit [Ping timeout: 255 seconds]
swav has quit [Remote host closed the connection]
jonahR has quit [Quit: jonahR]
srbaker has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
krz has joined #ruby-lang
<Ridders24>
ok so ive tested the script, and the reason I get the error, is because the the var "us" is not being seen in the req line. But i dont know why?
<canton7>
is it being passed to backup() correctly? SO a 'p us' on line 16 works?
sush24 has quit [Quit: This computer has gone to sleep]
mercwithamouth has joined #ruby-lang
methods has left #ruby-lang [#ruby-lang]
krz has quit [Quit: krz]
krz has joined #ruby-lang
MaddinXx has joined #ruby-lang
zwevans has joined #ruby-lang
mercwithamouth has quit [Ping timeout: 245 seconds]
mercwithamouth has joined #ruby-lang
apeiros_ has quit [Remote host closed the connection]
mercwithamouth has quit [Client Quit]
mercwithamouth has joined #ruby-lang
<Ridders24>
canton7: so "def backup (p us) ?
<canton7>
Ridders24, no. so `def backup(us) \n p us \n`
<Ridders24>
canton7: im getting a syntax error for the \n
<canton7>
that means "newline"
<Ridders24>
ahh, learnt somthing new
<canton7>
puts "one\ntwo", see the \n being turned into a newline? same in most languages
<Ridders24>
canton7: still getting a not authorised error. when I look at the tweet output "/1/statuses/user_timeline.json?screen_name=&count=200&page=6" its still not including 'us' in the screen_name : http://pastebin.com/HUkskEQg
srbaker has quit [Quit: Computer has gone to sleep.]
<canton7>
Ridders24, I'm interested in what is printed to the console by the 'pp' line
<canton7>
Ridders24, and how are you calling the script?
<canton7>
ruby myscript.rb username ?
<canton7>
I just noticed line 46, which takes ARGV[0] and passes that in as the 'us' param to #backup
<Ridders24>
no i used to do that, but now im trying to do it by just calling ruby myscript.rb
<canton7>
so line 7 does bugger all
krz has quit [Quit: krz]
<canton7>
does that make sense?
<Ridders24>
oh hang on, I'll # line 46
<Ridders24>
yh that makes sence
blazes816 has joined #ruby-lang
<Ridders24>
when I # line 46 and run the script, I get no error, but no output either now
<canton7>
how are you calling it?
<canton7>
are you running 'ruby myfile.rb yourusername' ?
<Ridders24>
no just 'ruby myscript.rb' then it asks for the username, which is what the STDIN is for and I type the username
MaddinXx has quit [Remote host closed the connection]
<canton7>
but that gets assigned to the 'us' variable, and then you don't do anything with it!
Asher has joined #ruby-lang
<canton7>
instead, when you call #backup, you pass in ARGV[0], NOT us
<injekt>
banisterfiend: exactly like you just did :D
<banisterfiend>
injekt: hm let me try
<injekt>
banisterfiend: it's stored as 'description' on the option object
<injekt>
banisterfiend: [1] pry(main)> o = Slop.new { on :foo, 'something fooey'; }; o.fetch_option(:foo).description
<injekt>
=> "something fooey"
<llaskin>
sorry i've been fighting this annoying thing for probably 2 days
<banisterfiend>
injekt: are you talking about options or commands?
kyrylo has joined #ruby-lang
<banisterfiend>
injekt: I'm talking about stuff of the form "git log"
<banisterfiend>
where 'log' is a command
<injekt>
banisterfiend: oh
<injekt>
my bad
<banisterfiend>
injekt: i can document the options that commands take
<banisterfiend>
but i can't seem to document the commands themeslves
<injekt>
yeah I rarely use the command system and it already needs an overhaul, I just need to know how people want to use it
<banisterfiend>
and some commands don't take options at all, and i don't appear to have a way to document them at all
<banisterfiend>
ah ok
<injekt>
yeah that makes sense. each command is an instance of slop, though, so what if you open up cmd.banner ?
<injekt>
might be able to leverage on that
<banisterfiend>
injekt: yeah i could do that, but it's pretty slick to have slop auto-generate that from a doc string that i give the command, hopefully kyrylo is working on a patch for u
<banisterfiend>
kyrylo: right? :)
ebouchut has joined #ruby-lang
<kyrylo>
Not yet, but… Yes.
<injekt>
cool, any patches for commands are welcome, they need a lot of input from people who use them (you guys)