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!
elphe has joined #ruby
v1sage has joined #ruby
kristian_on_linu has joined #ruby
caterfxo has joined #ruby
caterfxo is now known as mrwisdom
zlogan has quit [Ping timeout: 246 seconds]
dionysus69 has quit [Ping timeout: 256 seconds]
<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?
<leftylink> I think that is delete.
<leftylink> &>> a = [1, 1, 1]; a.delete(1); a
<rubydoc> # => [] (https://carc.in/#/r/8t9o)
kristian_on_linu has quit [Remote host closed the connection]
<leftylink> WELL i am wrong
<leftylink> good job
<leftylink> I am good at this
<leftylink> maybe delete_at... ??? but you would need the index for that
<thenori> delete deletes all of the objects
<thenori> i'll just do .index.delete_at
TCZ has quit [Quit: Leaving]
pandakekok9 has quit [Ping timeout: 250 seconds]
LDonoughe has joined #ruby
ChmEarl has quit [Quit: Leaving]
patrick99e99 has quit [Quit: Lost terminal]
zxq2 has joined #ruby
djdduty has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
KamLy has joined #ruby
Arkantos has quit [Quit: Textual IRC Client: www.textualapp.com]
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
snosk8r has quit [Read error: Connection reset by peer]
frem has quit [Quit: Connection closed for inactivity]
brool has quit [Quit: WeeChat 2.7.1]
sergioro has joined #ruby
polishdub has joined #ruby
zacts has joined #ruby
zacts has quit [Client Quit]
zacts has joined #ruby
KamLy has quit [Read error: Connection reset by peer]
gigetoo has quit [Ping timeout: 265 seconds]
greypack has quit [Ping timeout: 265 seconds]
bambanx has joined #ruby
snosk8r has joined #ruby
zacts has quit [Quit: WeeChat 2.8]
gigetoo has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
bambanx has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 252 seconds]
cthu| has quit [Ping timeout: 256 seconds]
greypack has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.7.1]
ReekenX has quit [Quit: Away...]
al2o3-cr has joined #ruby
LDonoughe has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
patrick99e99 has joined #ruby
<patrick99e99> Hi everyone.. How can I convert a hex string to a raw hex string with single back slashes? for example, "ff00a1" => "\xff\x00\xa1" ?
<havenwood> &>> "ff00a1".scan(/\h\h/).map(&:hex).map(&:chr).join
<rubydoc> # => "\xFF\x00\xA1" (https://carc.in/#/r/8tah)
<havenwood> &>> "ff00a1".gsub(/\h\h/) { _1.hex.chr }
<rubydoc> # => "\xFF\x00\xA1" (https://carc.in/#/r/8tai)
<havenwood> patrick99e99: ^
<patrick99e99> havenwood: THANK YOU!!!!!!!!!!!!!!!!
minall has quit [Quit: Konversation terminated!]
<havenwood> &>> "ff00a1".gsub(/\h\h/) { |pair| pair.hex.chr }
<rubydoc> # => "\xFF\x00\xA1" (https://carc.in/#/r/8tan)
thenori has quit [Remote host closed the connection]
cd has quit [Quit: cd]
s2013 has joined #ruby
jcalla has quit [Ping timeout: 264 seconds]
alfiemax has quit [Ping timeout: 260 seconds]
apteryx has joined #ruby
<apteryx> what does #{7.chr} mean in Ruby?
BTRE has quit [Ping timeout: 256 seconds]
BTRE has joined #ruby
<havenwood> aphorise: A bell.
<havenwood> oops, wrong nick
zacts has joined #ruby
<havenwood> apteryx: 7.chr #=> "\a"
<havenwood> aphorise: It makes a: Ding!
<havenwood> gah
<havenwood> aphorise: sry
<havenwood> apteryx: #{} is String interpolation.
<havenwood> apteryx: ruby -e 'print "\a"'
<havenwood> apteryx: Same as:
<havenwood> apteryx: ruby -e 'print 7.chr'
<apteryx> OK! So it's designed to ring the terminal bell in the example I was looking at. I wasn't sure. Thanks!
<havenwood> apteryx: Yup, that's all. You're welcome.
<stapler> i know im asking #ruby, but is mri as slow as people tend to believe it is?
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jcalla has joined #ruby
<havenwood> stapler: By MRI do you mean the modern CRuby VM or the old interpreter?
<havenwood> Endless method definition... hehe: https://bugs.ruby-lang.org/issues/16746
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. :)
Arkantos has joined #ruby
<stapler> on 2.7?
<havenwood> stapler: yeah
<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?
<s2013> https://paste.ubuntu.com/p/m2vCBqKHgT/ hope this makes sense
<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]
bvdw has joined #ruby
<s2013> would still love to cehck it out
<havenwood> s2013: sec, I'll find an example
<s2013> sure
<havenwood> s2013: This is what I'm talking about, but too convoluted of an example: https://gist.github.com/havenwood/0c2a3f70f68151f7ab022e2430487432
<havenwood> s2013: Lemme show a simpler one, sec.
<s2013> ok
Fusl has quit [Quit: K-Lined]
<havenwood> s2013: I'm not even sure this is what you meant you want to do, but here's how to make an instance of a module with particular state: https://gist.github.com/havenwood/63be076960792288a3b5fb318f251f3e
<s2013> not exactly .. let me try out few more things and then maybe i can paste what i have attempted
Fusl has joined #ruby
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 256 seconds]
dinfuehr has joined #ruby
jingjinghack has joined #ruby
apteryx is now known as Guest44796
Guest44796 has quit [Killed (barjavel.freenode.net (Nickname regained by services))]
apteryx has joined #ruby
Arkantos has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
polishdub has quit [Quit: leaving]
SeepingN has quit [Ping timeout: 240 seconds]
donofrio has quit [Remote host closed the connection]
TzilTzal has joined #ruby
<TzilTzal> Hi
<TzilTzal> Does anyone know whether it's possible to pass arguments to the after_create callback in ActiveRecord?
dinfuehr has quit [Ping timeout: 258 seconds]
dinfuehr has joined #ruby
markopasha has joined #ruby
BTRE has quit [Ping timeout: 240 seconds]
<havenwood> TzilTzal: Can you just use the block form of #after_create? What arguments are you passing?
<havenwood> TzilTzal: after_create do
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #ruby
<TzilTzal> havenwood: I'd like to insert something to another table (model B) upon the creation of model A.
<TzilTzal> havenwood: and this requires a couple of arguments.
BTRE has joined #ruby
<havenwood> TzilTzal: after_create { |_model_a| ModelB.something(model_a) }
<TzilTzal> but it's not just model a..
<TzilTzal> I might need other arguments as well.
<havenwood> TzilTzal: Like what? Show an example?
<TzilTzal> some external arguments that are unrelated to model A.
<havenwood> TzilTzal: #after_create just executes a block or calls a method. The docs do show how to make it flexible with initialization data.
<havenwood> TzilTzal: after_save EncryptionWrapper.new("credit_card_number")
<havenwood> TzilTzal: If you show what you'd like it to look like, it might trigger someone here proffering what you're looking for.
ReekenX has joined #ruby
<TzilTzal> havenwood: thanks )
idiocrash has joined #ruby
CrazyEddy has quit [Ping timeout: 258 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
cliluw has joined #ruby
postmodern has quit [Remote host closed the connection]
postmodern has joined #ruby
kaleido has quit [Quit: ZNC 1.7.4+deb7 - https://znc.in]
m27frogy has quit [Quit: ZNC - https://znc.in]
kaleido has joined #ruby
m27frogy has joined #ruby
roadie has joined #ruby
gavlee_ has joined #ruby
gavlee has quit [Ping timeout: 265 seconds]
yokel has quit [Ping timeout: 265 seconds]
foxxx0 has quit [Ping timeout: 265 seconds]
dhollinger has quit [Ping timeout: 265 seconds]
EvanR has quit [Ping timeout: 265 seconds]
yokel has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tabakhase has quit [Ping timeout: 265 seconds]
tabakhase has joined #ruby
dhollinger has joined #ruby
foxxx0 has joined #ruby
vasilakisfil has joined #ruby
imadper has quit [Remote host closed the connection]
<vasilakisfil> my rails app just hangs :/
idiocrash has quit [Quit: Textual IRC Client: www.textualapp.com]
<havenwood> vasilakisfil: HTTP/1.1 401 Unauthorized
<vasilakisfil> jesus I fucking hate dropbox
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.
<troydm> al2o3-cr: ic, thx
<al2o3-cr> troydm: np.
yokel has quit [Ping timeout: 240 seconds]
yokel has joined #ruby
nullus has joined #ruby
<s2013> https://repl.it/repls/WelltodoTerribleEmbeds anyone knows why which_fields is returning []
<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 has quit [Ping timeout: 256 seconds]
phaul has joined #ruby
akem_ is now known as akem
<phaul> &>> class Foo; def self.mod(a); @a = a; end; def self.which; @a; end; end; Foo.mod(13); Foo.which # s2013
<rubydoc> # => 13 (https://carc.in/#/r/8tcq)
<s2013> ok
<s2013> let me try
<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'?
_phaul has quit [Ping timeout: 256 seconds]
<phaul_> seems newarr = [] is slightly smaller internall code, probably slightly faster
<phaul_> &asm>> []
<rubydoc> I have disassembled your code, the result is at https://carc.in/#/r/8tcv
<phaul_> &asm>> Array.new
<rubydoc> I have disassembled your code, the result is at https://carc.in/#/r/8tcw
phaul has joined #ruby
<phaul> it has to be as this is valid although not good code: class Array; def initialize; raise 'boom!'; end; end; then Array.new should raise
<minall> I see. Thanks phaul!
<minall> THanks rubydoc
phaul_ has quit [Ping timeout: 265 seconds]
dhoc has joined #ruby
siery has joined #ruby
<siery> Why is ruby cuting last element of the string when it is a white space?
TomyWork has joined #ruby
<siery> I mean, I try to see if the last character in the matched string is a " "
<siery> So first I match the 'options string'
<siery> opt = (/[#{OPTIONS}]?[#{OPTIONS}]?[#{OPTIONS}]\s?/.match(pattern[2..4])).to_s
<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
<_phaul> &>> /../.match('a ').to_s
<rubydoc> # => "a " (https://carc.in/#/r/8tcx)
alfiemax_ has joined #ruby
<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
CrazyEddy has quit [Ping timeout: 240 seconds]
chalkmonster has quit [Quit: WeeChat 2.7.1]
<havenwood> &>> RubyVM::DEFAULT_PARAMS.fetch(:thread_vm_stack_size)
<rubydoc> # => 1048576 (https://carc.in/#/r/8tdl)
<havenwood> CommunistWolf: Time to increase the stack size? Heh.
CrazyEddy has joined #ruby
<havenwood> export RUBY_THREAD_VM_STACK_SIZE=2097152
<havenwood> CommunistWolf: I'm curious if it works with double the stack?
<CommunistWolf> that would require me to shuffle the profile between processes somehow. regenerating it is a right pain
gavlee has quit [Ping timeout: 265 seconds]
burningserenity has joined #ruby
<CommunistWolf> haha, the calltree file is 600MiB of html. firefox can't even. fortunately, callgrind format is sane
gavlee has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
KamLy has joined #ruby
^amra has quit [Read error: Connection reset by peer]
burningserenity has quit [Read error: Connection reset by peer]
postmodern has joined #ruby
chalkmonster has joined #ruby
BTRE has joined #ruby
burningserenity has joined #ruby
<siery> havenwood: Ya, I figured that out ^_^
Furai has quit [Remote host closed the connection]
Furai has joined #ruby
sysh has quit [Remote host closed the connection]
Rudd0 has quit [Ping timeout: 265 seconds]
chalkmonster has quit [Quit: WeeChat 2.7.1]
zacts has joined #ruby
iNs has quit [Ping timeout: 240 seconds]
electrostat has quit [Quit: uwotm8]
electrostat has joined #ruby
iNs has joined #ruby
<kaleido> NameError (uninitialized constant Net)
<kaleido> everytime i try to use Net::SSH
<kaleido> when i get done, i get that error :(
<siery> looks like the Net module is not defined, have you includet 'net/ssh'?
<kaleido> LoadError (cannot load such file -- net/ssh)
<kaleido> but i can load 'net'
bvdw has quit [Read error: Connection reset by peer]
<siery> gem install net-ssh?
bvdw has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
<kaleido> thanks, dunno why i thought it was built-in
kinduff has joined #ruby
<siery> You'w welcome c:
<siery> Hey guys, is there a way to escape an eval in ruby?
<havenwood> siery: Escape it for what?
<siery> file_list.insert(-1, do_search_names && search_names(pattern) || return)
<siery> but just return from the .insert block c:
zapata has quit [Ping timeout: 246 seconds]
<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.
<havenwood> &>> 'kaleido'.scan /[aeiou]+/
<rubydoc> # => ["a", "ei", "o"] (https://carc.in/#/r/8ted)
LDonoughe has quit [Ping timeout: 265 seconds]
<kaleido> adam12: yeah im trying to get a paste together of the output and what i want to check against.
chalkmonster has joined #ruby
zapata has quit [Ping timeout: 256 seconds]
chalkmonster has quit [Client Quit]
LDonoughe has joined #ruby
minall has quit [Quit: Konversation terminated!]
chalkmonster has joined #ruby
caterfxo has quit [Ping timeout: 260 seconds]
caterfxo has joined #ruby
caterfxo has quit [Ping timeout: 256 seconds]
caterfxo has joined #ruby
troulouliou_div2 has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7.1]
chalkmonster has joined #ruby
zapata has joined #ruby
<kaleido> way off topic but is it strange i sport wood very time i realize how easy i can do something in ruby?
chalkmonster has quit [Quit: WeeChat 2.7.1]
caterfxo has quit [Quit: leaving]
* _phaul googles sporting wood
chalkmonster has joined #ruby
<apotheon> kaleido: maybe a little
chalkmonster has quit [Client Quit]
<apotheon> _phaul: You don't want to do that.
<_phaul> now I know..
<apotheon> I'm sorry.
<apotheon> I wasn't quick enough to save you.
cockadopolous has joined #ruby
<apotheon> kaleido: I like Ruby, too, but evidently not as much as you.
burningserenity has quit [Remote host closed the connection]
zacts has quit [Quit: WeeChat 2.8]
kristian_on_linu has joined #ruby
caterfxo has joined #ruby
Arkantos has joined #ruby
LDonoughe has quit [Ping timeout: 260 seconds]
chalkmonster has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
IDGM5 has joined #ruby
<IDGM5> Morning everyone!
LDonoughe has joined #ruby
<IDGM5> What sites do you guys recommend to practice code challanges with ruby, besides hackerrank?
<_phaul> codewars?
<CommunistWolf> I use my job, it's kind of a bore :p
<IDGM5> hahaha
troulouliou_div2 has quit [Remote host closed the connection]
<IDGM5> I'll check codewars, thanks _phaul!
chalkmonster has quit [Read error: Connection reset by peer]
<apotheon> _phaul: Do you pronounce that like "foul"?
<havenwood> IDGM5: https://exercism.io/
roadie has quit [Ping timeout: 265 seconds]
<IDGM5> Thanks havenwood!!
cockadopolous has quit [Quit: leaving]
roadie has joined #ruby
roadie has quit [Ping timeout: 260 seconds]
gavlee has quit [Ping timeout: 265 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gavlee has joined #ruby
phaul has joined #ruby
Arkantos has quit [Ping timeout: 264 seconds]
<phaul> apotheon: no
<apotheon> How do you pronounce it, then?
<phaul> p-silent h-aul :)
_phaul has quit [Ping timeout: 250 seconds]
<phaul> btw my given name is paul, and phaul is a terrible nick.. But I chose it 20+ years ago, and now it feels weird to change it
<apotheon> . . . so "haul"?
<phaul> just pronounce it like paul. :)
<apotheon> okay
<apotheon> Oh, "p (silent H) aul"
<apotheon> I read that as "p-is-silent, haul".
<apotheon> Thanks.
<apotheon> Not knowing how it's pronounced was kinda bugging me.
dhoc has quit [Quit: dhoc]
manveru_ has joined #ruby
Hobbyboy has joined #ruby
elphe has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
TheMoonMaster_ has joined #ruby
Rudd0 has joined #ruby
EvilJStoker has quit [Killed (adams.freenode.net (Nickname regained by services))]
EvilJStoker has joined #ruby
aspiers has quit [*.net *.split]
Hobbyboy|BNC has quit [*.net *.split]
infernix has quit [*.net *.split]
Querens has quit [*.net *.split]
manveru has quit [*.net *.split]
michael_mbp has quit [*.net *.split]
bga57 has quit [*.net *.split]
mahlon has quit [*.net *.split]
mkaito has quit [*.net *.split]
e has quit [*.net *.split]
kreantos has quit [*.net *.split]
KrzaQ has quit [*.net *.split]
SegFaultAX has quit [*.net *.split]
themoonmaster has quit [*.net *.split]
seb_ has quit [*.net *.split]
ytti has quit [*.net *.split]
manveru_ is now known as manveru
emptyflask has joined #ruby
KrzaQ has joined #ruby
jerome___ has joined #ruby
Hobbyboy has quit [Quit: The BNC has broken!]
infernix has joined #ruby
jeromelanteri has quit [Ping timeout: 264 seconds]
jerome__ has joined #ruby
michael_mbp has joined #ruby
kreantos has joined #ruby
schne1der has quit [Ping timeout: 256 seconds]
jerome___ has quit [Ping timeout: 265 seconds]
robotmay has quit [Remote host closed the connection]
mahlon has joined #ruby
robotmay has joined #ruby
Spitfire_ has quit [Quit: ZNC 1.6.2 - http://znc.in]
s2013 has quit [Ping timeout: 260 seconds]
Spitfire has joined #ruby
Hobbyboy has joined #ruby
NODE has quit [Excess Flood]
SegFaultAX has joined #ruby
bga57 has joined #ruby
NODE has joined #ruby
aspiers has joined #ruby
zacts has joined #ruby
zlogan has quit [Ping timeout: 272 seconds]
LDonoughe has quit [Ping timeout: 256 seconds]
e has joined #ruby
dhoc has joined #ruby
IDGM5 has quit [Quit: Lost terminal]
Arkantos has joined #ruby
sergioro has quit [Quit: leaving]
cliluw has quit [Ping timeout: 240 seconds]
cliluw has joined #ruby
Arkantos has quit [Client Quit]
roadie has joined #ruby
roadie has quit [Read error: Connection reset by peer]
<siery> I have to swap words in a bunch files, what is a faster way then `file << file.gsub(content, phrase)`
<siery> I use ag to search for files, so I can simply provide the exact line that needs to be changed
dhoc has quit [Quit: dhoc]
drincruz_ has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 252 seconds]
Technodrome has joined #ruby
siery has quit [Quit: WeeChat 2.7.1]
NODE has quit [Quit: changing servers]
NODE has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
cliluw has quit [Ping timeout: 265 seconds]
cliluw has joined #ruby
LDonoughe has joined #ruby
ur5us has joined #ruby
LDonoughe has quit [Ping timeout: 240 seconds]