<cloud69>
I'm trying to pick a random string from an array but get: `NoMethodError: undefined method 'strip' for #<Array:0x000000afec634808>`: https://pastebin.com/Ds3xXX5Y anybody know?
<leftylink>
there's a big difference between .sample and .sample(1). try them out and see
stryek has quit [Quit: Connection closed for inactivity]
<havenwood>
cloud69: With the current level of human-like behavior they'll likely see through your ruse, for what it's worth. Is this really a purely academic exercise?
<havenwood>
This bot seems like a bot.
<cloud69>
Purely yeah!
<cloud69>
Hehe I figured it'd set off some alarm bells ;)
<havenwood>
cloud69: You've already required pry, so just jump in to a `binding.pry` on the line before the #sample and try it in the REPL.
ur5us_ has joined #ruby
<cloud69>
Hey at least I'm not asking how to simulate clicks mouse movements right? :)
<havenwood>
cloud69: The REPL is a lovely way to quickly sanity check values and try hunches.
<cloud69>
havenwood: Great, I'm on it thanks!
tcrypt has quit [Quit: _ノ乙(、ン、)_]
Azure|dc has quit [Read error: Connection reset by peer]
<cloud69>
ruby is so pretty i often find myself just staring at its beauty for hours and hours on end :D
<havenwood>
cloud69: Look at the arguments to your method and study which part the error says is wrong.
<havenwood>
cloud69: What class do you expect to be stripping?
<havenwood>
cloud69: And what class is it?
<cloud69>
i'm not sure i'm stripping anything, i just wanted to pass a random browser string to `html = open(startpage, "User-Agent" => random_browser)`
<havenwood>
cloud69: What class is `random_browser`?
<havenwood>
cloud69: Doesn't it seem wrong?
<havenwood>
cloud69: Look at what's expected versus what you're passing.
<havenwood>
cloud69: What is the expected class of the value corresponding to the "User-Agent" string?
moldorcoder7 has quit [Quit: %bye mirc%]
<havenwood>
cloud69: leftylink pointed to the cause of your problem. Did you try the difference in `pry`?
moldorcoder7 has joined #ruby
<havenwood>
cloud69: From the command line, just type `pry` and try sampling with `1` as the argument versus no argument.
<cloud69>
that i tried but both returned the useragent string. but i see you just ran some stuff to show one is an array and the other an integer
<cloud69>
2 sec
lucasb has quit [Quit: Connection closed for inactivity]
<cloud69>
there we go, thanks guys :D
ur5us_ has quit [Ping timeout: 260 seconds]
impermanence has quit [Quit: Connection closed]
TCZ is now known as Tunuka
bamdad_ has joined #ruby
bamdad has quit [Ping timeout: 240 seconds]
bamdad_ has quit [Remote host closed the connection]
kristian_on_linu has quit [Remote host closed the connection]
<leftylink>
hmm. you know why I don't like alias? its args are the opposite of ln -s
ur5us_ has joined #ruby
<leftylink>
you know how to resolve this problem... just allow alias to accept its args in either order
<leftylink>
chaos
Tunuka has quit [Quit: Things Take Time]
chouhoulis has quit [Remote host closed the connection]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us_ has quit [Ping timeout: 260 seconds]
Rudd0 has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
bmurt has joined #ruby
bmurt has quit [Client Quit]
jmcgnh has quit [Ping timeout: 246 seconds]
cd has quit [Quit: cd]
adu has joined #ruby
jmcgnh has joined #ruby
SeepingN_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
queip has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
m27frogy has quit [Ping timeout: 260 seconds]
howdoi has joined #ruby
adu has quit [Quit: adu]
bocaneri has joined #ruby
akem_ has quit [Ping timeout: 258 seconds]
Emmanuel_Chanel has quit [Quit: Leaving]
bocaneri has quit [Max SendQ exceeded]
bocaneri has joined #ruby
bocaneri has quit [Max SendQ exceeded]
bocaneri has joined #ruby
Emmanuel_Chanel has joined #ruby
Emmanuel_Chanel has quit [Client Quit]
_whitelogger has joined #ruby
Emmanuel_Chanel has joined #ruby
nakilon has quit [Quit: Ping timeout (120 seconds)]
nakilon has joined #ruby
BenDover has joined #ruby
cthulchu_ has quit [Ping timeout: 258 seconds]
akem has joined #ruby
vondruch has joined #ruby
burgestrand has joined #ruby
m27frogy has joined #ruby
pabs has quit [Ping timeout: 265 seconds]
postmodern has joined #ruby
pabs has joined #ruby
ua has quit [Ping timeout: 256 seconds]
TomyWork has joined #ruby
Glumetu has joined #ruby
Hol_La has joined #ruby
ua has joined #ruby
Glumetu has quit [Ping timeout: 260 seconds]
Hol_La is now known as Glumetu
Hol_La has joined #ruby
Glumetu has quit [Ping timeout: 256 seconds]
Hol_La is now known as Glumetu
hiroaki has quit [Ping timeout: 260 seconds]
priodev has quit [Ping timeout: 268 seconds]
priodev has joined #ruby
braincrash has joined #ruby
fippy has quit [Quit: Leaving]
dionysus69 has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
duderonomy has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
johnny56 has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
dfucci has joined #ruby
dfucci has quit [Client Quit]
dfucci has joined #ruby
dionysus69 has quit [Remote host closed the connection]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
akem has quit [Ping timeout: 260 seconds]
mtsd has joined #ruby
BenDover has quit [Quit: BenDover]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
impermanence has joined #ruby
cloud69 has quit [Quit: Connection closed for inactivity]
BenDover has joined #ruby
mtsd has quit [Quit: Leaving]
howdoi has quit [Quit: Connection closed for inactivity]
Jonopoly has joined #ruby
pinkpandabot has joined #ruby
burgestrand has quit [Quit: burgestrand]
Glumetu has quit [Ping timeout: 260 seconds]
Glumetu has joined #ruby
pinkpandabot has quit [Quit: use it or lose it principle]
baojg has quit [Remote host closed the connection]
cloud69 has joined #ruby
baojg has joined #ruby
TCZ has joined #ruby
Jonopoly has quit [Quit: WeeChat 2.9]
braincrash has quit [Ping timeout: 246 seconds]
mcr has quit [Ping timeout: 260 seconds]
mcr has joined #ruby
mkaito- has left #ruby ["WeeChat 2.9-dev"]
al2o3-cr has quit [Quit: WeeChat 2.9]
burgestrand has joined #ruby
malikith has joined #ruby
foxxx0 has quit [Quit: foxxx0]
pinkpandabot has joined #ruby
foxxx0 has joined #ruby
ujjain has joined #ruby
ujjain has quit [Changing host]
ujjain has joined #ruby
al2o3-cr has joined #ruby
burgestrand has quit [Quit: burgestrand]
vondruch has quit [Ping timeout: 240 seconds]
chouhoulis has joined #ruby
bmurt has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
<adam12>
lol
hiroaki has joined #ruby
DaRock has quit [Ping timeout: 240 seconds]
Jonopoly has joined #ruby
baojg has quit [Remote host closed the connection]
vondruch has joined #ruby
baojg has joined #ruby
eoli3n has joined #ruby
<eoli3n>
Hi
<eoli3n>
in a vagrantfile, i want to increment a letter, something like this : http://ix.io/2E11
<eoli3n>
but vagrant shouldn't "see" ruby part, so i don't get why you say that it is a vagrant bug
<eoli3n>
if i set manually disks names it should work : lets try
<eoli3n>
(without the loop)
<eoli3n>
oh, you're right
<eoli3n>
so my ruby is ok ? good news
<adam12>
eoli3n: It's alomst fine. I'd personally assign LETTER to letter.
<adam12>
eoli3n: LETTER is a constant, and technically constants dont' change.
<eoli3n>
ah, right, fixed
<adam12>
eoli3n: And you could do `DISK_COUNT.times do`
<adam12>
eoli3n: Other than that, it's fine.
<eoli3n>
lets try the times part
<adam12>
eoli3n: Won't make a different since it's the same code.
<adam12>
"same" as functionality.
<adam12>
Just reads nicer / more intent revealing.
<eoli3n>
oh strange... LETTER to letter fixed my first problem
chouhoulis has joined #ruby
<eoli3n>
oh that's strange, i don't get what happened
<eoli3n>
because the letter part is still commented
ChmEarl has joined #ruby
queip has quit [Excess Flood]
<eoli3n>
adam12 times is not ok because it start to 0 and not 1
<leftylink>
whiel that may be true, notice that (0..DISK_COUNT).size == DISK_COUNT + 1, therefore the original code creates one more disk than DISK_COUNT should suggest it should
<leftylink>
&>> (0..DISK_COUNT).size
<eoli3n>
yes i saw it
<rubydoc>
stderr: -e:4:in `<main>': uninitialized constant DISK_COUNT (NameError)... check link for more (https://carc.in/#/r/9ydq)
<eoli3n>
never been there but #ruby is a fun place, i stay
burgestrand has quit [Quit: burgestrand]
lucasb has joined #ruby
<adam12>
Heh
SeepingN has joined #ruby
cloud69 has quit [Quit: Connection closed for inactivity]
iNs_ has quit [Remote host closed the connection]
iNs has joined #ruby
TCZ has quit [Quit: Things Take Time]
code_zombie has joined #ruby
stryek has joined #ruby
svilenv has joined #ruby
<jidar>
can somebody explain what &:succ is doing in the above Enumerator/
orbyt_ has joined #ruby
<adam12>
jidar: &:succ is calling Symbol#to_proc, which returns a Proc. The second argument to Enumerator.produce is a block to be called for each iteration, where in this case we pass a proc. Behind the scenes, it's yielding the return object from the previous loop (let's call it current_value). So basically each time #each is called, it calls the proc with current_value, then re-assigns it.
<adam12>
dnadev2: I didn't test it but it looks accurate.
burgestrand has joined #ruby
burgestrand has quit [Client Quit]
<adam12>
dnadev2: Might be more efficient to count this on the database tho, but you'd have to benchmark it.
<dnadev2>
adam12, interesting and definitely prettier than mine.. gonna test, thanks. yea, true about the performance :/
vondruch has quit [Read error: Connection reset by peer]
<dnadev2>
adam12, love it
<dnadev2>
:)
<dnadev2>
thanks
<adam12>
dnadev2: np
* dnadev2
needs to learn how to think like that
<adam12>
dnadev2: It's just a few tricks, nothing super surprising.
<adam12>
dnadev2: Hash can return a default for missing keys, so we use that to initialize with `0`.
<dnadev2>
ahh
<adam12>
dnadev2: each_with_object is simpler (imho) to rationalize than reduce/inject because of the argument order. So iterate through each item, passing the item and the same Hash to each block.
<adam12>
it probably could of been reduce(Hash.new ...) { |memo, obj| }.
<adam12>
If you initialize someting immediately before a loop, then inside the loop, add to it, there's likely an Enumerable method for you. each_with_object, map, etc.
<adam12>
And of course, variable_N where N is a number, is generally a good use of a Hash.