havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.0, 2.5.3, 2.4.5: 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!
crankharder has joined #ruby
phaul has joined #ruby
Tempesta has quit [Quit: AdiIRC is updating to v3.3 Beta Build (2018/12/26 UTC) 64 Bit]
Tempesta has joined #ruby
bmurt has joined #ruby
rubydoc has joined #ruby
jottr has joined #ruby
hutch has quit [Ping timeout: 246 seconds]
hutch has joined #ruby
tdy has joined #ruby
mikecmpbll has joined #ruby
jottr has quit [Ping timeout: 272 seconds]
hutch has quit [Ping timeout: 246 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
GodFather has quit [Ping timeout: 258 seconds]
conta has joined #ruby
polishdub has quit [Quit: leaving]
uplime has joined #ruby
conta has quit [Ping timeout: 250 seconds]
Renich has quit [Ping timeout: 250 seconds]
jottr has joined #ruby
tdy has quit [Ping timeout: 272 seconds]
Renich has joined #ruby
profetes has quit [Ping timeout: 244 seconds]
NingaLeaf has joined #ruby
NingaLeaf has quit [Client Quit]
Aqo has quit [Quit: ChatZilla 0.9.92-rdmsoft [XULRunner 35.0.1/20150122214805]]
Renich has quit [Remote host closed the connection]
Renich has joined #ruby
davidw_ has quit [Ping timeout: 246 seconds]
jottr has quit [Ping timeout: 246 seconds]
nowhere_man has joined #ruby
cthulchu_ has quit [Remote host closed the connection]
cthulchu_ has joined #ruby
cthulchu_ has quit [Ping timeout: 246 seconds]
rkazak has joined #ruby
comet23 has quit [Quit: Connection closed for inactivity]
Ookma-Kyi has joined #ruby
uplime has quit [Quit: WeeChat 2.2]
Ookma-Kyi has quit [Ping timeout: 240 seconds]
chouhoulis has joined #ruby
\void has quit [Quit: So long, and thanks for all the fish.]
spacesuitdiver has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gix has quit [Ping timeout: 258 seconds]
Ookma-Kyi has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
mikecmpbll has quit [Quit: inabit. zz.]
Nicmavr has joined #ruby
Ookma-Kyi has quit [Read error: Connection reset by peer]
Ookma-Kyi has joined #ruby
orbyt_ has joined #ruby
uplime has joined #ruby
hutch has joined #ruby
lightstalker has quit [Ping timeout: 250 seconds]
lightstalker has joined #ruby
esrse has joined #ruby
dviola has joined #ruby
davidw_ has joined #ruby
Ookma-Kyi has quit [Ping timeout: 250 seconds]
AJA4350 has quit [Remote host closed the connection]
stryek has quit [Quit: Connection closed for inactivity]
tdy has joined #ruby
RougeR has quit [Ping timeout: 258 seconds]
dviola has quit [Quit: WeeChat 2.3]
evdubs_ has quit [Ping timeout: 268 seconds]
evdubs has joined #ruby
jottr has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jottr has quit [Ping timeout: 258 seconds]
masterasia has joined #ruby
hutch has quit [Ping timeout: 250 seconds]
cd has quit [Quit: cd]
davidw_ has quit [Ping timeout: 272 seconds]
cd has joined #ruby
crankhar1er has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
crankhar1er has quit [Ping timeout: 245 seconds]
elcontrastador has quit [Quit: Textual IRC Client: www.textualapp.com]
hutch has joined #ruby
Renich has quit [Quit: Renich]
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Renich has joined #ruby
Renich has quit [Read error: Connection reset by peer]
Renich has joined #ruby
crankhar1er has joined #ruby
hutch has quit [Ping timeout: 272 seconds]
\void has joined #ruby
crankhar1er has quit [Ping timeout: 240 seconds]
\void has quit [Client Quit]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hutch has joined #ruby
crankhar1er has joined #ruby
sanscoeu_ has joined #ruby
orbyt_ has joined #ruby
crankhar1er has quit [Ping timeout: 246 seconds]
sanscoeur has quit [Ping timeout: 245 seconds]
sanscoeu_ has quit [Ping timeout: 250 seconds]
Mike11 has quit [Quit: Leaving.]
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
chouhoulis has quit [Remote host closed the connection]
comet23 has joined #ruby
<comet23> how would i create a new hash value?
<comet23> this is what i'm trying :/
mozzarella has joined #ruby
<mozzarella> so
<mozzarella> how do you make a deep copy of an array?
<comet23> you don't]
<mozzarella> why not?
<Radar> comet23: use each_with_object, passing it a Hash where the default value for all keys in the hash is zero.
<Radar> >> h = Hash.new(0); h["a"]
<ruby[bot]> Radar: # => 0 (https://eval.in/1074344)
<comet23> mozzarella: sorry i wasn't replying to you
<comet23> i hit the wrong window :(
<Radar> Your issue is because your hash doesn't have that key set to any particular value.
<Radar> mozzarella: input and expected output plzkthx
<Radar> ?mcve
<ruby[bot]> Radar: I don't know anything about mcve
<Radar> ruby[bot]: you never do.
<comet23> i'm not setting it on line 6 Radar ?
<Radar> ?mcve
<ruby[bot]> Please provide a Minimal, Complete, and Verifiable example: https://stackoverflow.com/help/mcve
<Radar> comet23: only if the entire hash is empty.
<comet23> ae_chars = {}
<Radar> I just updated my example to remove the if statement entirely.
<comet23> ae_chars.empty? # => true
davidw_ has joined #ruby
<Radar> comet23: yeah, but then you find the first character, increase the count for that and then what happens to ae_chars?
<Radar> comet23: is it then empty?
<comet23> oh
<comet23> !ae_chars[char]
<comet23> ?
tiff has joined #ruby
<comet23> Radar: you're a genius!
<comet23> thank you so much :D
<Radar> comet23: you're too kind
<comet23> mozzarella: look into this https://rubygems.org/gems/ruby_deep_clone
cd has quit [Quit: cd]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
davidw_ has quit [Ping timeout: 272 seconds]
orbyt_ has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
memofun has joined #ruby
sauvin has joined #ruby
<memofun> hi, im learning ruby. Im using IRB, when i execute this code 2.times {"hello"}, why at the end shows =>2
<WA9ACE> are you wanting to see the world "hello" printed to the screen?
<WA9ACE> word*
<memofun> WA9ACE: yes, it shows the word hello 2 ties, but then shows =>2. What is the meaning of that
jottr has joined #ruby
<havenwood> memofun: Integer#yield returns self when a block is provided. So it just returns the integer you call it on.
<WA9ACE> that's the return type of the iterator
<Radar> memofun: When you call the times function on Ruby, it will evaluate the block that number of times. The function then returns itself.
<WA9ACE> what memofun said
<Radar> itself -> the object you called the function on
<havenwood> memofun: Try: 2.times.map {"hello"}
<WA9ACE> that will return an array with 2 strings of "hello"
<WA9ACE> instead of the number 2
<memofun> WA9ACE: havenwood thank you. Learning
<memofun> can you recommend a good tutorial to learn ruby?, my intention is to learn Ruby on Rails.
mr_rich101 has quit [Quit: ZNC - http://znc.in]
houhoulis has joined #ruby
jottr has quit [Ping timeout: 244 seconds]
<havenwood> memofun: Did you see the links I posted to you earlier?
mr_rich101 has joined #ruby
<havenwood> memofun: The Rails docs are great to read once you've learned some Ruby.
<memofun> havenwood: no, can you share again please
<havenwood> memofun: Check here in the logs: https://freenode.irclog.whitequark.org/ruby/2019-01-03#23806605;
<memofun> havenwood: thank you
<havenwood> memofun: np
code_zombie has quit [Quit: Leaving]
houhoulis has quit [Remote host closed the connection]
hutch has quit [Ping timeout: 258 seconds]
hutch has joined #ruby
Ookma-Kyi has joined #ruby
Ookma-Kyi has left #ruby [#ruby]
hell0h0la has joined #ruby
<hell0h0la> hi
cnsvc has joined #ruby
patteh has quit [Ping timeout: 250 seconds]
patteh has joined #ruby
Guest5049 has quit [Quit: WeeChat 2.3]
al2o3-cr has joined #ruby
<havenwood> hell0h0la: hi
<al2o3-cr> &>> nh = {a:{b:{c:{d:{e:42}}}}}; hold = []; Marshal.load Marshal.dump(nh), -> v { hold << v; v }; hold.each &:freeze
<rubydoc> # => [:a, :b, :c, :d, :e, 42, {:e=>42}, {:d=>{:e=>42}}, {:c=>{:d=>{:e=>42}}}, {:b=>{:c=>{:d=>{:e=>42}}}}, ...check link for more (https://carc.in/#/r/5x1y)
akaiiro3 has joined #ruby
akaiiro has quit [Ping timeout: 246 seconds]
conta has joined #ruby
hell0h0la has quit [Read error: Connection reset by peer]
rkazak has quit [Quit: Sleep.....ing....]
rippa has joined #ruby
memofun has quit [Read error: Connection reset by peer]
_whitelogger has quit [Ping timeout: 250 seconds]
_whitelogger has joined #ruby
themsay has joined #ruby
themsay has quit [Read error: Connection reset by peer]
mutantkeyboard has quit [Remote host closed the connection]
themsay has joined #ruby
themsay has quit [Read error: Connection reset by peer]
LadyElusive has joined #ruby
themsay has joined #ruby
patteh has quit [Ping timeout: 245 seconds]
aupadhye has joined #ruby
themsay has quit [Read error: Connection reset by peer]
themsay has joined #ruby
jottr has joined #ruby
hutch has quit [Ping timeout: 258 seconds]
code_zombie has joined #ruby
jottr has quit [Ping timeout: 250 seconds]
themsay has quit [Remote host closed the connection]
themsay has joined #ruby
patteh has joined #ruby
aufi has joined #ruby
reber has joined #ruby
akaiiro3 has quit [Remote host closed the connection]
status402 has joined #ruby
patteh has quit [Ping timeout: 250 seconds]
patteh has joined #ruby
ruskie has quit [Ping timeout: 260 seconds]
status402 has quit [Read error: Connection reset by peer]
status402 has joined #ruby
dellavg_ has joined #ruby
patteh has quit [Ping timeout: 250 seconds]
ruskie has joined #ruby
patteh has joined #ruby
reber has quit [Remote host closed the connection]
Inline has quit [Quit: Leaving]
clemens3 has joined #ruby
Puffball has quit [Remote host closed the connection]
Davey has joined #ruby
<baweaver> Woo, put everything from 2018 together - https://medium.com/@baweaver/2018-in-review-3f619f26baca
SeepingN has joined #ruby
snatcher has joined #ruby
snatcher has left #ruby [#ruby]
themsay has quit [Ping timeout: 246 seconds]
uplime has quit [Quit: WeeChat 2.2]
<comet23> i am having the hardest time grasping recursion
<comet23> what i don't understand is why is it not returning 1 at the end
<status402> comet23: What the function is doing is essentially to keep running itself until some condition is met. That means that the 1 is just part of the "whole result", if that at all makes sense.
<comet23> no it doesn't
<comet23> it doesn't because it breaks my understanding of ruby returning the last thing that's evaluated
discopatrick has joined #ruby
mutantkeyboard has joined #ruby
<phaul> comet23 fwiw that method works fine here
jottr has joined #ruby
<status402> comet23: It actually is returning the last thing that's evaluated, but 1 isn't that.
<comet23> how is it not 1??
<status402> You start out by asking your function "is my number, n equal to 1?", which it's not so you multiply n by the result of calling your function yet again, this time with 4.
vondruch has joined #ruby
<status402> This continues until n actually is 1, at which point you start to gather up all the results of your function calls, so what you really have is a kind of pyramid shape of function calls.
<status402> I'd be making a lot more sense if I could draw this, honestly.
mikecmpbll has joined #ruby
profetes has joined #ruby
tdy has quit [Ping timeout: 250 seconds]
<status402> comet23: https://lucasfcosta.com/assets/factorial-calls.png is actually a much simpler way to visualize it than I had in mind. It shows you sort of the order of the calls.
<mutantkeyboard> Do you guys use Ruby for anything other than Rails?
aupadhye is now known as aupadhye|brb
aupadhye|brb is now known as aupadhye
<comet23> thank u
Aqo has joined #ruby
<TheBrayn> mutantkeyboard: I'm using it for Puppet and general scripting
<TheBrayn> I haven't done much web development with it at all
profetes has quit [Ping timeout: 250 seconds]
lxsameer has joined #ruby
<phaul> mutantkeyboard: also inside the field of Ruby web development some ppl migrate to newer frameworks which either better fit how web development is changing, like sinatra, with single page apps or microservies, or have a cleaner design but still MVC like hanami.
<mutantkeyboard> paul I've used haa
<mutantkeyboard> hanami
<mutantkeyboard> But was more like a general question. I come from a lower-level development (C++ middleware services), and just decided to replace the previous Python glue code with Ruby, so that's where the question comes from
cnsvc has quit [Ping timeout: 256 seconds]
mutantkeyboard has quit []
code_zombie has quit [Quit: Leaving]
fmccann has quit [Ping timeout: 250 seconds]
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
tiff has joined #ruby
status402 has quit [Read error: Connection reset by peer]
status402 has joined #ruby
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
_whitelogger has joined #ruby
garyserj has joined #ruby
esrse has quit [Quit: 안녕히계세요~]
comet23 has quit [Quit: Connection closed for inactivity]
status402 has quit [Quit: status402]
status402 has joined #ruby
garyserj has quit [Quit: garyserj]
adac has joined #ruby
bak1an has joined #ruby
<adac> Hi there! Is there a method to get an array out of a simple regex such as for example: (string1|string2|string3)?
status402 has quit [Read error: Connection reset by peer]
status402_ has joined #ruby
<canton7> adac, give us some sample input and sample output?
<adac> canton7, actually the regex is simply: (string1|string2|string3) and the output would be simply: [string1, string2, string3] I know I could remove chars and simply split but maybe there is a direct method that is used for such things?
status402_ has quit [Quit: status402_]
status402 has joined #ruby
sonikspin has joined #ruby
<canton7> what's the input?
AJA4350 has joined #ruby
status402 has quit [Read error: Connection reset by peer]
status402 has joined #ruby
<adac> canton7, the imput is this regex string: (string1|string2|string3)
status402 has quit [Read error: Connection reset by peer]
status402 has joined #ruby
<up|ime> adac : and the string you're matching?
<canton7> you have two inputs: the regex, and the string the regex is applied to. You've only given us one of those two
<phaul> i think adac wants to interpret regexp as a string. regexp is not matched but rather is the data
<adac> yes from the regex I'd like to export the strings to an array
<adac> the 3 strings in that regex should become an array
<adac> of 3 items
<adac> 3 strings
<phaul> well, #to_s and #scan
<canton7> or something like 's[1..-2].split('|')' . Depends how much you want to check that the input is well-formed
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<phaul> to_s seems to insert some junk.. so be careful. that aside why would you want to do this
<phaul> &>> /(a|b|c)/.to_s
<rubydoc> # => "(?-mix:(a|b|c))" (https://carc.in/#/r/5x50)
* canton7 has written regexes to parse regexes more times than he would have liked
<phaul> I think parsing regexes with regexes falls into the same category as parsing anything complex like html with regexes. simply dont
<adac> thanks for the hints!
<phaul> well, this might be an xy thing, you havent told us why you are doing such a thing
<phaul> ?xy
<ruby[bot]> it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
kapil____ has quit [Quit: Connection closed for inactivity]
<adac> I think the solution to my issue is probably not to use regex in first place but define an array instead for such a simply case
<adac> I first was thinkink I cannot validate an array in ruby on rails
<adac> so I awanted to use a regex for validation
<up|ime> if you're dealing with forms they can send arrays of data and/or json post bodies
<adac> kk
szulak_ has joined #ruby
masterasia has joined #ruby
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Sembei has quit [Ping timeout: 240 seconds]
status402 has quit [Ping timeout: 250 seconds]
Fusl has quit [Remote host closed the connection]
bmurt has joined #ruby
Fusl has joined #ruby
sandelius has joined #ruby
<sandelius> Hello everyone
<phaul> hi sandelius
<phaul> I heard it was windy over there, how are you holding up
kapil____ has joined #ruby
catbusters has joined #ruby
<catbusters> Hi
<sandelius> phaul I live in the south so it sure was windy but not that bad like other countries have it sometimes.
<catbusters> Are example 1 and 2 equivalent? https://bpaste.net/show/713caf53d909
<sandelius> yes
Inline has joined #ruby
<sandelius> catbusters { are mostly used when doing one-liner blocks
rawrg has joined #ruby
<catbusters> Ok. Getting a bit confused as I'm from JS land and the lack of braces and parens is putting me off balance
<phaul> equivalent but parser precedences might differ, you might need () around expressions to force the parser
<phaul> sometimes direct search and replace fails
<sandelius> catbusters try to wrap your head arounf that do/end is used for multi-line blocks and {/} for one-liners
<catbusters> Alright
<catbusters> And are these two examples also the same? https://bpaste.net/show/4be5bd06866f
<sandelius> yepp
rawrg has quit [Remote host closed the connection]
<catbusters> What's the resources block inside the scope block? I mean, it looks like calling a function inside another function
<catbusters> Sorry for the noob questions
<sandelius> catbusters it's exactly that tho your're calling a method from the scoped context
<sandelius> it kinda works the same way as jsvascript
agent_white has joined #ruby
<catbusters> So I'd be able to define multiple resources blocks inside the scope block?
<jhass> sure, picture blocks as anonymous functions
<phaul> hi, jhass, sorry for jumping on you as soon as you appear :) can you please update carc.in to 2.6 for our bot, when you have time? (in your own time, no rush)
<jhass> as soon as it's out of testing @ https://www.archlinux.org/packages/extra/x86_64/ruby/
<jhass> that is if that happens tomorrow, will be without laptop for the week after
<phaul> ah, cool, thanks
crankhar1er has joined #ruby
crankhar1er has quit [Client Quit]
crankharder has quit [Quit: leaving]
crankharder has joined #ruby
conta has quit [Ping timeout: 258 seconds]
dviola has joined #ruby
crankharder has quit [Ping timeout: 250 seconds]
krawchyk has joined #ruby
sonikspin has quit [Remote host closed the connection]
h0h0h0 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Puffball has joined #ruby
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NingaLeaf has joined #ruby
Dbugger has joined #ruby
clemens3 has quit [Quit: WeeChat 2.1]
clemens3 has joined #ruby
polishdub has joined #ruby
tdy has joined #ruby
ua_ has quit [Ping timeout: 250 seconds]
comet23 has joined #ruby
<comet23> how do you create a new array with ordered nums?
<comet23> if x is 5 1...x => [1,2,3,4,5]
<comet23> or do you have to create a new array and iterate over it and append the current number into the array?
<mozzarella> (1..5).to_a
<mozzarella> > (1..5).to_a
<mozzarella> >> (1..5).to_a
<ruby[bot]> mozzarella: # => [1, 2, 3, 4, 5] (https://eval.in/1074629)
<mozzarella> comet23: is that what you want?
<comet23> yyeah
<comet23> thank you :D
<mozzarella> np
postmodern has quit [Quit: Leaving]
<phaul> ruby[bot] , welcome back among the living!
<phaul> >> RUBY_VERSION
<ruby[bot]> phaul: # => "2.3.0" (https://eval.in/1074630)
hiroaki has joined #ruby
conta has joined #ruby
Rapture has joined #ruby
vikaton has joined #ruby
ua has joined #ruby
rubydoc has quit [Ping timeout: 250 seconds]
phaul has quit [Ping timeout: 246 seconds]
aupadhye has quit [Quit: Leaving]
spacesuitdiver has joined #ruby
phaul has joined #ruby
lucasb has joined #ruby
clemens3 has quit [Ping timeout: 272 seconds]
ua has quit [Quit: Leaving]
chouhoulis has joined #ruby
aufi has quit [Remote host closed the connection]
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
adac has quit [Ping timeout: 250 seconds]
ua has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
profetes has joined #ruby
catbusters has quit [Quit: Connection closed for inactivity]
NingaLeaf has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
maryo has joined #ruby
<dviola> nice to see 2.6.0 is out
uplime has joined #ruby
\void has joined #ruby
despai has joined #ruby
tiff has joined #ruby
davidw_ has joined #ruby
agent_white has quit [Ping timeout: 258 seconds]
reber has joined #ruby
hutch has joined #ruby
profetes has quit [Quit: Leaving]
blaguvest has joined #ruby
despai has quit [Ping timeout: 246 seconds]
chouhoulis has quit [Remote host closed the connection]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
mikecmpbll has quit [Ping timeout: 258 seconds]
orbyt_ has joined #ruby
cthulchu_ has joined #ruby
agent_white has joined #ruby
rubydoc has joined #ruby
despai has joined #ruby
despai has quit [Client Quit]
lxsameer has quit [Ping timeout: 245 seconds]
phaul has quit [Ping timeout: 250 seconds]
phaul has joined #ruby
cthu| has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
johnny56 has quit [Ping timeout: 272 seconds]
cthulchu_ has quit [Ping timeout: 268 seconds]
r29v has quit [Quit: r29v]
lucasb has quit [Quit: Connection closed for inactivity]
r29v has joined #ruby
ellcs has joined #ruby
discopatrick has quit [Quit: Connection closed for inactivity]
clemens3 has joined #ruby
mikecmpbll has joined #ruby
Aqo has quit [Quit: ChatZilla 0.9.92-rdmsoft [XULRunner 35.0.1/20150122214805]]
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
johnny56 has joined #ruby
szulak_ has joined #ruby
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
stephenplatz has joined #ruby
bak1an has quit [Quit: Textual IRC Client: www.textualapp.com]
tiff has joined #ruby
sanscoeur has joined #ruby
tdy has quit [Ping timeout: 268 seconds]
sanscoeur has quit [Remote host closed the connection]
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Aqo has joined #ruby
sauvin has quit [Ping timeout: 245 seconds]
chouhoulis has joined #ruby
NingaLeaf has joined #ruby
scrptktty has joined #ruby
Swyper has joined #ruby
SeepingN has joined #ruby
conta1 has joined #ruby
tdy has joined #ruby
Swyper has quit [Remote host closed the connection]
conta1 has quit [Ping timeout: 244 seconds]
vikaton has quit [Quit: Connection closed for inactivity]
Rapture has joined #ruby
Xenosine has joined #ruby
Xenosine has left #ruby [#ruby]
s3nd1v0g1us has joined #ruby
hutch has quit [Ping timeout: 244 seconds]
hutch has joined #ruby
sanscoeur has joined #ruby
ua has quit [Remote host closed the connection]
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
maryo has quit [Ping timeout: 258 seconds]
conta has quit [Quit: conta]
NingaLeaf has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NingaLeaf has joined #ruby
NingaLeaf has quit [Client Quit]
ua has joined #ruby
ivanskie has joined #ruby
<ivanskie> hi all
dellavg_ has quit [Ping timeout: 258 seconds]
<ivanskie> i have a what i think is a fairly common problem that I haven't dealt with yet, trying to wrap my head around. thought I might ask for suggestions here.
gnarmis has joined #ruby
bob_dino has joined #ruby
gnarmis has quit [Client Quit]
<ivanskie> I'm using aws sdk, getting logs from cloudwatch logs. what i ended up doing was remap the messages hash to new hash like this: { timestamp: { message: '', instanceid: '' ...} since i will be collecting logs from several streams at once, i thought I'd push them all into a single hash, then do hash.keys.sort.each { |key| print hash[key].message } ( simplified for simplicity's sake)... so the issue i'm running into now, is when i
<ivanskie> refresh and get logs. it re-prints the old ones in addition to new ones, within the request limit.. of lets say 100 records. so refreshes, adds lets say 5 new lines, and 5 oldest lines dissapear, but all existing just get reprinted..
<ivanskie> so how can I check, and only print new records?
<havenwood> ivanskie: I don't quite follow your example code. Can you show a simplified version of what you're doing that run?
<havenwood> runs*
<ivanskie> probably not in a shirt time.
cthulchu has joined #ruby
bmurt has quit [Ping timeout: 268 seconds]
<ivanskie> i think i need to keep track of "old" records. and when new ones come in, only deal with new records.
<havenwood> ivanskie: Your pseudo code has some inconsistencies and it's not clear which Hash you mean by `hash`.
<ivanskie> like array of epoch timestamps
brendan- has quit [Ping timeout: 250 seconds]
<ivanskie> ah alright let me put some code together one sec
cthu| has quit [Ping timeout: 245 seconds]
quiliro has joined #ruby
tdy has quit [Ping timeout: 244 seconds]
<ivanskie> havenwood https://dpaste.de/yZ0A
<ivanskie> on every request i get about 50 records from past few seconds.. then refresh using the "nextFordwardToken", which doesn't seem to be changing much, but thats a different issue alltogether.
<quiliro> hello...is there some newbie tutorial for using ruby to communicate with an FTDI device?
<ivanskie> so i'd like to just tail, and print only the new records, and not reprint old ones
m27frogy_ has quit [Read error: Connection reset by peer]
rubydoc has quit [Ping timeout: 250 seconds]
phaul has quit [Ping timeout: 240 seconds]
<havenwood> ivanskie: Why `response.to_h` when `response` is already a Hash?
<ivanskie> its json
<ivanskie> i mean comes in as json
<ivanskie> hm yeah good point i guess
<havenwood> ivanskie: Where is `@events` defined?
<ivanskie> its blank at init. then i add to it on every request
<havenwood> ivanskie: This is a very hard example to follow, since it doesn't execute and references things that aren't here.
<ivanskie> so within that block
<ivanskie> one sec
<havenwood> ivanskie: By "blank" do you mean it's an empty Hash?
<ivanskie> yes
m27frogy has joined #ruby
bob_dino has quit [Quit: bob_dino]
bmurt has joined #ruby
rubydoc has joined #ruby
<havenwood> quiliro: It looks like there are old gems callled ftdi and libftdi-ruby: https://github.com/Undev/libftdi-ruby
<quiliro> havenwood: thank you. i saw them but i do not understand...is there something tutorialish somewhere?
<havenwood> quiliro: What are you trying to do?
rubydoc has quit [Ping timeout: 240 seconds]
<quiliro> i want to communicate an avr via an ftdi to usb device to my computer
<quiliro> it must just send bits: 01100101001 etc
<quiliro> i have an idea of ruby already but it is very basic...perhaps it would be easier to learn though an exercise which involves what i need to achieve
Sina has quit [Quit: Connection closed for inactivity]
<quiliro> -> send the data to the usb port
<havenwood> quiliro: I don't know of any tutorials.
<havenwood> quiliro: Maybe check: https://github.com/larskanis/libusb
<havenwood> quiliro: Dunno if this is relevant to what you're doing?: https://github.com/jmelkor/RubimC#some-interesting-idea
bob_dino has joined #ruby
<quiliro> havenwood: i even found this https://github.com/claudijd/serial-tools
<quiliro> but it is still too complicated for my level
<quiliro> let me check your last link
<havenwood> quiliro: Check the one I linked above, rubyserial.
rubydoc has joined #ruby
<quiliro> havenwood: that last link looks easier to understand and more up-to-date
<havenwood> ivanskie: Don't put timestamps past where you last checked in `@events` and they won't be there to print.
<ivanskie> how do you mean
<ivanskie> only add new ones?
phaul has joined #ruby
<baweaver> hehehehehe
<baweaver> ( yes, I know it breaks some other things )]
<havenwood> ivanskie: Yup, unless you need them in `@events`, in which case only start iterating past the last seen timstamp
<baweaver> Also got a 2018 review done - https://medium.com/@baweaver/2018-in-review-3f619f26baca
<ivanskie> alright thank you :)
tdy has joined #ruby
<havenwood> baweaver: It's interesting there's NilClass#to_i, #to_h, #to_a, but no #to_int, #to_hash, #to_ary. I guess worry about masking bugs with implicit conversions?
<baweaver> Pretty much.
brandonkal has joined #ruby
<ivanskie> havenwood here's my actual code.. https://dpaste.de/zOv5#L157,158,159,163,165,166,167,168,169,170,171,172,173,174 i should be doing a comparison somewhere in there to determine only the new records. but not sure about the best way to do that. unless that means that the way i wrote that is already bad to begin with.
<ivanskie> within the block on lines 163-174
<havenwood> ivanskie: Put an if statement around line 158, checking if the timestamp is newer than last seen.
bob_dino has quit [Quit: bob_dino]
<ivanskie> that takes care of not adding duplicates. but my print block is still flawed, i'll have to do something similar there
<ivanskie> `if @events.keys.sorted[@events.size] < event['timestamp']` ?
rubydoc has quit [Ping timeout: 268 seconds]
<ivanskie> maybe add it to @new_events then only print @new_events
phaul has quit [Ping timeout: 268 seconds]
<ivanskie> or rather do that with timestamps.. only make list of new timestamps
<ivanskie> yaaa
cthulchu has quit [Ping timeout: 252 seconds]
rubydoc has joined #ruby
phaul has joined #ruby
cthulchu has joined #ruby
tdy has quit [Ping timeout: 246 seconds]
hurricanehrndz has quit [Ping timeout: 250 seconds]
cschneid has joined #ruby
hurricanehrndz has joined #ruby
cnsvc has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
comet23 has quit [Quit: Connection closed for inactivity]
Scriptonaut has joined #ruby
<Scriptonaut> have you guys noticed how in the ruby console, if you override an assignment method, it will always return whatever you assign it to, even if the method returns false?
<Scriptonaut> I have a method that's like: def receive_notifications=(flag); User.current.is_admin? && super(flag); end
millerti has joined #ruby
<Scriptonaut> in the console however, when User.current is a non-admin user, and I do: my_user.receive_notifications = true, the console prints "true" as the return value, even though I checked, and it's not true
<Scriptonaut> should I raise an error instead?
<cschneid> Does anybody have links to articles about tooling around ruby? We're using codeclimate, standardrb, and I'm looking at rufo for formatting - any others that people like? Trying to make sure a rapidly growing team stays relatively consistent
<mspo> rubocop?
whathappens has joined #ruby
tomaw_ has joined #ruby
tomaw has quit [Read error: Connection reset by peer]
tomaw_ is now known as tomaw
despai has joined #ruby
Azure has quit [Ping timeout: 258 seconds]
conta has joined #ruby
conta has quit [Ping timeout: 268 seconds]
tdy has joined #ruby
Mike11 has joined #ruby
quiliro has left #ruby [#ruby]
<cschneid> mspo: standardrb is a set of rubocop rules - so that's included yep. Anything else to look at that will let junior devs focus on the behavior & tests rather than accidental complexity?
<LadyElusive> Scriptonaut: i think you're assigning a variable of the same name as the function, and assigning a variable returns what was assigned, thus true
s3nd1v0g1us has quit [Quit: WeeChat 2.2]
<LadyElusive> also, the function you defined is "receive_notifications=" and not "receive_notifications"
tdy has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
tdy has joined #ruby
<havenwood> cschneid: You might take a look at Querly for things that come up: https://github.com/soutaro/querly#readme
<cschneid> @havenwood - oh cool, I like that
spacesui_ has joined #ruby
<havenwood> cschneid: Or for non-code things, Goodcheck: https://github.com/sider/goodcheck#readme
Mike11 has quit [Quit: Leaving.]
<havenwood> cschneid: Sider have some other interesting tools: https://sider.review/
agent_white has quit [Quit: bbl]
spacesuitdiver has quit [Ping timeout: 244 seconds]
Azure has joined #ruby
<havenwood> cschneid: You might also consider reek: https://github.com/troessner/reek#readme
<cschneid> yeah, codeclimate has some set of those already - cyclomatic complexity and such.
<cschneid> I think it uses reek underneath
<havenwood> cschneid: Dependabot is handy, so each team doesn't need a person obsessed with following dep updates.
nickjj has quit [Quit: Leaving]
<havenwood> cschneid: Any Rails involved?
<cschneid> yep, that's the main app I'm worried about right now
<cschneid> rails_best_practices gem looked old when I last looked
<havenwood> cschneid: Yeah, it still has some interesting sections though. I tend to run it and largely disregard its output - but a few things worth looking at.
<havenwood> cschneid: Brakeman for sure.
<havenwood> cschneid: bundle-audit
tiff has joined #ruby
<havenwood> cschneid: the bullet gem for N+1 queries and unnecessary eager loading
whathappens has quit [Remote host closed the connection]
nickjj_ has joined #ruby
<havenwood> cschneid: ah, missing indexes is one nice rails_best_practices thing
chouhoulis has quit [Ping timeout: 268 seconds]
nickjj_ is now known as nickjj
<havenwood> that matters soo mcuh
hutch has quit [Ping timeout: 250 seconds]
mustmodify has joined #ruby
<mustmodify> I'm having brain problems.
<cschneid> of for sure. I actually work at scoutapp.com - an APM. So performance, especially db, is what we do :)
<mustmodify> I want an iterator that provides the n and the n+1st elements of an array
<mustmodify> is that a thing? I guess I could write one...
<havenwood> cschneid: hah, I was a Scout customer on Heroku
<havenwood> cschneid: Nice stuff!
<cschneid> Thanks :)
<havenwood> mustmodify: each_cons
<cschneid> havenwood: And thank you for the ton of linters I get to go track down and implement!
<havenwood> cschneid: AccessLint for accessibility CI
stephenplatz has quit [Ping timeout: 260 seconds]
nickjj has quit [Client Quit]
<mustmodify> havenwood: Oh blah, I was just writing it. Spoil my fun!
<mustmodify> :)
<mustmodify> thanks I'll check it out.
<mustmodify> havenwood: Hunh. I would never have found that. Thanks.
<havenwood> mustmodify: hah, np - each_cons(2) for doubles
mustmodify has left #ruby [#ruby]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
tdy has quit [Ping timeout: 258 seconds]
nickjj has joined #ruby
<Scriptonaut> LadyElusive: no I overrode the receive_notifications= method. THen I call super inside of it. The method returns false, I've tested it, but for some reason the console (only in the console, not when it runs anywhere else) short-circuits and displays the return value as whatever you pass to it. With a normal assignment method this is expected behavior, but I overrode the method and changed how it worked
nickjj has quit [Client Quit]
<Scriptonaut> I'll gist the actual code
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
despai has quit [Quit: ...]
gix has joined #ruby
orbyt_ has joined #ruby
<Scriptonaut> that's odd behavior
<Scriptonaut> I made another gist that demonstrates the weird behavior: https://gist.github.com/robins35/ddd8616f05bfaa256292ab1d559e0c46
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hutch has joined #ruby
nickjj has joined #ruby
spacesuitdiver has joined #ruby
despai has joined #ruby
spacesui_ has quit [Ping timeout: 240 seconds]
CrazyEddy has quit [Read error: Connection reset by peer]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Eiam> in console whats your staff.first.is_admin? value
CrazyEddy has joined #ruby
<Eiam> your first line makes it sound like that value is false, since line 3 shows false. if is_admin is false, the next call will be false && super(true) which can only return false
<Eiam> Scriptonaut: ^
phaul has quit [Ping timeout: 258 seconds]
orbyt_ has joined #ruby
rubydoc has quit [Ping timeout: 245 seconds]
<Eiam> so then its false && super(true) as the return value on line 4, which we already established must be false because it says false in your output.
<Scriptonaut> Eiam: exactly
<Scriptonaut> that's why I'm confused
<Eiam> right so I don't get the bug
<Scriptonaut> why is the console displaying true, when it's false
<Eiam> its working exactly as the code says
<Scriptonaut> no it's not, look at line 6
<Scriptonaut> it returns true
<Eiam> oh, something to do with how irb echos statements or something
<Eiam> i don't think thats the return value of your statement
<Scriptonaut> when I do: ret_val = (gu.receive_direct_message_alerts = true), ret_val is assigned true
<Scriptonaut> only in the console though, when I run it on unicorn or even just through the interpreter it returns false
<Eiam> whats the implementation of receive_direct_message_alerts
* baweaver wanders in
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Scriptonaut> Eiam: it's a cp_typed_hash on an ActiveRecord 2 model
<Scriptonaut> the method I wrote is to override the setter to prevent non-admins from having that setting set to true
<Eiam> i mean do you have receive_direct_message_alerts and receive_direct_message_alerts=
* baweaver kinda thinks this sounds like Rails
<Scriptonaut> baweaver: it's not
<Eiam> because it looks like you are calling two different implementations and wondering why each has its own return value
<Scriptonaut> Eiam: I explicitly wrote the setter, the getter was defined by cp_typed_hash
<Eiam> but I only see one implementation, receive_direct_message_alerts=
<Scriptonaut> Eiam: yes, I wrote that
<Scriptonaut> and then call super, to the setter that was defined previously
<Scriptonaut> method overriding
<Scriptonaut> I only call super if the user is an admin though
<Scriptonaut> this is an issue with irb, the code is working as it should, it's just that in irb the return value is true when it should be false
<Scriptonaut> I wonder if it's a bug in old irb, this is ruby 1.8.7
<Eiam> okay... what I'm saying is you could be calling "methodA" and it gives you false. later you call "methodB" and it gives you true, then you again call "methodA" and it gives you false again, which is expected...
<Eiam> receive_direct_message_alerts and receive_direct_message_alerts= aren't the same method , they could be defined totally different
<Scriptonaut> what?
<Scriptonaut> I gisted a console session, I am not confusing the getter and setter
<Scriptonaut> I just recreated it in irb with a test class: https://gist.github.com/robins35/bb3dbd2dcc13a72b9d2a39ba1a73fee3
<Eiam> okay
<Scriptonaut> there, that's plain ruby, no activerecord, no method overriding
<Scriptonaut> it still has the issue
<Scriptonaut> as you can see, on line 6, the method x= should always return false
<Scriptonaut> however on line 15 it returns true
<Scriptonaut> when I do: t.x = "foo bar", it returns "foo bar"
<Scriptonaut> I'm gonna try in ruby 2.5 and see if the issue is still there
hiroaki has quit [Ping timeout: 252 seconds]
drale2k_ has joined #ruby
<Scriptonaut> hmm, still happens with ruby 2.5.1. It must just be the way the console is written. I always thought that the => in the console was supposed to denote the return value, but when the method ends with a '=', it returns the RValue no matter what
<Eiam> it behaves the same on 2.3.7
<Scriptonaut> oh well, it's not a big deal, the code works. I just thought that was weird
rubydoc has joined #ruby
<Eiam> if you split your assignment out into its own line
<Eiam> the behavior will change
<Eiam> i thought assignment in comparisons were frowned upon
<Eiam> on line 6 if you set @x = flag, then do false && @x you'll see it shifts
<Scriptonaut> well that would change the behavior because that's totally different code. The assignment in your example wouldn't be dependent on the first argument to &&
<Scriptonaut> that would assign @x to flag no matter what
<Scriptonaut> I came up with an even simpler example
<Scriptonaut> def foo=(bar); false; end
<Scriptonaut> f = true # This returns true
<Scriptonaut> foo = true **
<Scriptonaut> even though the method :foo= just returns false
<Eiam> oh you are counting on the early exit to avoid the assignment
<Eiam> ha ha
<Eiam> righto
<Eiam> Scriptonaut: yeah, that is interesting
<Scriptonaut> ya, pretty much. In my actual program I'm not doing condition && foo = bar, I'm just calling super(flag)
<Eiam> i don't know why you are seeing that behavior in console
<Scriptonaut> ya, it's odd
phaul has joined #ruby
Dbugger has quit [Remote host closed the connection]
<Scriptonaut> this seems like it might be related https://bugs.ruby-lang.org/issues/2050
Nicmavr has quit [Read error: Connection reset by peer]
hutch has quit [Ping timeout: 240 seconds]
Inline has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
hutch has joined #ruby
Yxhuvud has joined #ruby
polishdub has quit [Remote host closed the connection]
waheedi has joined #ruby
<waheedi> is rubygems.org down for fetching gems or versions?
<waheedi> or its a deployment on a late friday
<waheedi> or it could be my poor internet connection, timing out :)
<waheedi> Exception `Gem::RemoteFetcher::UnknownHostError' at /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/remote_fetcher.rb:276 - timed out (https://rubygems.org/api/v1/dependencies)
paraxial has quit [Quit: The Lounge - https://thelounge.github.io]
paraxial has joined #ruby
<Scriptonaut> I'll check
<Scriptonaut> I just bundled fine, I wonder if it cached the locations of my gems since they're already downloaded though.
<havenwood> waheedi: Seems up to me.
<waheedi> strange
<waheedi> I first thought its a bundler issue, so tried manually installing gems, and it worked
<waheedi> then went back to try again after few minutes with bundler, and it failed again, then when tried again manually it failed as well.
<Scriptonaut> hmm
<waheedi> so its either timing out very quickly or
<waheedi> it hate my icmp tunnel for some reason
<Scriptonaut> there are various rubygem servers right?
despai has quit [Quit: ...]
<Scriptonaut> I wonder if the one you usually use is down
<waheedi> i use rubygems.org
<Scriptonaut> same, I mean I think there are various physical servers, depending on your location
<waheedi> Scriptonaut: do I have to load balance them manually too :)
<waheedi> yeah they are dns fail over or based on location, for sure
<Scriptonaut> lol
<Scriptonaut> ya, I've never had rubygems go down on me
<Scriptonaut> but it could be
rubydoc has quit [Ping timeout: 246 seconds]
phaul has quit [Ping timeout: 258 seconds]
<waheedi> 151.101.128.70 is the one I'm calling atm
<Scriptonaut> did you just ping that to get it?
<waheedi> the website seems to be fine
<waheedi> no
cthulchu has quit [Read error: Connection reset by peer]
<waheedi> i dig it
<Scriptonaut> 151.101.64.70
cthulchu has joined #ruby
<Scriptonaut> under ANSWER SECTION I got 4 rubygems.orgs, one of them is that one you are hitting
<waheedi> right
<Scriptonaut> they all have the same values other than IP
trbh has joined #ruby
<Scriptonaut> I'm hitting the first one on the list, the 128 one you're hitting is the 3rd one
<Scriptonaut> for me
<waheedi> I can open linked just fine but https://status.rubygems.org/ does not appear to open on my end
<waheedi> ERR_TIMED_OUT
<Scriptonaut> weird
<Scriptonaut> it shows me that everything is operational, I'm hitting it fine
<Scriptonaut> Try hitting that: 151.101.64.70
<Scriptonaut> oh it doesn't like it when I try to hit it by ip
<waheedi> sure it does not
phaul has joined #ruby
rubydoc has joined #ruby
<waheedi> the web server is relaying apps based on their host names :)
<Scriptonaut> ah
<Scriptonaut> microservices
<waheedi> thats the buzz word
<waheedi> i don't use it
<waheedi> :)
<Scriptonaut> heh
clemens3 has quit [Ping timeout: 250 seconds]
<waheedi> but its cool
sanscoeu_ has joined #ruby
trbh has quit [Read error: Connection reset by peer]
RougeR has joined #ruby
sanscoeur has quit [Ping timeout: 245 seconds]
<waheedi> it seems timing out is too short for low speed connections like mine
<Scriptonaut> do you have a vps or something you could test it out on
<Scriptonaut> some remote server you could try pulling in rubygems from
<waheedi> yeah i already did, it works fine
<Scriptonaut> ah ok, must just be your connection
<waheedi> well, I hope so
sanscoeu_ has quit [Ping timeout: 258 seconds]
hutch has quit [Ping timeout: 258 seconds]
<cthulchu> ma folks
<cthulchu> will JSON.pretty_generate prettify other object that are not hashes?
planigan has quit [Ping timeout: 272 seconds]
<waheedi> so if they are not hashes, what they are?
<waheedi> cthulchu:
<waheedi> "f":"d"
<waheedi> ?
<cthulchu> well like would it pretty print an object like puts_r or what it's called
<cthulchu> including :
<cthulchu> I think it'll print : just fine
<cthulchu> I tested that
<waheedi> yes, sure
Inline has joined #ruby
planigan has joined #ruby
reber has quit [Remote host closed the connection]
<Scriptonaut> cthulchu: you just mean to read? You could use awesome_print
<Scriptonaut> that will pretty print all kinds of things
<Scriptonaut> even xml
bob_dino has joined #ruby
<Scriptonaut> what's puts_r
<cthulchu> holy crap
<cthulchu> tell me I don't need a gem for it
<Scriptonaut> you do lol
<Scriptonaut> it's a tiny gem though iirc
<cthulchu> crap
<Scriptonaut> I always put awesome_print in my dev dependencies
<Scriptonaut> you could also download it and then just require it as needed I think
Aqo has quit [Quit: ChatZilla 0.9.92-rdmsoft [XULRunner 35.0.1/20150122214805]]
johnny56_ has joined #ruby
johnny56 has quit [Ping timeout: 272 seconds]