havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.1, 2.6.6, 2.5.8: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
AndreYuhai has quit [Quit: Leaving]
DoomSlayer2020 has quit [Quit: Leaving]
renich_ has joined #ruby
renich_ has quit [Remote host closed the connection]
renich has quit [Ping timeout: 246 seconds]
chalkmonster has quit [Quit: WeeChat 2.8]
drincruz has joined #ruby
LtHummus has quit [Quit: ZNC 1.8.0 - https://znc.in]
LtHummus has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
ChmEarl has quit [Quit: Leaving]
jtdowney has quit [Quit: Bye]
jtdowney has joined #ruby
jtdowney has quit [Quit: Bye]
jtdowney has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
bruce_lee has quit [Ping timeout: 260 seconds]
jinmiaol1 has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
ur5us has joined #ruby
sphex has quit [Read error: Connection reset by peer]
sphex_ has joined #ruby
iNs has quit [Ping timeout: 240 seconds]
cnsvc_ has joined #ruby
iNs has joined #ruby
charon77 has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
duckpuppy has quit [Ping timeout: 260 seconds]
duckpuppy has joined #ruby
evdubs_ has joined #ruby
duckpuppy has quit [Read error: Connection reset by peer]
evdubs has quit [Ping timeout: 260 seconds]
jtdowney has quit [Quit: Bye]
<poro> Trying to get an exercise done and not sure what I got wrong
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
duckpuppy has joined #ruby
jtdowney has joined #ruby
<poro> any input appreciated, I was confident I got it right but then I googled the answer and the correct number is different from what I get when I run my code
<poro> forget about it
<poro> as I was looking at the paste I realized what was the problem haha, my bad
<poro> This is kinda awkward now hahaha
<poro> I suppose It's good to look at the same code in a different font-size sometimes to catch bugs
ExCwIzItMEDIA has joined #ruby
ExCwIzItMEDIA has quit [Client Quit]
bsdbandit-01 has joined #ruby
jacks2 has joined #ruby
gpanders has joined #ruby
root____ has joined #ruby
<gpanders> Hi all, I'm working on packaging a program that builds ruby bindings as a .bundle file. Note that I am a complete Ruby noob, so this might be an obvious question, but I'm not sure what to do with the .bundle file. Searching for 'ruby bundle file' brings up a bunch of results for bundler, which looks different
<gpanders> (this is on macOS by the way, I am packaging for Homebrew, in case that's relevant)
<gpanders> Using `find` I was able to find some other .bundle files under /usr/local/Cellar/ruby/<version>/lib/ruby/<version>/x86_64-darwin18, so my best guess is that I need to install it there. But I haven't been able to figure out a way to programatically generate that path
<gpanders> (i.e. by using a Ruby command of some kind so that I can put it in the Homebrew formula)
barg has quit [Read error: Connection reset by peer]
jinmiaol1 has quit [Quit: WeeChat 2.8]
evdubs_ is now known as evdubs
root____ has quit [Quit: leaving]
TzilTzal has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
gix- has joined #ruby
gix has quit [Disconnected by services]
drincruz has joined #ruby
jonathant has joined #ruby
jonathant has left #ruby [#ruby]
jonathant has joined #ruby
jonathant has quit [Remote host closed the connection]
drincruz has quit [Ping timeout: 265 seconds]
machinehead has joined #ruby
woodruffw has quit [Ping timeout: 258 seconds]
donofrio has quit [Remote host closed the connection]
woodruffw has joined #ruby
woodruffw has joined #ruby
woodruffw has quit [Changing host]
seaef has quit [Quit: ZZZzzz…]
woodruffw has quit [Ping timeout: 256 seconds]
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
jinmiaoluo has joined #ruby
<poro> if values_array[i].even?
<poro> How come that gives me an undefined method `even?' for nil:NilClass (NoMethodError)
<poro> yet when I debug it evaluates to true without problem
<leftylink> well, it certainly is true that nil doesn't have .even?
<leftylink> &>> nil.even?
<rubydoc> stderr: -e:4:in `<main>': undefined method `even?' for nil:NilClass (NoMethodError)... check link for more (https://carc.in/#/r/95iq)
<machinehead> Title: Carcin (at carc.in)
<poro> hmmmm
<poro> but the second item in that array is the number 2
<al2o3-cr> whos bot is machinehead?
<poro> and i is 1
<poro> maybe it tries to solve the .even? part before solving the array[1] part
<poro> sorry I meant [i]
<leftylink> if one wishes to make sure that an index is in the array, one could use Array#fetch ... though now that I think of this suggestion, I usually don't see Array#fetch used... and usually only Hash#fetch ... wonder if I have just missed the times when people suggest the former
<leftylink> one might also consider the possibility that the array has nil as an element
<leftylink> "take aim at the machine head of that airship / is an airship that slowness crawl along"
<leftylink> is that what machine head means
<leftylink> oh I missed a word
<leftylink> s/aim at the/aim at directly the/
<poro> It is null indeed, my debugging was dumb since I was doing it on a different scope
<poro> found the problem and fixed it, thanks
<poro> since it was a loop I didnt realize that the error was only being triggered after several iterations, it was accessing a position in the array that doesnt exist
matsaman has joined #ruby
<matsaman> rvm tells me "No binary rubies available for: freebsd/11.3/x86_64/ruby-2.7.1." — is there a way to list all binaries/versions that _are_ available?
ur5us has quit [Ping timeout: 260 seconds]
sauvin has joined #ruby
bier has quit [Ping timeout: 244 seconds]
ldepandis has joined #ruby
<phaul> s/s\/aim at the\/aim at directly the\/s\/aim at the\/aim directly at the\//
<phaul> :)
<phaul> actually no. I didn't know the quote just sounded weird. My bad
hiroaki has joined #ruby
schne1der has joined #ruby
hiroaki has quit [Ping timeout: 272 seconds]
morantro1 has joined #ruby
gix- has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
matsaman has quit [Quit: leaving]
imode has quit [Ping timeout: 265 seconds]
conta has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
phaul has joined #ruby
AndreYuhai has joined #ruby
AndreYuhai has quit [Client Quit]
x0n has quit [Ping timeout: 256 seconds]
x0n has joined #ruby
x0n- has joined #ruby
vondruch has joined #ruby
x0n has quit [Ping timeout: 260 seconds]
Liothen_ has joined #ruby
Iambchop_ has joined #ruby
creat_ has joined #ruby
Hobbyboy has joined #ruby
ljarvis_ has joined #ruby
methos1 has joined #ruby
creat has quit [*.net *.split]
mbarbar has quit [*.net *.split]
turt2live has quit [*.net *.split]
Hobbyboy|BNC has quit [*.net *.split]
Liothen has quit [*.net *.split]
ljarvis has quit [*.net *.split]
GGMethos has quit [*.net *.split]
Iambchop has quit [*.net *.split]
Liothen_ is now known as Liothen
Iambchop_ is now known as Iambchop
jacks2 has quit [Quit: http://www.okay.uz/ (Session timeout)]
vqrs has quit [Ping timeout: 264 seconds]
prestorium has quit [Ping timeout: 246 seconds]
vqrs has joined #ruby
prestorium has joined #ruby
cd has quit [Quit: cd]
morantro1 has quit [Remote host closed the connection]
mbarbar has joined #ruby
turt2live has joined #ruby
conta has quit [Quit: conta]
mikecmpbll has quit [Quit: inabit.]
AndreYuhai has joined #ruby
NODE has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
infinityfye has joined #ruby
NODE has quit []
Benett has quit [Remote host closed the connection]
Benett has joined #ruby
NODE has joined #ruby
charon77 has quit [Quit: WeeChat 2.8]
vondruch has quit [Ping timeout: 260 seconds]
<AndreYuhai> How can I set the request body of a get request when making a get request using mechanize? I do this: https://dpaste.org/NgUd#L17 but then I get 400 error
<machinehead> Title: dpaste/NgUd (Ruby) (at dpaste.org)
butcher has joined #ruby
<butcher> is it possible to use react rails with actioncable ?
vondruch has joined #ruby
cliluw has quit [Ping timeout: 264 seconds]
donofrio has joined #ruby
schne1der has quit [Ping timeout: 260 seconds]
<go|dfish> AndreYuhai: what happens if you use a .post instead of .get
rain1 has joined #ruby
<rain1> he
<rain1> hey
<rain1> im on debian and using rbenv
<rain1> in rbenv install -l i can see versions 2.4.1 and 2.5.0-dev -- is there no way to get 2.4.7?
<rain1> the dev version fails to install and 2.4.1 is too old for me
<AndreYuhai> go|dfish, post request returns 405 method not allowed. I don't know why it works perfectly in python but I can not make it work neither in browser network monitor nor in Ruby
<AndreYuhai> go|dfish, I've tried in firefox browser network monitor as well, post request returns invalid client as response and get request returns 400 again.
<go|dfish> AndreYuhai: well requests lets you send a GET request with a body and sends it as application/x-www-form-urlencoded
<go|dfish> AndreYuhai: mech's .get doesn't appear to let you do that, http://docs.seattlerb.org/mechanize/Mechanize.html#method-i-get
<machinehead> <https://x0.no/4ryqe> (at docs.seattlerb.org)
<go|dfish> whatever you pass to it gets sent as a query string
<AndreYuhai> go|dfish, I've included that in my header but result was the same I guess and in python it is not even included.
<AndreYuhai> Oh maybe that's why
<AndreYuhai> I should try with net/http maybe if that allows it
<go|dfish> yeah
chalkmonster has joined #ruby
conta has joined #ruby
conta1 has joined #ruby
conta1 is now known as conta
conta has quit [Ping timeout: 256 seconds]
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
chalkmonster has quit [Quit: WeeChat 2.8]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chalkmonster has joined #ruby
seaef has joined #ruby
Besnik_b has quit [Ping timeout: 272 seconds]
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
schne1der has joined #ruby
drincruz has joined #ruby
mlk has joined #ruby
<mlk> Hi there. Does anyone have any idea how to test a rake task that calls `abort` under certain conditions? It aborts my entire rspec test suite
drincruz has quit [Ping timeout: 264 seconds]
<jhass> mock the abort method?
drincruz has joined #ruby
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
xco has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
tau has joined #ruby
tau has joined #ruby
cnsvc_ has joined #ruby
mlk has quit [Remote host closed the connection]
cnsvc_ has quit [Ping timeout: 240 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Technodrome has joined #ruby
xco has joined #ruby
wogi has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
leitz has joined #ruby
<leitz> Is there any reason not to do a small Sinatra project on Heroku?
wogi has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
jinmiaoluo has quit [Ping timeout: 272 seconds]
cnsvc_ has joined #ruby
<jhass> cost?
<jhass> heroku offers you a lot, but it isn't exactly the cheapest way to host stuff
donofrio_ has joined #ruby
donofrio has quit [Ping timeout: 246 seconds]
joast has quit [Quit: Leaving.]
joast has joined #ruby
d0liver has quit [Ping timeout: 256 seconds]
d0liver has joined #ruby
gitter1234 has joined #ruby
seaef has quit [Quit: ZZZzzz…]
<leitz> jhass, I think I could get in at the free level, the app concept is pretty simple. But, is there a better option?
<leitz> jhass, I'm moving from being a Linux guy to a Programmer Guy, and trying not to spend a lot of time on the backend stuff.
<jhass> better can always be only defined in (mostly subjective) terms/aspects you care about
<leitz> Small project, low cost. Minimal resource usage, custom domain pointing to it.
<jhass> something is never better than the other, it can only better for something
<jhass> note the big "sleeps after 30 minutes of inactivity" restriction on heroku
<jhass> for the free tier
<jhass> and also 1000 hours per account
<leitz> Yup. I figure it will take me a couple of months to get the app working the way I want.
<leitz> Putting it on Heroku will let others see it, and make comments.
TzilTzal has quit [Quit: Leaving.]
tau has quit [Remote host closed the connection]
bsdband63 has joined #ruby
seaef has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.8]
seaef has quit [Client Quit]
bsdbandit-01 has quit [Ping timeout: 240 seconds]
Rudd0 has quit [Ping timeout: 256 seconds]
cnsvc_ has quit [Ping timeout: 240 seconds]
al2o3-cr has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
NODE has quit [Client Quit]
NODE has joined #ruby
Rudd0 has joined #ruby
cnsvc_ has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
rippa has joined #ruby
nofxx_ has quit [Remote host closed the connection]
nofxx_ has joined #ruby
<apotheon> leitz: In my experience, it's difficult to find a host for Ruby web applications that's easier to use than Heroku at the free tier. It does get expensive quickly if you start needing non-free features, though.
<apotheon> leitz: . . . but on the free tier there are going to be slow page loads when the dyno isn't already running at the moment someone visits, as jhass pointed out, so if that's a concern it's worth keeping in mind.
<apotheon> leitz: There's also the fact that, if you need filesystem access for something (e.g. for file uploads) rather than database storage, you'll end up having to use some paid AWS storage or pay for filesystem storage features on Heroku (and filesystem storage is more expensive on Heroku).
<apotheon> leitz: I think a common plan for new applications is to start on Heroku, then move it to AWS or something like that once things really get underway.
ChmEarl has joined #ruby
<leitz> apotheon, thanks!
<apotheon> welcome
<leitz> I'm trying to combine "contribute to an open source project", "learn Ruby", and "build a codebase resume". :)
poro has quit [Quit: Leaving]
<apotheon> leitz: good plan
jrvlima has joined #ruby
jrvlima has quit [Quit: Textual IRC Client: www.textualapp.com]
<jennis> Hi guys, how would I refer to an instance of a class within the class itself?
<havenwood> jennis: Typically: self
<jennis> I thought that was referring to the class itself
<jennis> ?
cnsvc_ has joined #ruby
<jennis> So my understanding was def self.foo will allow you to call Class.foo without having a class instance initialized
<havenwood> jennis: What `self` is varies by context.
<havenwood> jennis: At the top level of the class, it's the class itself.
<havenwood> jennis: So it work to: def self.foo
<havenwood> jennis: But in the context of a method, `self` is the instance.
<jennis> I see, so I have a class Foo which has a boolean attribute bar, and in another method I want to say "do this if bar is true", so I can just use `if self.bar`?
<havenwood> jennis: You don't even need an explicit `self` there, but yes that does work!
<havenwood> jennis: You can just: if bar
<jennis> wonderful, thanks havenwood
<havenwood> jennis: Which is the same as: if self.bar
<havenwood> jennis: no prob, any time
nofxx_ has quit [Remote host closed the connection]
cnsvc_ has quit [Ping timeout: 240 seconds]
kinduff has quit [Read error: Connection reset by peer]
nofxx_ has joined #ruby
kinduff has joined #ruby
nofxx_ has quit [Remote host closed the connection]
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
SeepingN has joined #ruby
TvL2386 has quit [Ping timeout: 260 seconds]
TvL2386 has joined #ruby
AndreYuhai has quit [Ping timeout: 246 seconds]
AndreYuhai has joined #ruby
davispuh has joined #ruby
SuperL4g is now known as SuperLag
<AndreYuhai> Why do I get empty strings as well? https://repl.it/repls/LightpinkEagerPolygons
jinmiaoluo has joined #ruby
<jhass> because * is 0 or more
<jhass> try +, which is 1 or more
<jhass> ah wait, I misread and overlooked the first character group
<jhass> Are you looking for String#scan maybe?
<AndreYuhai> Well, if that does what I am trying to do then sure. But I just wonder why I get empty strings there from that regexp.
<havenwood> AndreYuhai: str.split /(?:[A-Z][^A-Z])+/
<havenwood> AndreYuhai: Or what logic are you trying to do?
<havenwood> AndreYuhai: What's the desired result?
<havenwood> AndreYuhai: Consider a non-capture match with #split, so `(?:foo)` instead of `(foo)`.
<AndreYuhai> havenwood, I just want each word starting with a capital letter so the desired result in my example would be ["Some", "Camel", "Case"]
<havenwood> AndreYuhai: #scan
<jhass> &>> "SomeCamelCase".scan(/[A-Z][a-z]*/)
<rubydoc> # => ["Some", "Camel", "Case"] (https://carc.in/#/r/95n4)
<machinehead> Title: Carcin (at carc.in)
<jhass> wtf is machinehead
<AndreYuhai> jhass, Oh thank you.
<havenwood> AndreYuhai: Or for non-ASCII upper and lower from UTF-8 included too:
<havenwood> str.scan /[[:upper:]][[:lower:]]*/
<deimos_> https://rubular.com maybe helps
<machinehead> Title: Rubular: a Ruby regular expression editor (at rubular.com)
<AndreYuhai> havenwood, thanks :)
<havenwood> &>> class 🆇; end; 🆇.new
<rubydoc> # => #<🆇:0x000055f4ffc0f1a8> (https://carc.in/#/r/95n5)
<machinehead> Title: Carcin (at carc.in)
<AndreYuhai> deimos_, I was trying on regexr.com but I will check that as well.
<havenwood> &>> class Ærbødig; end; Ærbødig.new
<rubydoc> # => #<Ærbødig:0x000055825219b7a0> (https://carc.in/#/r/95n6)
<machinehead> Title: Carcin (at carc.in)
<jhass> !kick machinehead
machinehead was kicked from #ruby by ruby[bot] [kickable offense, see http://ruby-community.com/pages/user_rules]
butcher has quit [Ping timeout: 256 seconds]
gpanders has quit [Ping timeout: 256 seconds]
gpanders has joined #ruby
cnsvc_ has joined #ruby
gpanders has quit [Ping timeout: 264 seconds]
poro has joined #ruby
gpanders has joined #ruby
cnsvc_ has quit [Ping timeout: 240 seconds]
<poro> two newbie questions, what is the point of having to type "do" after the condition of a while loop, also what is the point of having to type end at the end of any conditional statement, shouldnt indentation take care of that?
legit has quit [Quit: WeeChat 2.6]
gpanders has quit [Read error: Connection reset by peer]
<havenwood> poro: For the first point, you don't have to type "do" actually. Try it!
<apotheon> poro: answer - No, because syntactically significant indentation imposes limits on code formatting that can actually reduce readability in some cases, and it also imposes limitations on code idioms that can be productively used without making things harder to read in general.
<jhass> worded differently: Ruby simply doesn't care about the whitespace, so it needs something else
<poro> Oh ok, thank you all
gpanders has joined #ruby
<apotheon> poro: Also, it introduces irregularities in how things are delimited, unless you basically want your programming language to be YAML, such that you end up with inconsistent indentation even in a language that syntactically enforces indentation.
<apotheon> (e.g. multiline dictionary definitions in Python)
<havenwood> poro: Python chose whitespace sensitive syntax, which comes with it's own tradeoffs. It's possible, but not what Ruby does. Matz has decline to make Ruby whitespace sensitive multiple times over the years, but recently approved an experimental "endless" method definition inspired by Coconut (compiles to Python) lang. The new endless syntax still isn't whitespace sensitive but doesn't require "end."
legit has joined #ruby
<havenwood> poro: def foo(a) = expression
<apotheon> Hilariously, the term "endless method" makes me think of a lazily-executed infinite set parsing operation or something like that, and it always takes me a moment to translate it into "method definition without use of the end keyword".
<havenwood> apotheon: Method definition into infinity and beyond.
<apotheon> yep
<jhass> well I guess actually we're lying because \n totally is whitespace and virtually all languages are sensitive to it, but....
<AndreYuhai> Why do I get this: https://imgur.com/a/sJLsOPm when I copy & paste something like this: https://dpaste.org/byVZ into irb starting with the letter "i"?
<AndreYuhai> This had never happened to me before I guess.
<jhass> because you paste it into a REPL and it's indented with tabs
<jhass> so you trigger a double tab
<jhass> which triggers autocompletion (this is not an error message)
jinmiaoluo has quit [Ping timeout: 258 seconds]
<apotheon> jhass: I said "syntactically significant indentation", so I wasn't lying.
<apotheon> I've been referring to it as "indentation" and not "whitespace" all along.
<AndreYuhai> jhass, weird that I'd never encountered that so far.
<apotheon> for years
<jhass> :P
<apotheon> because of the newlines and the whitespace between tokens even on the same line.
<apotheon> s/.$//
vondruch_ has joined #ruby
<apotheon> AndreYuhai: Maybe autocomplete wasn't turned on before.
<AndreYuhai> but then why didn't it happen with code before "if". It only does this when there is an "i" in the beginning I guess
<havenwood> AndreYuhai: Two-space, soft tabs ftw.
<havenwood> ?tabs
<ruby[bot]> Ruby community standards recommend using 2 spaces as indentation (see https://github.com/bbatsov/ruby-style-guide#spaces-indentation and https://ukupat.github.io/tabs-or-spaces/).
<apotheon> Yeah, use spaces. You can still use the tab key; just configure your editor to convert to spaces.
<apotheon> set expandtab
<apotheon> autocmd BufEnter *.rb set shiftwidth=2
<AndreYuhai> Oh yea because I wrote it all in Sublime haha. First time copy pasting from Sublime I guess. :D
<apotheon> (in .vimrc)
<apotheon> This isn't exactly related to your tab/space situation, but consider this in your ~/.irbrc file:
<apotheon> require 'interactive_editor'
vondruch has quit [Ping timeout: 256 seconds]
vondruch_ is now known as vondruch
<apotheon> . . . because it makes working with files and IRB together much easier.
<apotheon> Obviously, you'd have to install the interactive_editor gem.
<apotheon> I think pry has a feature like that built in, but I'm not sure. Anyway, you referred to using IRB.
gix has joined #ruby
<AndreYuhai> apotheon, should I just create that irbrc?
<apotheon> sure
<AndreYuhai> oh yes I did it. Thank you. :)
<apotheon> Once you start IRB with that line in the rc file, you can run the "vim" method in IRB to open an instance of Vim and, when you save/exit, all the code in it will become part of your IRB context.
<apotheon> Alternatively, in IRB, you can give the vim method an argument that is a filename, and it'll open that file, then when you leave the file it'll load its contents into the IRB context.
<apotheon> If you start a fresh file using vim with no arguments, you can use the usual approach to save with a filename, and it'll do that.
<apotheon> Subsequent times opening it will open the same file.
<apotheon> It doesn't have to be Vim. It works with other editors, too.
<poro> Is it normal that my modern i5 takes 2 seconds to do 300000 iterations of this simple loop https://dpaste.org/gxUi
<apotheon> Check out the ri for InteractiveEditor (which is sparse) or online documentation for interactive_editor to learn more about how it works.
<jhass> poro: yes, because it needs to reallocate the array multiple times
<poro> what does reallocate exactly mean in this context?
<poro> jhass
<apotheon> the equivalent of Array.new
<jhass> I bet it's a lot faster if you do Array.new(600851475143)
<jhass> ah wait, that's crystal :D
<jhass> mmh, does ruby has really no way to preset capacity?
<apotheon> I'm not sure it actually reallocates each time, though, in Ruby.
<jhass> it doesn't, it's about geometric I iirc
<apotheon> Is << still implemented differently from Array#push?
<jhass> poro: the array initially allocates with space for a couple of elements, say 8 (I'm making up the numbers and exact algo)
<apotheon> If so, << should be faster than push.
<jhass> poro: as it runs out of space to add elements it allocates a new buffer with space for say 16 elements, then copies the existing 8 to that buffer
<jhass> as it runs out of space there, it allocates space for 32 and so on
<poro> I see, so I should set the size of it on creation before the loop
<apotheon> jhass: I don't think there's a semantically meaningful "capacity" for an array.
<jhass> yeah, I don't see anything either :(
<apotheon> The capacity reallocation is an implementation detail.
<apotheon> . . . rather than part of the language.
<apotheon> That's my understanding, anyway.
<jhass> poro: a fast version of that loop would be Array.new(600851475143) {|i| i }
<jhass> oh wait, I didn't even see you're printing firstly
bier has joined #ruby
<poro> that was just debugging, the printing
<jhass> this can also vastly affect runtime depending on where the output goes to
<apotheon> You should be able to kinda-sorta preallocate just by giving it a number, though. It'd just return an array full of nil.
<poro> I will try that
<AndreYuhai> Yes I was just trying that out. It is really cool to be able to edit it afterwards. Saves a lot of copy & paste time again and again.
<apotheon> Array.new N
<jhass> number + block is the best way really
<jhass> poro: so yeah, also take care with printing while timing things, most terminals are pretty slow and ruby has flush on newline behaviour on tty IOs
<jhass> which costs a syscall roundtrip
<poro> I need some visual feedback tho
<poro> otherwise this thing is gonna be running for minutes and I dont know whats going on haha
<apotheon> Just don't time it while you have your print expression.
<jhass> print a dot every one percent of iterations or so
<poro> ok
<apotheon> That's an idea. Of course, then you're still adding some latency because of keeping track of progress -- just not nearly as much as making syscalls.
<jhass> yeah
<apotheon> . . . and writing to a filehandle via the syscalls.
<apotheon> (at least it's not a file on disk)
<jhass> well, ruby has buffered IO, so it's not necessarily a syscall per write, unless the IO is a tty and the write always has a newline
<apotheon> ah, yeah
cliluw has joined #ruby
<apotheon> hadn't thought of that
<poro> ok now it did 10 million in less than a second just by changing the printing to a percentage, I will research how to populate an array of set sized instead of pushing and that will increase the speed even more
<poro> size*
<poro> oh actually I already know how to do it there is no need to research
<poro> actually...
<poro> integers_array = Array.new(600851475143) this causes a no memory error haha
cliluw has quit [Ping timeout: 260 seconds]
<poro> I went back to the pushing method instead
<jhass> poro: Array.new(...) {|i| i }
<jhass> sorry for the bad hint earlier, I was thinking in Crystal :)
<jhass> in Ruby this is not a capacity hint but creates an array with that many nil's
<poro> Sorry I didnt wanna use that because I havent learned about those symbols yet but I will read up on them
<jhass> so then going on and pushing stuff into it will just add more elements
<jhass> you're learning a lannguage by benchmarking it? :D
<poro> I like to learn hands on as much as possible, looked at the basics and then started solving math problems
<jhass> you might enjoy the ruby koans
<jhass> I think they might be a good approach for where you are currently
<poro> I will check that out, now I gotta disconnect and go home, thanks for the help
poro has quit [Quit: Leaving]
fratis has joined #ruby
<al2o3-cr> &>> x = 600851475143; y = 2; while y < x do while x % y == 0 do x /= y end; y += 1 end; x # i think they wanted this not array.
<rubydoc> # => 6857 (https://carc.in/#/r/95ng)
<al2o3-cr> and i can't even find an end syntax error
<leitz> jhass, I'm enjoying the Koans as well, even though I've done some Ruby. It's a nice self-test, and I'm learning stuff too.
fratis has quit [Read error: Connection reset by peer]
fratis has joined #ruby
fratis has quit [Read error: Connection reset by peer]
fratis has joined #ruby
cliluw has joined #ruby
imode has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
poro has joined #ruby
ellcs1 has joined #ruby
sdrew has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sdrew has quit [Quit: *poof*]
sdrew has joined #ruby
chalkmonster has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
fratis has quit [Ping timeout: 265 seconds]
NODE has left #ruby [#ruby]
NODE has joined #ruby
tau has quit [Ping timeout: 256 seconds]
lucasb has joined #ruby
AndreYuhai has quit [Quit: Leaving]
Scriptonaut has left #ruby [#ruby]
<jrhorn424> is there a way to get rdoc to only document part of a project? I'm attempting to document only `lib`, for example. `rdoc_options` has an `rdoc_include` directive, which doesn't seem to accomplish what I want. neither does `--root`. is the only way to accomplish this by passing the directory as a command line option?
cliluw has quit [Ping timeout: 240 seconds]
jeromelanteri has joined #ruby
cliluw has joined #ruby
cliluw has quit [Ping timeout: 260 seconds]
cliluw has joined #ruby
chalkmonster has joined #ruby
bukkitgerman8608 has quit [Quit: Ping timeout (120 seconds)]
bukkitgerman8608 has joined #ruby
<deimos_> 1/4
<deimos_> oops, sorry
<apotheon> Yeah, at least give us half.
<deimos_> that's my root password
<apotheon> Quarter root?
<deimos_> root_password = "1/4"
<poro> thats a interesting password
<apotheon> I knew it wasn't your Oracle password.
* deimos_ violates security standards and ruby guides
<apotheon> Oracle shits itself if your password starts with a number, I think.
<apotheon> . . . or maybe that SQL Server.
<apotheon> s/that/that was/
<apotheon> I accidentally a word.
<deimos_> in reality, i was just trying to change channels
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alexherbo2 has joined #ruby
fuDwitc has joined #ruby
cahoots_ has joined #ruby
<cahoots_> hi, i want to require a certain gem (pry-byebug) for every single ruby script i run. how might i do this?
fratis has joined #ruby
akem_ has joined #ruby
akem has quit [Ping timeout: 256 seconds]
rain1 has quit [Quit: leaving]
fratis has quit [Read error: Connection reset by peer]
fratis has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
gnufied has joined #ruby
<jhass> alias ruby=ruby -rpry-byebug
fratis has quit [Ping timeout: 246 seconds]
ur5us has joined #ruby
akem has joined #ruby
akem has quit [Remote host closed the connection]
akem_ has quit [Ping timeout: 258 seconds]
akem has joined #ruby
akem_ has joined #ruby
akem has quit [Read error: Connection reset by peer]
TCZ has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
jeromelanteri has quit [Quit: Leaving]
<cahoots_> jhass, ty
TCZ is now known as DoomSlayer2020
infinityfye has quit [Read error: Connection reset by peer]
infinityfye has joined #ruby
BTRE has quit [Ping timeout: 265 seconds]
bsdband63 has quit [Quit: -a- Connection Timed Out]
BTRE has joined #ruby
bsdbandit-01 has joined #ruby
ellcs1 has quit [Ping timeout: 256 seconds]
fratis has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
inradius has joined #ruby
imode has quit [Ping timeout: 256 seconds]
Mawile has joined #ruby
imode has joined #ruby
Archenoth has quit [Ping timeout: 246 seconds]
fratis has quit [Remote host closed the connection]
<leitz> apotheon, when are we going to get the OWL on spdx?
<apotheon> I need to get a legal review first.
<apotheon> . . . which means giving money to a lawyer.
<apotheon> same for the COIL
<apotheon> It also means getting a lawyer who seems competent to give me a quote.
poro_ has joined #ruby
<leitz> How much are the legal reviews?
fratis has joined #ruby
poro has quit [Ping timeout: 256 seconds]
infinityfye has quit [Read error: Connection reset by peer]
infinityfye has joined #ruby
Technodrome has joined #ruby
troulouliou_div2 has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<apotheon> leitz: I don't know yet. I haven't gotten a quote.
cloaked1 has joined #ruby
prestorium has quit [Remote host closed the connection]
prestorium has joined #ruby
<leitz> apotheon, sorry. I thought you might have a ballpark number. I don't mind helping out, if you catch me when I have funds.
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leitz has quit [Quit: Leaving]
infinityfye has quit [Quit: Leaving]
DoomSlayer2020 has quit [Quit: Leaving]
drincruz has quit [Ping timeout: 256 seconds]
cd has joined #ruby
barg has joined #ruby
<barg> poro_: besides looking at a paste , you should debug. it's easier!
lesha has joined #ruby
<poro_> true
<havenwood> poro_: Want any refactoring suggestions or focusing on new tasks?
<poro_> suggestions please
<havenwood> poro_: Share your latest paste or if I check the logs will I find it?
<poro_> I'll make a new one
howdoi has joined #ruby
fratis has quit [Remote host closed the connection]
fratis has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leftylink> what's wrong with using Range#to_a ?
<leftylink> er, what is the rationale for the code above not using Range#to_a ?
<poro_> me not knowing about that until you mentioned it :D
<poro_> Im reading on it now
<havenwood> poro_: Instead of Array.new, it's best to use the Array literal for an empty Array. So on line 2, just: integers_array = []
<havenwood> poro_: There are more reasons, but it's faster and easier to read.
<havenwood> poro_: On line 5 you can drop the `do`. In general, if you can remove code and have it operate identically or faster, do it!
fratis has quit [Ping timeout: 260 seconds]
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
<havenwood> poro_: It's a common idiom in Ruby to use the shovel operator (<<) instead of #push.
<havenwood> poro_: integers_array << i
<havenwood> It has a visual appeal.
<havenwood> poro_: i += 1
<havenwood> poro_: += is part of a family of useful things like -=, /=, |=, ||=, etc.
<havenwood> *=
<poro_> I changed all those things, thanks
<havenwood> &>> x = 5; x *= 42; x
<rubydoc> # => 210 (https://carc.in/#/r/95p2)
<havenwood> poro_: So line 10, same refactor. +=
<poro_> Is there a way of having the array be a given length with nil values with the Array literal?
<havenwood> &>> Array.new(4)
<rubydoc> # => [nil, nil, nil, nil] (https://carc.in/#/r/95p3)
<havenwood> &>> [nil] * 4
<rubydoc> # => [nil, nil, nil, nil] (https://carc.in/#/r/95p4)
<poro_> hmm but 600851475145 is too much it runs out of memory