xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
baojg_ has quit [Remote host closed the connection]
baojg has joined #ruby
skx86 has quit [Quit: Connection closed for inactivity]
elphe has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
maidhc_ has joined #ruby
maidhc_ has quit [Ping timeout: 240 seconds]
mikhailnovikov has joined #ruby
mikhailnovikov has quit [Client Quit]
vondruch has quit [Quit: vondruch]
<al2o3-cr>
adam12: i initially thought it might be pryrc interfering but i've temporarily suppressed both and the same behaviour happens.
vondruch has joined #ruby
mossplix has quit [Remote host closed the connection]
imode has quit [Ping timeout: 260 seconds]
oddp_ has joined #ruby
mossplix has joined #ruby
<al2o3-cr>
adam12: binding.irb works flawlessly, binding.pry with next/step jumps to '/usr/lib/ruby/2.7.0/forwardable.rb:229' => 229: #{accessor} @ this line always. puzzled to say the least.
mossplix has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
vondruch has quit [Remote host closed the connection]
vondruch has joined #ruby
AlwaysInTime has joined #ruby
dfucci has joined #ruby
ur5us has joined #ruby
ur5us has quit [Client Quit]
konsolebox has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
konsolebox has joined #ruby
ruurd has joined #ruby
mossplix has joined #ruby
dionysus69 has joined #ruby
Tempesta_ has quit [Quit: See ya!]
Tempesta has joined #ruby
baojg has quit [Remote host closed the connection]
dfucci_ has joined #ruby
baojg_ has joined #ruby
rkoller has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
rkoller has quit [Client Quit]
schne1der has quit [Ping timeout: 265 seconds]
dfucci_ has quit [Ping timeout: 240 seconds]
MrCrackPot has joined #ruby
hkais has joined #ruby
hkais has left #ruby [#ruby]
MrCrackPot has quit [Quit: Leaving]
twe4ked has quit [Ping timeout: 256 seconds]
sagax has quit [Read error: Connection reset by peer]
twe4ked has joined #ruby
mossplix has quit [Ping timeout: 246 seconds]
Besnik_b has joined #ruby
Besnik_b has quit [Client Quit]
dualfade has quit [Ping timeout: 264 seconds]
dualfade has joined #ruby
MrCrackPot has joined #ruby
baojg_ has quit [Remote host closed the connection]
TvL2386 has quit [Quit: leaving]
troulouliou_dev has joined #ruby
TvL2386 has joined #ruby
baojg has joined #ruby
Mia has quit [Read error: Connection reset by peer]
<TvL2386>
hey all, I just found out that [nil].empty? is false and [nil].any? is false as well
<TvL2386>
did not expect that
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
markoong has joined #ruby
<leftylink>
what is there to say in response to that other than "yes, what you have just said is the case, and both things are expected" ?
<TvL2386>
There's nothing to say, it wasn't a question. I was just really surprised and thought maybe someone in here reading it would learn something as well like I did.
<TvL2386>
Maybe shouldn't have started with "hey all"
<TvL2386>
I'm sorry
<yxhuvud>
any? simply go through the enumerable and checks if any element is true. Which nil is not.
<leftylink>
ah, good. I had to ask because a lot of the time no question will be stated, but the person actually had a question
<leftylink>
but in this case since there was no question, all is good
<TvL2386>
thx leftylink, my mistake, I should have been more clear
alfiemax has quit [Remote host closed the connection]
<leftylink>
I was worried that my statement might have seemed too passive-aggressive. I think it would have been better if I had instead asked "indeed, are there any questions and/or can we explain this for you"
<TvL2386>
I must admit that I took it as passive-aggressive yes :)
<leftylink>
ah.
<TvL2386>
But no worries :)
<leftylink>
I'll learn from that and be clearer in the future
<TvL2386>
Well, good to see my eye-opener, and wanting to share, did lead to something positive :p
lmat has quit [Ping timeout: 264 seconds]
Mia has quit [Read error: Connection reset by peer]
markong has joined #ruby
markoong has quit [Ping timeout: 258 seconds]
lmat has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
ur5us has quit [Ping timeout: 260 seconds]
<pwnd_nsfw>
TvL2386 what if you have multiple nil items in an array?
<pwnd_nsfw>
That's false as well
xco has joined #ruby
<pwnd_nsfw>
TvL2386 I guess 'cause any without a block checks to see if there's any truthy elements in it
<pwnd_nsfw>
of which nil is not
<pwnd_nsfw>
word
<TvL2386>
pwnd_nsfw: yes you are correct. I just mistakenly always thought any? was the same as !empty?
<pwnd_nsfw>
That's what I thought when you brought up the idea
<TvL2386>
:)
<pwnd_nsfw>
yxhuvud had said it already :x
<TvL2386>
yep, it's totally clear now. any? is very powerful, I should use it (correctly) more
<pwnd_nsfw>
well
<pwnd_nsfw>
any? { |elem| elem.nil? } is correct
<pwnd_nsfw>
:p
<TvL2386>
lol
<TvL2386>
but it's not the same as any? { |elem| !!elem }
<pwnd_nsfw>
Not at all, for sure
<TvL2386>
I made no sense, nm :)
<TvL2386>
[nil].any?(NilClass)
<TvL2386>
that also works!
<pwnd_nsfw>
any?(&:nil?)
<TvL2386>
yep
<leftylink>
I haven't used patterned any? (or all?, none?, one?) yet, that I can remember. I thought "this is cool!" when it was introduced in 2.5, just hadn't gotten a chance yet
exmortus has quit [Ping timeout: 260 seconds]
<pwnd_nsfw>
have you just not written any ruby since? lol
<pwnd_nsfw>
I keep forgetting a lot of the convenience is there
<leftylink>
even though I used any and all many times, I never had an occasion to pass them patterns
<pwnd_nsfw>
ah, understood
ursuta has joined #ruby
ursuta has quit [Max SendQ exceeded]
<leftylink>
oh... actually, searching through some recent code, I've missed soem easy opportunities to do so...
<TvL2386>
doing `grep -r 'any?' app in my rails root... Same here, It's actually only used to test if an Enumerable has any values... And that's where I went wrong. I thought any? was !empty?
<leftylink>
I have a few instances of any? { |x| range.cover?(x) } which I should instead write as any?(range)
darkstardevx has joined #ruby
<TvL2386>
nice :)
<leftylink>
so uh I guess I just forgot that that exists
bsdbandit-01 has joined #ruby
schne1der has joined #ruby
<TvL2386>
I'm now looking at this rails code @user.errors.any? and knowing what any? does now, I don't like it anymore
donofrio has joined #ruby
drincruz has joined #ruby
<TvL2386>
I shouldn't complain. Of course it's not an Array :S
<TvL2386>
talking about cool methods not being used: how about :tap ?
cgfbee has quit [Remote host closed the connection]
wildtrees has joined #ruby
<leftylink>
I sometimes feel "insecure" in how I use it, by which I mean that I worry that the code will be judged to be unclear. often I use it to replace something like `x = figure_it_out; side_effect; x` with `figure_it_out.tap { side_effect }`
<leftylink>
though I can't recall many instances where I put that insecurity to the test
<leftylink>
and see whether people actually think it's unclear
<TvL2386>
Yeah I understand
cgfbee has joined #ruby
<TvL2386>
I'm doing something here that I'm also not to sure about. My method needs to return an Array but has many if statements which may add items to the array. Weird business logic. So to not forget about returning an Array, I just wrapped the entire method body in [].tap { |items| .... }
<TvL2386>
it works, not very pretty though
alfiemax has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
code_zombie has joined #ruby
<leftylink>
for that sometimes I would do it like
<leftylink>
&>> [(1 if true), (2 if false), (3 if true)].compact
<leftylink>
I suppose this is not good if the conditions get too long though
<leftylink>
I'm happy to put each element on its own line, but if the conditions also require multiple lines I'm not sure I can possibly make that look good
<TvL2386>
wouldn't work for my case, but that's interesting code though
baojg has quit [Remote host closed the connection]
baojg_ has joined #ruby
<pwnd_nsfw>
ruby is great lol
<rapha>
hi all
Garb0 has joined #ruby
roshanavand__ has quit [Ping timeout: 240 seconds]
jhill has quit []
drincruz has joined #ruby
jhill has joined #ruby
ec has quit []
ec has joined #ruby
impermanence has joined #ruby
alfiemax has quit [Remote host closed the connection]
Garb0 has quit [Remote host closed the connection]
<rapha>
hmm
<rapha>
can ruby Marshal _any_ object, no matter how complex?
strmpnk has quit []
strmpnk has joined #ruby
<leah2>
>> Marshal.dump(STDIN)
<leah2>
&>> Marshal.dump(STDIN)
<rubydoc>
stderr: -e:4:in `dump': can't dump IO (TypeError)... check link for more (https://carc.in/#/r/9fal)
englishm has quit []
englishm has joined #ruby
xco has quit [Read error: Connection reset by peer]
ctOS has quit []
ctOS has joined #ruby
TCZ has joined #ruby
<rapha>
hmmm
<rapha>
okay
<rapha>
:P
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
Mia has quit [Read error: Connection reset by peer]
wildtrees_ has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
wildtrees has quit [Ping timeout: 240 seconds]
dfucci has joined #ruby
baojg_ has quit [Remote host closed the connection]
<micah>
adam12: ah, i think i see the issue, the 'slot' variable is not changing, its just the last one determined each time
<micah>
i need to iterate over each slot, i thought that devices[slot][splitted[0].chop] = splitted[1].chomp would make it so the devices hash was keyed on the slot, and then devices.each_key do |a| would iterate over each of those slots
TomyWork has quit [Remote host closed the connection]
<micah>
yeah, ok, i see it now, thanks for rubber ducking :D
<adam12>
:)
<al2o3-cr>
adam12: awesome! i really like this simple debugger, i'm glad you mentioned it up yesterday :)
<adam12>
micah: if you're accepting improvement suggestions, I think I might have two at least.
Mia has quit [Read error: Connection reset by peer]
xco has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
skx86 has joined #ruby
dionysus70 has joined #ruby
dionysus69 has quit [Ping timeout: 265 seconds]
dionysus70 is now known as dionysus69
Genadi has quit [Remote host closed the connection]
<micah>
adam12: this is the latest, seems to work, so any improvements, i'm interested: https://dpaste.org/gYne
sagax has joined #ruby
pwnd_nsfw has quit [Remote host closed the connection]
pwnd_nsfw has joined #ruby
Esa__ has joined #ruby
schne1der has quit [Ping timeout: 256 seconds]
<adam12>
micah: My first suggestion is to eagerly skip loops instead of using an if statement that covers the entire loop.
<adam12>
micah: So where you if not line =~ /^$/ then a huge block, I'd go `next if line =~ /^$/` then get rid of the if/end part. If it's an empty line, move on. If not, evaluate rest of the block.
<adam12>
micah: My second suggestion would be to split on ":\t", and give names to the return values. attribute, value = line.split(":\t", 2)
<adam12>
micah: Then anywhere you use splitted[0], it's attribute, and where you use splitted[1], it's value. No chopping necessary (tho you might need to chomp newlines).
<adam12>
micah: you could even chomp early, before splitting. attribute, value = line.chomp.split(":\t", 2)
<micah>
if I get you right, you mean like this: https://dpaste.org/Z19O ? Or are you saying I can remove some more chomps?
<adam12>
micah: you can get rid of all chomps except the one on the split line, if you wanted.
<adam12>
micah: now of course, attribute is going to be "Slot" not "Slot:" so you can do a regular if. `if attribute == "Slot"`
<micah>
right
<adam12>
micah: you shouldn't need value[1] either, unless you want the first character of a String.
<micah>
adam12: oh, you mean just replace value[1] with value
<adam12>
micah: Right. attribute and value are usable as-is. No chomping, no chopping, no subarray needed. Just use it as it was the real value you cared about.
<micah>
this is definitely much cleaner
manveru has quit []
manveru has joined #ruby
mossplix has quit [Remote host closed the connection]
<adam12>
micah: where you call `#select {}[0]`, you can just use `find` or `detect` here. It will return the first value (or nil). `find` and `detect` are the same (one is an alias for the other) so you can use whichever one reads nicer to you.
vondruch has quit [Quit: vondruch]
cthu| has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<adam12>
micah: Dir includes the Enumerable module, so you can even drop `entries` and just call `find` or `detect` after your call to `glob`.
<micah>
adam12: do you mean I can just replace 'select' with 'find' and remove the [0]? so it is: device = Dir.entries("/sys/bus/pci/devices/#{a}/net").find {|f| !File.directory? f} + "," + device
<adam12>
Oh, nevermind, you call entries with a glob.
<adam12>
micah: Yep, that looks right.
arzWZM has quit [Ping timeout: 256 seconds]
arzWZM has joined #ruby
mossplix has joined #ruby
kozowu has quit []
kozowu has joined #ruby
CrazyEddy has quit [Ping timeout: 246 seconds]
impermanence has quit [Quit: Connection closed]
parallels has joined #ruby
CustosLimen has quit []
MrCrackPot has quit [Quit: Leaving]
CustosLimen has joined #ruby
vondruch has joined #ruby
Mia has quit [Ping timeout: 240 seconds]
parallels has quit [Ping timeout: 256 seconds]
alex_ has joined #ruby
TCZ has joined #ruby
orbyt_ has joined #ruby
duckpupp- has joined #ruby
duckpuppy has quit [Ping timeout: 244 seconds]
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
lmat has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 265 seconds]
alex_ has quit [Quit: leaving]
ChmEarl has joined #ruby
lmat has joined #ruby
mossplix has quit [Remote host closed the connection]
_aeris_ has quit [Ping timeout: 240 seconds]
_aeris_ has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
lmat has quit [Ping timeout: 246 seconds]
alexherbo2 has joined #ruby
cthu| has quit [Read error: Connection reset by peer]
cthu| has joined #ruby
lmat has joined #ruby
xco has joined #ruby
TomyWork has quit [Remote host closed the connection]
TCZ has quit [Quit: Leaving]
al2o3-cr has quit [Quit: WeeChat 2.8]
al2o3-cr has joined #ruby
alexherbo2 has quit [Ping timeout: 240 seconds]
gray_-_wolf has joined #ruby
chalkmonster has joined #ruby
cthu| has quit [Read error: Connection reset by peer]
cthu| has joined #ruby
lmat has quit [Ping timeout: 256 seconds]
lmat has joined #ruby
cd has joined #ruby
mossplix has joined #ruby
postmodern has quit [Quit: Leaving]
ellcs has joined #ruby
venmx has quit [Quit: leaving]
<micah>
adam12: hum, it seems that now I dont have a key 'Vendor'
<micah>
i think its because it is Vendor:\t
<micah>
it looks like \nClass:\t0300\nVendor:\t1a03\nDevice:\t2000\nSVendor:\t15d9\nS
<micah>
oh strange, when I look at devices its cut off: {"0000:00:00.0"=>{"Clas"=>"0600", "Vendo"=>"8086", "Devic"=>"0c08", "SVendo"=>"15d9", "SDevic"=>"0811", "Re"=>"06"},
<micah>
ah I think i had an additional chop to get rid of
alexherbo2 has joined #ruby
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
konsolebox has quit [Read error: Connection reset by peer]
Lewix has quit []
Lewix has joined #ruby
AlwaysInTime has quit [Ping timeout: 240 seconds]
konsolebox has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gavlee has quit [Remote host closed the connection]
gavlee has joined #ruby
bocaneri has quit [Remote host closed the connection]
AlwaysInTime has joined #ruby
greypack has quit [Read error: Connection reset by peer]
greypack_1 has joined #ruby
gavlee has quit [Remote host closed the connection]
gavlee has joined #ruby
AlwaysInTime has quit [Ping timeout: 256 seconds]
gavlee has quit [Max SendQ exceeded]
gavlee has joined #ruby
xco has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
drincruz has quit [Ping timeout: 256 seconds]
bsdbandit-01 has joined #ruby
<apteryx>
hello! Shouldn't the Time class obey SOURCE_DATE_EPOCH, for reproducible builds?
<apteryx>
e.g., if the SOURCE_DATE_EPOCH environment variable is set, Time.now would return whatever static value was set to SOURCE_DATE_EPOCH.