<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
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
<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
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". :)
<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]
<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....
<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
<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?