<havenwood>
patrick99e99: How many zeros do you want to pad? Show an example?
<havenwood>
patrick99e99: Are you wanting a String representation of an Integer? Something else?
roadie has joined #ruby
^amra has quit [Quit: ^amra]
ur5us has quit [Ping timeout: 240 seconds]
roadie has quit [Ping timeout: 265 seconds]
<TCZ>
is it possible to create substring without copying characters? i wanted to make proc function simpler instead of proc(str,from,to) -> proc(substr)
<havenwood>
TCZ: What do you mean by "copying characters?"
<havenwood>
TCZ: Show an example of what that's look like in practice?
mrwisdom is now known as caterfxo
<TCZ>
for example if im recursively processing string, splitting into 2 parts i could pass indices to both function calls so they both use the same string or pass 2 substrings but that would cause creating unnecessary copies right?
<havenwood>
TCZ: Show an example of the code in use? I *kinda* get what you're saying but not quite following how you're using the proc.
v1sage has quit [Quit: v1sage]
leitz has quit [Quit: Leaving]
lightstalker has quit [Remote host closed the connection]
lightstalker has joined #ruby
ur5us has joined #ruby
duderonomy has quit [Ping timeout: 260 seconds]
duderonomy has joined #ruby
duderono_ has joined #ruby
duderonomy has quit [Ping timeout: 265 seconds]
markong has quit [Ping timeout: 256 seconds]
gavlee has quit [Ping timeout: 260 seconds]
postmodern has joined #ruby
jamessan has joined #ruby
gix has quit [Ping timeout: 256 seconds]
LDonoughe has joined #ruby
<jamessan>
_phaul: re: my Proc.new question the other day, switching to &callback doesn't seem to work. https://dpaste.org/91KC is the original code. If I s/callback=Proc.new/&callback/ then I get complaints about passing an argument to a function that doesn't expect one (both from init_callbacks and, after removing the nil, from set_log_msg_func)
gavlee has joined #ruby
LDonoughe has quit [Ping timeout: 258 seconds]
Esa_ has quit []
sergioro has quit [Quit: leaving]
pandakekok9 has joined #ruby
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
ReekenX has joined #ruby
<thenori>
What's the form of delete that only deletes the first element it finds?
apteryx has quit [Killed (kornbluth.freenode.net (Nickname regained by services))]
apteryx has joined #ruby
<havenwood>
stapler: Matz's Ruby Interpreter (MRI) was replaced by a VM (YARV) years back, in Ruby 1.9, which greatly increased performance.
<stapler>
havenwood: the modern vm.. sorry.. not too familiar with ruby's history
<havenwood>
stapler: There's been a ton of work done to speed up the reference implementation, CRuby. Some folk still call it MRI, others mean the old, slow interpreter.
<havenwood>
stapler: JRuby and TruffleRuby are both very performance oriented implementations.
<havenwood>
stapler: The goal for CRuby 3, due out this Christmas, is more than three times faster than Ruby 2, which is itself several times faster than Ruby 1.8.
<havenwood>
stapler: That goal was actually already hit with the new JIT using the optcarrot NES emulator as the reference benchmark, which was the goal.
<havenwood>
TruffleRuby takes the cake on that one though. Hundreds of FPS!
<havenwood>
CRuby now plays +60 FPS on my laptop, so perfect. :)
<stapler>
what is the status of truffleruby and jruby by the way.. are they frequently used among people who deploy software written in ruby?
<stapler>
sorry.. probably rather surface level questions and i've always enjoyed the look of ruby but just curious about the realities/practicalities of it
<havenwood>
stapler: JRuby is fairly widely used and is production ready. TruffleRuby is a remarkably complete implementation with really remarkable performance but it's not yet battle tested widely in prod like CRuby and JRuby.
<stapler>
do people tend to favor java interop with jruby or libraries written in ruby?
<s2013>
can you have a ? in the attr_accessor name?
<havenwood>
stapler: A bunch of popular libraries have extensions in Java and C with a fallback to pure Ruby.
<havenwood>
s2013: no
<s2013>
so something like attr_accessor :emailable?
<s2013>
so what is the best approach for something like that
<havenwood>
s2013: You have to define a method or alias.
<havenwood>
s2013: No attr shortcut.
<s2013>
so def emailble? emailable end?
<havenwood>
s2013: def emailable? @emailable end
<s2013>
or like alias_method :emailable?, :emailable
<havenwood>
s2013: Yes
<havenwood>
s2013: Or with the keyword: alias emailable? emailable
<s2013>
which one is considered a better practice?
<s2013>
so when you set teh attribute you set .emailable right?
<s2013>
so like .emailable =t rue
<havenwood>
s2013: I just define a method to avoid a predicate and regular alias.
<havenwood>
s2013: def emailable?; @emailable end
<s2013>
gotcha, thanks
<havenwood>
np
<havenwood>
stapler: CRuby is most popular then JRuby.
<s2013>
im also stuck on a rails question but rails channel is dead
<havenwood>
s2013: What's the Rails question? Have a gist?
<s2013>
let me create a gist.. but it was about concerns..
<havenwood>
s2013: concerning
ttoocs has quit [Quit: WeeChat 2.7.1]
<stapler>
havenwood: knowing whats possible with 2.7 and soon 3, as well as alternate implementations
<stapler>
are there things you would say ruby is not suited for wrt performance?
<apotheon>
You might not want to write graphics drivers in Ruby.
<apotheon>
(re: performance question)
<havenwood>
s2013: Show #translate_with_options usage? I don't follow.
<apotheon>
It's probably fine just about anywhere you'd consider Python, Perl, most Scheme implementations, shell scripts (including PowerShell), and piles of other dynamic languages.
<s2013>
havenwood basically i want to refactor it so that the concern has everything it needs
<s2013>
and can call the translates methods from the concern itself
<s2013>
instead of calling it on each individual odel
<s2013>
model*
<havenwood>
stapler: It's not suitable for cases where execution speed is more important than programmer happiness. It's generally fast enough for things where it doesn't have to be as fast as possible. I'm sure you could come up with GC-related cases for realtime-type things where it's not appropriate. System programming comes to mind.
<havenwood>
s2013: How do you call it from the concern without passing the field names? Assuming your gist is how it currently works? Gist how you'd like it to work?
<s2013>
id just call it translate_with_opts :field1 :field2
<havenwood>
s2013: I don't get how that's different from `translates :field1, :field2` in what you've shown.
zacts has quit [Quit: WeeChat 2.8]
<havenwood>
s2013: What's different, other than the method name?
<s2013>
there are bunch of options and configurations which are same across all of them
<havenwood>
s2013: Ahh
<s2013>
anyways even if it was the same, im trying to figure out how to do it using that ethod
<s2013>
theres a lot of repeat so trying to cut that down
<havenwood>
s2013: Hmm. There's a pattern for an instance of a module that you could probably use.
<havenwood>
unsure if it's worth the confusion
bvdw has quit [Read error: Connection reset by peer]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
<vasilakisfil>
the top most widest line refers to a class that I initialize inside a rails controller method, all the rest below that are rails calls
<vasilakisfil>
so what can we understand from that flamegraph? That ruby spends enormous amount of time inside rails ?
<havenwood>
vasilakisfil: Is it an enormous amount of time or just a large percent of a tiny amount of time?
<havenwood>
vasilakisfil: This isn't very spiky and looks like a bunch of quick things. Is it taking long?
<havenwood>
vasilakisfil: The slow parts are typically waiting on I/O.
ur5us has joined #ruby
BTRE has quit [Ping timeout: 258 seconds]
<havenwood>
vasilakisfil: DB and API calls and such are relatively quite slow and are often where you should optimize.
<havenwood>
vasilakisfil: Is something slow here or just inspecting?
<vasilakisfil>
it takes ages
<havenwood>
vasilakisfil: What's it doing?
<vasilakisfil>
and I found the issue, I had a loop checking a global variable
kke has quit [Remote host closed the connection]
<havenwood>
Ahh.
<vasilakisfil>
actually flamegraph was into the point, super helpful
<vasilakisfil>
hehe great stuff :D added a sleep now seems to be working
<vasilakisfil>
question: if I add a sleep, will the thread give priority to other threads, meaning will it yield to another thread automatically or should I do something else ?
schne1der has joined #ruby
sagax has quit [Remote host closed the connection]
<havenwood>
vasilakisfil: Yeah, other Threads can schedule during sleep. You can alternatively do a Thread.stop and #run it when you'd like to resume. Why are you sleeping?
duderono_ has quit [Ping timeout: 250 seconds]
BTRE has joined #ruby
duderonomy has joined #ruby
rmnull has joined #ruby
jingjinghack has quit [Read error: Connection reset by peer]
jingjinghack has joined #ruby
zlogan has joined #ruby
sagax has joined #ruby
jingjing1 has joined #ruby
jingjing2 has joined #ruby
jingjinghack has quit [Ping timeout: 256 seconds]
<vasilakisfil>
cause checking all the time a variable, it monopolizes the cpu
jingjing1 has quit [Ping timeout: 264 seconds]
snosk8r has quit [Remote host closed the connection]
snosk8r has joined #ruby
hbroadbent has joined #ruby
hbroadbent has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 252 seconds]
<yxhuvud>
Why are you continously checking a variable?
Secret-Fire has joined #ruby
Secret-Fire has quit [Max SendQ exceeded]
xco has joined #ruby
markopasha has quit [Ping timeout: 264 seconds]
braincrash has quit [Ping timeout: 260 seconds]
gix has joined #ruby
schne1der has quit [Quit: schne1der]
nullus has quit [Quit: leaving]
schne1der has joined #ruby
CrazyEddy has joined #ruby
jingjinghack has joined #ruby
angelds has joined #ruby
jingjing2 has quit [Ping timeout: 256 seconds]
<_phaul>
busy wait for IO to become available is bad, sleeping is also not ideal. OS supported wake up like select is better...
fanta1 has joined #ruby
angelds has quit [Ping timeout: 250 seconds]
jeromelanteri has joined #ruby
snosk8r has quit [Quit: Leaving]
snosk8r has joined #ruby
CrazyEddy has quit [Ping timeout: 260 seconds]
rubydoc has quit [Ping timeout: 260 seconds]
gavlee_ is now known as gavlee
madhatter has quit [Remote host closed the connection]
madhatter has joined #ruby
CrazyEddy has joined #ruby
ritalinona has quit [Ping timeout: 240 seconds]
rprimus has quit [Ping timeout: 256 seconds]
rprimus has joined #ruby
ritalinona has joined #ruby
hiroaki has quit [Ping timeout: 258 seconds]
rippa has joined #ruby
vondruch_ has joined #ruby
vondruch has quit [Ping timeout: 265 seconds]
vondruch_ is now known as vondruch
Technodrome has joined #ruby
chalkmonster has joined #ruby
TCZ has joined #ruby
patrick99e99 has quit [Ping timeout: 265 seconds]
postmodern has quit [Quit: Leaving]
arahael2 has quit [Quit: WeeChat 2.4]
rubydoc has joined #ruby
phaul has joined #ruby
zlogan has quit [Ping timeout: 272 seconds]
_phaul has quit [Ping timeout: 258 seconds]
sysh has joined #ruby
TzilTzal has quit [Quit: Leaving.]
zapata has quit [Ping timeout: 252 seconds]
TCZ has quit [Quit: Leaving]
ReekenX has quit [Ping timeout: 240 seconds]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
yxhuvud has quit [Remote host closed the connection]
markong has joined #ruby
zapata has joined #ruby
zlogan has joined #ruby
yxhuvud has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
markoong has joined #ruby
markong has quit [Ping timeout: 265 seconds]
burningserenity has joined #ruby
GodFather has quit [Ping timeout: 256 seconds]
drincruz_ has joined #ruby
akem_ has joined #ruby
markong has joined #ruby
akem has quit [Ping timeout: 256 seconds]
markoong has quit [Ping timeout: 250 seconds]
GodFather has joined #ruby
markoong has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
mn3m has quit [Read error: Connection reset by peer]
markong has quit [Ping timeout: 256 seconds]
phaul has quit [Ping timeout: 256 seconds]
markoong has quit [Ping timeout: 250 seconds]
mn3m has joined #ruby
markong has joined #ruby
burningserenity has quit [Remote host closed the connection]
howdoi has joined #ruby
burningserenity has joined #ruby
donofrio has joined #ruby
phaul has joined #ruby
_phaul has joined #ruby
phaul has quit [Ping timeout: 250 seconds]
TCZ has joined #ruby
_phaul has quit [Ping timeout: 260 seconds]
burningserenity has quit [Remote host closed the connection]
ellcs has joined #ruby
_phaul has joined #ruby
phaul has joined #ruby
ReekenX has joined #ruby
_phaul has quit [Ping timeout: 256 seconds]
ReekenX has quit [Quit: See you later!]
alfiemax has joined #ruby
_phaul has joined #ruby
fercell has joined #ruby
phaul has quit [Ping timeout: 258 seconds]
_phaul has quit [Ping timeout: 265 seconds]
_phaul has joined #ruby
s2013 has joined #ruby
gilfoyle has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
NODE has quit [Remote host closed the connection]
cow[moo] has joined #ruby
NODE has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
conta has joined #ruby
phaul has joined #ruby
_phaul has quit [Ping timeout: 256 seconds]
burningserenity has joined #ruby
jingjinghack has quit [Quit: WeeChat 2.1]
^amra has joined #ruby
lineus_ has quit [Remote host closed the connection]
roadie has joined #ruby
lineus has joined #ruby
_phaul has joined #ruby
sh7d has quit [Read error: Connection reset by peer]
phaul has quit [Ping timeout: 265 seconds]
fanta1 has quit [Quit: fanta1]
sh7d has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
_phaul has quit [Ping timeout: 256 seconds]
cow[moo] has quit [Ping timeout: 256 seconds]
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
_phaul has joined #ruby
LDonoughe has joined #ruby
ellcs has joined #ruby
lucasb has joined #ruby
chalkmonster has quit [Read error: Connection reset by peer]
conta has quit [Quit: conta]
phaul has joined #ruby
_phaul has quit [Ping timeout: 256 seconds]
phaul has quit [Ping timeout: 256 seconds]
jcalla has quit [Remote host closed the connection]
phaul has joined #ruby
_phaul has joined #ruby
SeepingN has joined #ruby
jcalla has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
alfiemax_ has joined #ruby
alfiemax has quit [Ping timeout: 240 seconds]
lineus has quit [Remote host closed the connection]
lineus has joined #ruby
LDonoughe has quit [Ping timeout: 265 seconds]
Fusl has quit [Quit: K-Lined]
Fusl has joined #ruby
ChmEarl has joined #ruby
KamLy has joined #ruby
zapata has quit [Quit: WeeChat 2.7.1]
hiroaki has joined #ruby
KamLy has quit [Ping timeout: 246 seconds]
TCZ has quit [Quit: Leaving]
lineus has quit [Remote host closed the connection]
lineus has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
cd has joined #ruby
elphe has quit [Ping timeout: 256 seconds]
cthu| has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
stapler has quit [Quit: Connection closed for inactivity]
zapata has joined #ruby
troydm has joined #ruby
<troydm>
what's the easiest way to execute some shell command and get it's output in Ruby without seeing command's outputed to current shell
<troydm>
?
conta1 has joined #ruby
NODE has quit [Quit: changing servers]
NODE has joined #ruby
<al2o3-cr>
troydm: if you want stdout and stderr: output, status = Open3.capture2e('w') otherwise use capture2.
<s2013>
oh i think i know why its returning [] but how do i set it so it always returns the params from mod_fields
alfiemax_ has quit [Remote host closed the connection]
<_phaul>
you would have to store that state somewhere, as currently there is nothing connecting your calls
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<_phaul>
instance variable probably
alfiemax has joined #ruby
<s2013>
_phaul yeah .. im doing this as part of rails where the model has an initial method (not an initialization) and i want to grab the arguments passed fro that method anytime
<s2013>
_phaul i added some more code to give context as to what i want to do
<phaul>
or more ruby-esque : class Foo; class << self; attr_accessor :fields; end; end ; Foo.fields = ['a', 'b'] ; Foo.fields # => ['a', 'b']
<s2013>
i think the @ worked
<s2013>
testing it.
<s2013>
thanks!
<phaul>
np
minall has joined #ruby
<minall>
Hello Ruby Community!
SeepingN has joined #ruby
<minall>
I'm learning Ruby, and I reached a file where a class is defined in a way I don't understand...
<phaul>
_o/ minall
<minall>
class < module::something
<minall>
How can this be readed?, class is inheriting everything from module and the variable something?
<phaul>
I would say this is syntax error..
<phaul>
&>> class < module::something; end
<rubydoc>
stderr: -e:4: syntax error, unexpected '<'... check link for more (https://carc.in/#/r/8tcr)
fercell has quit [Quit: WeeChat 2.7.1]
<phaul>
check if what you pasted is the exact code..
<minall>
phaul: o/
<phaul>
down to letter capitalization
<minall>
Ok, let me paste it, It's from koans I'm practicing right now
<minall>
class AboutAsserts < Neo::Koan
<minall>
I'm trying to understand what that means but, I can only see examples of namespace where a variable is accessed
<phaul>
class AboutAsserts is inheriting from class Neo::Koan. Neo is a module that nests the class Koan, giving it a namespace
<phaul>
module A; class B; end; end; then A::B is the class B inside namespace A
<minall>
Ohhh, thanks phaul, makes sense... But one question, what happends if I like, include in a new class Neo... Will it inherit Koan class also? or just methods and instances from Neo?
DTZUZU2 has joined #ruby
<phaul>
it will not. syntactical nesting or module nesting has no relation to inheritance
<minall>
So basically I'm just including the /Koan/ class that's inside the Neo Module, or am I also including Neo?
DTZUZU has quit [Ping timeout: 256 seconds]
<minall>
Sorry, that was a bad question, Modules can't be inherited but included
<phaul>
neither inlcude, extend, prepend or inheritance cares about nesting
<minall>
phaul: I'm not following...
_phaul has joined #ruby
<_phaul>
sorry minall , I'm on mobile net, getting disconnected frequently...
<minall>
_phaul: Don't worry, thanks for taking my question
<minall>
Is there a difference between making an array like 'newarr = []' To ' newarr = Array.new'?
phaul_ has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
<phaul_>
minall : topic you want to read about is module nesting https://cirw.in/blog/constant-lookup, as you will see it's an orthognall consept to the ancestor chain
conta1 has quit [Quit: conta1]
<minall>
Thanks phaul_!
<minall>
An unrelated question: Is there a difference between making an array like 'newarr = []' To ' newarr = Array.new'?
<siery>
and when accessing opt[opt], even when the opt is something like "n ", it returns n
burningserenity has quit [Quit: Leaving.]
burningserenity has joined #ruby
_phaul has joined #ruby
<minall>
siery: Maybe you can use chomp to your advantage?
<_phaul>
siery it doesn't. probably we would need the value for OPTIONS and pattern to understand what's going on, but in short it doesn't just remove the end of the string unless you ask it to
<siery>
ah, ya, I forget opt[opt.size - 1], I just typed opt[opt.size]
phaul has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 265 seconds]
LDonoughe has joined #ruby
rmnull1 has joined #ruby
burningserenity has quit [Quit: Leaving.]
rmnull has quit [Ping timeout: 252 seconds]
rmnull has joined #ruby
rmnull1 has quit [Ping timeout: 246 seconds]
alfiemax_ has quit []
<kaleido>
is there something already written that i could use that would ssh to a device using keys to auth, run a set of commands and then puts the output?
alfiemax has joined #ruby
jordanm has quit [Quit: Konversation terminated!]
jordanm has joined #ruby
NODE has quit [Quit: changing servers]
chalkmonster has joined #ruby
NODE has joined #ruby
vondruch has quit [Ping timeout: 256 seconds]
BTRE has quit [Read error: Connection reset by peer]
TomyWork has quit [Remote host closed the connection]
NODE has quit [Quit: changing servers]
NODE has joined #ruby
gilfoyle has quit [Quit: leaving]
alfiemax has quit [Remote host closed the connection]
<havenwood>
siery: opt[-1]
<havenwood>
kaleido: Net::SSH
<kaleido>
is that built in or do i have to require something?
rubydoc has quit [Remote host closed the connection]
KamLy has joined #ruby
DTZUZU2 has quit [Ping timeout: 258 seconds]
DTZUZU2 has joined #ruby
rubydoc has joined #ruby
KamLy has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
<CommunistWolf>
Today I investigated a performance issue so large, `Marshal` couldn't dump the profile. Ran out of stack space :D
<siery>
havenwood: I guess that will require to change the definition of insert
<havenwood>
siery: I don't understand what you're asking.
<havenwood>
siery: What are you doing and why?
<adam12>
def file_list.insert; "c:"; end
<adam12>
Actually it accepts an arg, so you'd have to redefine with args.
<siery>
havenwood: I was just curious if there is an easy way, like a keyward to avoid retruning eval value, like next or break in the block
ur5us has joined #ruby
zapata has joined #ruby
<kaleido>
what class(forgive me if i'm mangling terms) would i read up on if i was interested in grepping words from paragraphs, or counting down X number of lines before counting the remaining lines?
<adam12>
kaleido: String for the first, Enumerable (maybe) for the second
<adam12>
You might want stringscanner here, but not enough information to go on.