havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.6.5, 2.5.7, 2.7.0-preview1: 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!
wildtrees has quit [Quit: Leaving]
fphilipe has joined #ruby
fphilipe has quit [Ping timeout: 250 seconds]
Mia has quit [Ping timeout: 265 seconds]
Ai9zO5AP has quit [Quit: WeeChat 2.5]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
grvgr has quit [Quit: Connection closed for inactivity]
Fernando-Basso has quit [Quit: Leaving]
mikecmpbll has quit [Quit: inabit. zz.]
jrafanie has joined #ruby
ogres has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
mynameisdebian has quit [Ping timeout: 265 seconds]
cow[moo] has joined #ruby
cow[moo] has quit [Ping timeout: 268 seconds]
Omnilord has quit [Quit: This computer has gone to sleep]
gdubb has quit []
sytherax has joined #ruby
absolutejam has joined #ruby
sytherax has left #ruby ["Leaving..."]
Intelo has quit [Ping timeout: 265 seconds]
absolutejam1 has joined #ruby
absolutejam has quit [Ping timeout: 268 seconds]
ston3r has joined #ruby
Technodrome has joined #ruby
n88 has quit [Ping timeout: 268 seconds]
Omnilord has joined #ruby
Omnilord has quit [Client Quit]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bambanx has quit [Ping timeout: 276 seconds]
ston3r has quit [Remote host closed the connection]
jrafanie has joined #ruby
cd has quit [Quit: cd]
cthulchu_ has quit [Ping timeout: 250 seconds]
xGrind has quit [Ping timeout: 240 seconds]
xGrind has joined #ruby
xGrind has quit [Remote host closed the connection]
drincruz_ has joined #ruby
SzeregowyPosel has quit [Quit: Bye Bye]
tdy has quit [Ping timeout: 245 seconds]
edwardly has quit [Read error: Connection reset by peer]
uplime is now known as Scrooge
greengriminal has joined #ruby
edwardly has joined #ruby
edwardly has joined #ruby
edwardly has quit [Changing host]
greengriminal has quit [Quit: This computer has gone to sleep]
howdoi has quit [Quit: Connection closed for inactivity]
greengriminal has joined #ruby
edwardly has quit [Read error: Connection reset by peer]
edwardly has joined #ruby
edwardly has quit [Changing host]
edwardly has joined #ruby
gavlee has quit []
Jello_Raptor has quit [Remote host closed the connection]
absolutejam1 has quit [Ping timeout: 240 seconds]
evdubs has quit [Remote host closed the connection]
evdubs has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
Jello_Raptor has joined #ruby
tdy has joined #ruby
bambanx has joined #ruby
dasher00 has quit [Ping timeout: 268 seconds]
tsrt^ has quit []
sgen has joined #ruby
bambanx has quit [Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org]
Swyper_ has joined #ruby
Swyper has quit [Ping timeout: 240 seconds]
Swyper_ has quit [Remote host closed the connection]
jeremycw has joined #ruby
Swyper has joined #ruby
jeremycw has quit [Ping timeout: 246 seconds]
Swyper has quit [Remote host closed the connection]
mynameisdebian has joined #ruby
Swyper has joined #ruby
mossplix has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
mossplix has quit [Ping timeout: 268 seconds]
electrostat has quit [Quit: uwotm8]
electrostat has joined #ruby
liberpater has quit [Quit: WeeChat 1.5]
ogres has quit [Quit: Connection closed for inactivity]
rick_ has joined #ruby
sgen has quit [Ping timeout: 250 seconds]
matheusmoreira has quit [Ping timeout: 268 seconds]
matheusmoreira has joined #ruby
mynameisdebian has quit [Ping timeout: 265 seconds]
rick_ has quit [Quit: Leaving]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
Omnilord has joined #ruby
gavlee has joined #ruby
arwn has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
mossplix has joined #ruby
Swyper has quit [Remote host closed the connection]
mossplix has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ruby
kyrylo has joined #ruby
arooni has quit [Ping timeout: 265 seconds]
mossplix has joined #ruby
matheusmoreira has joined #ruby
dellavg has joined #ruby
Omnilord has quit [Quit: This computer has gone to sleep]
fphilipe has joined #ruby
arooni has joined #ruby
fphilipe has quit [Ping timeout: 246 seconds]
victorqueiroz is now known as graphicsv
mossplix has quit [Remote host closed the connection]
arwn has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Remote host closed the connection]
d^sh has joined #ruby
mossplix has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
apg has joined #ruby
ur5us has joined #ruby
MrCrackPot has joined #ruby
Junaos has quit [Quit: ZNC - http://znc.in]
ur5us has quit [Ping timeout: 265 seconds]
_whitelogger has joined #ruby
<Frankenstein> /^(\+|-)(\d+)([a-zA-Z]+)$/ is there a way to access the capture groups of this regex?
<baweaver> Yes?
<baweaver> What're you going for here?
<baweaver> Typically Regexp#match
<Frankenstein> I have a string that will look something along the lines of +30d or -20h and I was hoping to turn it into { d: { mod: :plus, amount: 30 } }
<Frankenstein> or something along those lines (d will actually map to a more descriptive name)
<Frankenstein> thanks, i'll take a peek at that
conta has joined #ruby
<baweaver> &>> /(\d+)\.(\d+)\.(\d+)\.(\d+)/.match('192.168.1.1')
<baweaver> (assuming I didn't typo that)
<rubydoc> # => #<MatchData "192.168.1.1" 1:"192" 2:"168" 3:"1" 4:"1"> (https://carc.in/#/r/7ty4)
<baweaver> (or that the bot is alive and well)
<Frankenstein> oh, yeah, that's perfect
<baweaver> Do you know about named captures?
<Frankenstein> i did, but forgot about them. my google search actually turned those up right as you mentioned them though
<baweaver> &>> /(?<first_octet>\d+)\.(?<second_octet>\d+)\.(?<third_octet>\d+)\.(?<fourth_octet>\d+)/.match('192.168.1.1')
<Frankenstein> stuff like (<name>.{3}) right?
<rubydoc> # => #<MatchData "192.168.1.1" first_octet:"192" second_octet:"168" third_octet:"1" fourth_octet:"1"> (https://carc.in/#/r/7ty5)
<Frankenstein> yeah, that looks better
<Frankenstein> thanks as always baweaver
<baweaver> &>> match_data = /(?<first_octet>\d+)\.(?<second_octet>\d+)\.(?<third_octet>\d+)\.(?<fourth_octet>\d+)/.match('192.168.1.1'); { 1: match_data[:first_octet] }
<rubydoc> stderr: -e:4: syntax error, unexpected ':', expecting =>... check link for more (https://carc.in/#/r/7ty6)
<baweaver> &>> match_data = /(?<first_octet>\d+)\.(?<second_octet>\d+)\.(?<third_octet>\d+)\.(?<fourth_octet>\d+)/.match('192.168.1.1'); { 1 => match_data[:first_octet] }
* baweaver mumbles about symbols starting with numbers
<rubydoc> # => {1=>"192"} (https://carc.in/#/r/7ty7)
blackmesa1 has joined #ruby
<baweaver> Note the `?`: (?<group_name>content)
<Frankenstein> &>> { "1": :foo }
<rubydoc> # => {:"1"=>:foo} (https://carc.in/#/r/7ty8)
<Frankenstein> lol
<Frankenstein> baweaver: oops, yeah, forgot that in my example
<baweaver> I mean yes, but the JSON syntax is touchy
<baweaver> I wonder
<baweaver> &>> { ?1: 2 }
<rubydoc> stderr: -e:4: syntax error, unexpected ':', expecting =>... check link for more (https://carc.in/#/r/7ty9)
<Frankenstein> &>> { "1": :foo }.to_json
<baweaver> Nope
<rubydoc> stderr: -e:4:in `<main>': undefined method `to_json' for {:"1"=>:foo}:Hash (NoMethodError)... check link for more (https://carc.in/#/r/7tya)
<baweaver> JSON-like syntax
<Frankenstein> &>> require "json"; { "1": :foo }.to_jsona
<rubydoc> stderr: -e:4:in `<main>': undefined method `to_jsona' for {:"1"=>:foo}:Hash (NoMethodError)... check link for more (https://carc.in/#/r/7tyb)
<Frankenstein> &>> require "json"; { "1": :foo }.to_json
<rubydoc> # => "{\"1\":\"foo\"}" (https://carc.in/#/r/7tyc)
<baweaver> 1.9 hash syntax if we're being pedantic
<baweaver> &>> ?!
<rubydoc> # => "!" (https://carc.in/#/r/7tyd)
<baweaver> Great for code golf. Horrid for anything else
greengriminal has quit [Quit: This computer has gone to sleep]
<baweaver> &>> (?a..?z).to_a
<rubydoc> # => ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",... check link for more (https://carc.in/#/r/7tye)
<baweaver> Old 1.8ism iirc
<Frankenstein> I wrote: some_test ?s ? ?s : ""
<Frankenstein> and it gave me a good chuckle
<baweaver> &>> ?!??!:?!
<rubydoc> # => "!" stderr: -e:4: warning: string literal in condition (https://carc.in/#/r/7tyf)
<baweaver> Almost
mossplix has quit [Remote host closed the connection]
<baweaver> &>> ?! ? ?! : ?!
<rubydoc> # => "!" stderr: -e:4: warning: string literal in condition (https://carc.in/#/r/7tyg)
<Frankenstein> &>> ?!.empty???!:?!
<rubydoc> stderr: -e:4: syntax error, unexpected '!', expecting end... check link for more (https://carc.in/#/r/7tyh)
blackmesa1 has quit [Ping timeout: 276 seconds]
<baweaver> I wonder if I still have those old things
Junaos has joined #ruby
<baweaver> One sec
<baweaver> Found it
<baweaver> &>> $_=$$/$$;@_=->_{_==''?_:[*?`..?{]['. !#% & , :;<= >@_ `'=~/#{_[$.]}/]+@_[_[$_..-$_]]};_=->&_{_}[&:"#{@_['@%<#']}"];_[_[_[_['',@_['!: @@']],@_[' <!%@_=>@']][-$_-$_],@_['!=<@_']+?_+@_['&%_'],(''<<(_=$_+$_)**_**(_+$_)/(_+$_)-$_)+@_[',;%']],@_['<%`']]
<rubydoc> # => 2019-10-18 05:24:20 +0000 (https://carc.in/#/r/7tyi)
<Frankenstein> :o
<baweaver> &>> @_=[*?/...?:][(_=$$/$$)..-_]*'';(@__=->__{$_=__[_-_];@_[$_]?$*<<(@_=~/#$_/):(___,$__=$*[-_-_,_+_];$*[-_-_,_+_]=$_[?+]?___+$__:$_[?-]?___-$__:$_[?*]?___*$__:$_[?/]?___/$__:_);__[_]?@__[__[_..-_]]:$*})
<rubydoc> # => #<Proc:0x000055b1118743e0@-e:4 (lambda)> (https://carc.in/#/r/7tyj)
<baweaver> &>> @_=[*?/...?:][(_=$$/$$)..-_]*'';(@__=->__{$_=__[_-_];@_[$_]?$*<<(@_=~/#$_/):(___,$__=$*[-_-_,_+_];$*[-_-_,_+_]=$_[?+]?___+$__:$_[?-]?___-$__:$_[?*]?___*$__:$_[?/]?___/$__:_);__[_]?@__[__[_..-_]]:$*})['1+2+3']
<rubydoc> stderr: -e:4:in `block in <main>': undefined method `+' for nil:NilClass (NoMethodError)... check link for more (https://carc.in/#/r/7tyk)
<baweaver> &>> @_=[*?/...?:][(_=$$/$$)..-_]*'';(@__=->__{$_=__[_-_];@_[$_]?$*<<(@_=~/#$_/):(___,$__=$*[-_-_,_+_];$*[-_-_,_+_]=$_[?+]?___+$__:$_[?-]?___-$__:$_[?*]?___*$__:$_[?/]?___/$__:_);__[_]?@__[__[_..-_]]:$*})['1+2']
<rubydoc> stderr: -e:4:in `block in <main>': undefined method `+' for nil:NilClass (NoMethodError)... check link for more (https://carc.in/#/r/7tyl)
<baweaver> Fine, I don't like you either
<baweaver> &>> (___=->_,__=''{__=_[$.]+__; _[$.+=$$/$$]?___[_,__]:__})['yllis os']
<rubydoc> # => "so silly" (https://carc.in/#/r/7tyn)
<baweaver> havenwood: you remember all these?
<baweaver> There are all of them "translated" and explained
<baweaver> Once you figure out this line the rest falls in pretty quick: $_ = $$ / $$ # PID / PID, or 1
<Frankenstein> &>> $$
<rubydoc> # => 1 (https://carc.in/#/r/7typ)
<baweaver> Not guaranteed to be 1, mind
<Frankenstein> right
<Frankenstein> its stuff like this why i get mixed up writing bash and ruby
<baweaver> Most of these have english equivalents, while those global shorthands are pretty well deprecated
<baweaver> That one is better
tdy has quit [Ping timeout: 276 seconds]
levifig has quit [Ping timeout: 240 seconds]
blackmesa1 has joined #ruby
levifig has joined #ruby
conta has quit [Ping timeout: 240 seconds]
queip has quit [Ping timeout: 240 seconds]
Inline has quit [Quit: Leaving]
queip has joined #ruby
conta has joined #ruby
blackmesa1 has quit [Ping timeout: 276 seconds]
blackmesa1 has joined #ruby
sandstrom has joined #ruby
Omnilord has joined #ruby
sandstrom has quit [Client Quit]
blackmesa1 has quit [Ping timeout: 250 seconds]
Omnilord has quit [Client Quit]
bitwinery has quit [Quit: Leaving]
hiroaki_ has quit [Ping timeout: 268 seconds]
ur5us has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
s2013 has joined #ruby
d^sh_ has joined #ruby
fphilipe has joined #ruby
d^sh has quit [Ping timeout: 276 seconds]
mossplix has joined #ruby
dionysus69 has joined #ruby
Intelo has joined #ruby
Intelo has quit [Remote host closed the connection]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Intelo has joined #ruby
jeremycw has joined #ruby
queip has quit [Quit: bye, freenode]
sarna has joined #ruby
luminousnine has quit [Read error: Connection reset by peer]
queip has joined #ruby
jeremycw has quit [Ping timeout: 245 seconds]
ur5us has quit [Remote host closed the connection]
luminousnine has joined #ruby
luminousnine has joined #ruby
luminousnine has quit [Changing host]
gix- has quit [Ping timeout: 268 seconds]
fphilipe has quit [Ping timeout: 245 seconds]
TomyWork has joined #ruby
schne1der has joined #ruby
ur5us has joined #ruby
<ytti> hmmm
<ytti> string.split.find_index { |e| e.match something }
<ytti> what if, instead of this, i want to have hash or array of something, and i want to return index and which hash or array element produced the match
mossplix has quit [Remote host closed the connection]
nowhere_man has quit [Ping timeout: 276 seconds]
<baweaver> ytti: What's the input and what are you trying to do with it?
ur5us has quit [Ping timeout: 276 seconds]
<ytti> baweaver, lemme cook up an tolerable example
<baweaver> because String#index probably does what you want
fphilipe has joined #ruby
<baweaver> &>> "I have a lot of things to say here, but looking for this one.".index(/things/)
<rubydoc> # => 16 (https://carc.in/#/r/7tz6)
blackmesa1 has joined #ruby
<ytti> baweaver, http://p.ip.fi/Orw3 now in the last example, i'd actually want to return like [1, :ios]
<ytti> baweaver, it matched the :ios key condition and position 1
<ytti> baweaver, but that's not right, obviously, because any? is boolean and because with_object would return the object, not the #find_index
tpanarch1st has quit [Ping timeout: 240 seconds]
<ytti> baweaver, which condition matched and at what position, essentially
<ytti> i can of course build loops, but was hoping something cuter
d^sh has joined #ruby
conta has quit [Ping timeout: 268 seconds]
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
<baweaver> conds.find probably
<ytti> but i still wont be able to return the index
<baweaver> Does it need to be word based though?
<ytti> because with_object masks it
<baweaver> What task specifically are you trying to solve for?
<baweaver> Because there may be a way to simplify the code a lot
<ytti> i have input string, which may be produced by number of different platforms
d^sh_ has quit [Ping timeout: 240 seconds]
<ytti> i want to test which platform produced the string, and i want to find index of specific condition, to use as an anchor to parse it
<baweaver> conds.find _index{ |_type, matcher| message.index(matcher) }
<baweaver> Why do you need the index?
<baweaver> of the condition rather
<ytti> it's an anchor to use later to parse the message, to find some information in the message which is relative to the anchor place
<baweaver> So the index of the condition is irrelevant probably
<baweaver> You only need the index of the word
<ytti> correct
<baweaver> and since String#index gives the start of a word you can use that to say `message[found_index..-1]`
chalkmonster has joined #ruby
<baweaver> and there's what you're looking to crop for the parse
d^sh has quit [Ping timeout: 240 seconds]
conta has joined #ruby
<ytti> http://p.ip.fi/e8W3 - this naive solution works
<baweaver> messages.map { |message| conds.reduce(nil) { |_, _type, cond| i = message.index(cond); break [cond, message[i..-1]] if i } }
<ytti> not particularly better than my naive solution, tbh
<ytti> map and break, imho make it bit ugly
<ytti> but perhaps it is what it is
absolutejam1 has joined #ruby
<ytti> maybe if there is solution without map/each and break, it'll be hard to read
<ytti> i just kinda hoped with_object did it, but nope
<baweaver> The map is only to go through all the messages
<baweaver> => [[/cisco/, "cisco heippa hei"], ["juniper", "juniper joooko"], [nil, nil]]
<baweaver> for the output
<ytti> k = conds.each.with_object do |(key, value), msg|
<ytti> break [key, index] if index
<ytti> index = msg.split.find_index { |e| e.match value }
<ytti> end
<ytti> it's really not meaningfully better than that
<ytti> oops
<ytti> sorry, the wiht_objectr was additional toy
<baweaver> Never really said it was
<ytti> jsut ignore that with_object and ,msg
<baweaver> Though in your case it has an extra loop
<ytti> http://p.ip.fi/mZpW - i think i'll use that
<ytti> yeah
Intelo has quit [Remote host closed the connection]
<ytti> but i think it's bit more readable
<baweaver> depending on the size of those messages you'll get dinged on that
<ytti> i'd trade readibility for lack of each/map and break
<ytti> yes, this is very short computationally
Intelo has joined #ruby
<baweaver> Then go with your solution
<ytti> thank you
<leftylink> uhhhhhh I guess you could conds.map { ... [index, cond] }.find(&:first) I guess???
<leftylink> it's going to go through all the conds though
<ytti> lemme test
<leftylink> maybe .lazy would prevent that
<leftylink> I never really looked at how lazy works
<baweaver> Eh, it's late here, so all code comes with disclaimers
<baweaver> Also a bit tipsy still, so extra disclaimers
<baweaver> Speaking of, sleep time it is
<ytti> nighty night
queip has quit [Ping timeout: 245 seconds]
<leftylink> we're getting filter_map in 2.7 but this is more like find_map here
<leftylink> well hence why my proposal uses `map` and `find` lol
<ytti> oh cool
<ytti> .find(&first) works even for two element array, as long as the boolean value is first element
<ytti> this works
queip has joined #ruby
<ytti> if i make the key first element, it won't (i'd need to do first{|e|e.last}
<ytti> i think that's pretty cute solution
suukim has joined #ruby
* leftylink checks whether the logger logs -offtopic
<leftylink> it does not
<entel> hi
tdy has joined #ruby
<ytti> (someone added 3rd option today, aruba, and it started to look too wet)
<ytti> and i think it's not golfing or unreadable, i think it's very much idiomatic solution
absolutejam1 has quit [Ping timeout: 240 seconds]
Intelo has quit [Ping timeout: 245 seconds]
<al2o3-cr> ytti: how about this: msg.split.each_with_index.with_object([]) { |(w, i), o| conds.any? { |k, v| o.push(i, k) if w.match? v } }
<ytti> al2o3-cr, thanks, but i'm happy with current solution, it's not computationally cheapest one, but i thikn it's readable and idiomatic
<al2o3-cr> ytti: np, as long as its readable to you ;)
Intelo has joined #ruby
Sina has joined #ruby
<Bish> if i have a regex with a repeating pattern
<Bish> how would i get every single match?
Jonopoly has joined #ruby
apg has quit [Quit: Til we meet again, my friends]
<leftylink> I like String#scan but actually that's not the question that was asked, since String#scan is for when the string contains multiple instances of the pattern. if the regex repeats itself like /aa/ and needs to find both index 0 and 1 of "aaa" then String#scan doesn't work then. might have to convert some parts to positive lookahead or do some manual work?
<Bish> yeah i guess i could match the whole pattern, group it, and then scan for the repeating thing
DTZUZU has quit [Ping timeout: 268 seconds]
mossplix has joined #ruby
minvs1 has joined #ruby
envex has joined #ruby
davor_ has joined #ruby
davor has quit [Ping timeout: 250 seconds]
davor_ is now known as davor
mikecmpbll has joined #ruby
al2o3-cr has quit [Ping timeout: 246 seconds]
Mrgoose845701915 has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
ellcs has joined #ruby
absolutejam2 has joined #ruby
ur5us has quit [Remote host closed the connection]
absolutejam2 has quit [Ping timeout: 268 seconds]
CalimeroTeknik has joined #ruby
absolutejam2 has joined #ruby
deathwishdave has joined #ruby
Intelo_ has joined #ruby
Intelo_ has quit [Remote host closed the connection]
Intelo_ has joined #ruby
Intelo has quit [Ping timeout: 268 seconds]
SzeregowyPosel has joined #ruby
Fernando-Basso has joined #ruby
dasher00 has joined #ruby
d^sh has joined #ruby
galaxie has quit [Remote host closed the connection]
mossplix has quit [Remote host closed the connection]
galaxie has joined #ruby
mossplix has joined #ruby
d^sh has quit [Excess Flood]
d^sh has joined #ruby
vondruch has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
luminousnine has quit [Quit: Toodles]
mossplix has quit [Ping timeout: 268 seconds]
luminousnine has joined #ruby
luminousnine has joined #ruby
luminousnine has quit [Changing host]
ur5us has joined #ruby
DTZUZO has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
SzeregowyPosel has quit [Quit: Bye Bye]
ur5us has quit [Ping timeout: 276 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
al2o3-cr has joined #ruby
al2o3-cr has quit [Client Quit]
DTZUZO has joined #ruby
NL3limin4t0r_afk is now known as NL3limin4t0r
al2o3-cr has joined #ruby
Benett has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
troulouliou_div2 has joined #ruby
conta has quit [Ping timeout: 246 seconds]
SzeregowyPosel has joined #ruby
DTZUZO has joined #ruby
d^sh has joined #ruby
s2013 has joined #ruby
jeremycw has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
conta has joined #ruby
DTZUZO has joined #ruby
jeremycw has quit [Ping timeout: 265 seconds]
conta has quit [Ping timeout: 245 seconds]
DTZUZO has quit [Ping timeout: 245 seconds]
tdy has quit [Ping timeout: 250 seconds]
DTZUZO has joined #ruby
DTZUZO has quit [Ping timeout: 265 seconds]
conta has joined #ruby
<NL3limin4t0r> ytti: Here is another solution for your map find problem https://gist.github.com/3limin4t0r/05f1e1cba5c590127b9982b0d92c37e2
DTZUZO has joined #ruby
<ytti> NL3limin4t0r, that is readable, idiomatic and computationally cheaper
d^sh has quit [Ping timeout: 268 seconds]
<ytti> NL3limin4t0r, thanks
d^sh has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
conta has quit [Ping timeout: 265 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
Ai9zO5AP has joined #ruby
mossplix has joined #ruby
DTZUZO has joined #ruby
conta has joined #ruby
jtdowney has quit [Quit: Bye]
evdubs has quit [Quit: Leaving]
jtdowney has joined #ruby
mossplix has quit [Remote host closed the connection]
d^sh has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
s2013 has joined #ruby
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #ruby
AJA4350 has joined #ruby
cyclonis_ has joined #ruby
cyclonis has quit [Ping timeout: 268 seconds]
minvs1 has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
lxsameer has joined #ruby
minvs1 has joined #ruby
DTZUZO has quit [Ping timeout: 250 seconds]
wickedbloodfart has joined #ruby
n88 has joined #ruby
DTZUZO has joined #ruby
dmitrycy[m] has joined #ruby
leitz has joined #ruby
<dmitrycy[m]> Wow, first time on irc since....mid 00s
cyclonis_ has quit [Quit: -a- IRC for Android 2.1.55]
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
<NL3limin4t0r> that's a long time ago
<NL3limin4t0r> some technoligies are to stubborn to die =)
<leitz> Before I jump into this, checking for feasibility. I can build a ruby application in /opt/my_cool_app, to include gems and a compiled Ruby, correct?
<leitz> Then a config and init file in the regular filesystem, for a mostly encapsulated app. The goal is to move away from any required internet access for gems, and to not worry about the OS Ruby.
DTZUZO has quit [Ping timeout: 265 seconds]
<leitz> I think this is the way Puppet and Chef used to install, but I haven't looked at them lately.
DTZUZO has joined #ruby
<NL3limin4t0r> leitz: can't comment, I have no experience with what you're trying to do
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #ruby
qolq has joined #ruby
DTZUZO has quit [Ping timeout: 268 seconds]
lxsameer has quit [Ping timeout: 245 seconds]
SzeregowyPosel has quit [Quit: Bye Bye]
DTZUZO has joined #ruby
lxsameer has joined #ruby
sun6174 has joined #ruby
DTZUZO has quit [Ping timeout: 250 seconds]
sun6174 has left #ruby [#ruby]
sun6174 has joined #ruby
jacksoow has quit [Ping timeout: 268 seconds]
sun6174 has left #ruby [#ruby]
VladGh has quit [Read error: Connection reset by peer]
DTZUZO has joined #ruby
sun6174 has joined #ruby
d^sh has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
jacksoow has joined #ruby
evdubs has joined #ruby
Intelo__ has joined #ruby
sun6174 has left #ruby [#ruby]
DTZUZO has quit [Ping timeout: 268 seconds]
Intelo_ has quit [Ping timeout: 265 seconds]
DTZUZO has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
minvs1 has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
d^sh has quit [Ping timeout: 246 seconds]
Azure has quit [Ping timeout: 268 seconds]
minvs1 has joined #ruby
d^sh has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
luminousnine has quit [Quit: Toodles]
stryek has joined #ruby
conta has quit [Ping timeout: 264 seconds]
DTZUZO has joined #ruby
DTZUZO has quit [Ping timeout: 240 seconds]
luminousnine has joined #ruby
luminousnine has quit [Changing host]
luminousnine has joined #ruby
cyclonis has joined #ruby
drincruz_ has quit [Ping timeout: 240 seconds]
VladGh has joined #ruby
DTZUZO has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #ruby
sun6174 has joined #ruby
sun6174 has left #ruby [#ruby]
dbugger has joined #ruby
DTZUZO has quit [Ping timeout: 268 seconds]
mossplix has joined #ruby
s2013 has joined #ruby
DTZUZO has joined #ruby
mossplix has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 276 seconds]
jcalla has joined #ruby
akemhp_ is now known as akem
SzeregowyPosel has joined #ruby
DTZUZO has joined #ruby
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Ping timeout: 268 seconds]
jrafanie has joined #ruby
ropeney has joined #ruby
Inline has joined #ruby
minvs1 has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
minvs1 has joined #ruby
drincruz_ has joined #ruby
ropeney has quit [Ping timeout: 240 seconds]
ropeney has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
minvs1 has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
Jonopoly has quit [Quit: WeeChat 2.5]
mossplix has joined #ruby
poontangmessiah has joined #ruby
Ai9zO5AP has quit [Quit: WeeChat 2.5]
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
reber has joined #ruby
poontangmessiah_ has joined #ruby
poontangmessiah has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
CalimeroTeknik has quit [Quit: バイバイ]
CalimeroTeknik has joined #ruby
grilix has joined #ruby
sarna has quit [Remote host closed the connection]
Swyper has joined #ruby
Yxhuvud has quit [Remote host closed the connection]
SzeregowyPosel has quit [Quit: Bye Bye]
Xiti has quit [Quit: Xiti]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
poontangmessiah_ has quit [Remote host closed the connection]
dbugger has quit [Quit: Leaving]
d^sh has quit [Ping timeout: 240 seconds]
d^sh has joined #ruby
lucasb has joined #ruby
minvs1 has joined #ruby
Swyper has quit [Remote host closed the connection]
Intelo__ has quit [Remote host closed the connection]
jeremycw has joined #ruby
Swyper has joined #ruby
deathwishdave has joined #ruby
kri404 has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Yxhuvud has joined #ruby
<adam12> leitz: If you're targetting a single platform, you could probably build a compiled Ruby to go with it, then have a shim in your init file that sets the path to your vendor'd ruby. If not, you'd have to use something like TravellingRuby which is a bit more complex once you start talking C extensions.
ellcs has quit [Ping timeout: 240 seconds]
<adam12> leitz: Bundler supports an option to package all dependencies up into a single folder, so you would ship it with that package.
<adam12> leitz: It's commonly called an Omnibus package. You might find more examples about how Gitlab does it, etc. if you Google.
Xiti has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4350 has joined #ruby
greengriminal has joined #ruby
<leitz> adam12, thanks!
<leitz> It should mostly be for a limited platform set, I'm still getting details and requirements.
apg has joined #ruby
apg has quit [Changing host]
apg has joined #ruby
<adam12> leitz: JRuby can be distributed as a JAR file too. Then you only need the JRE installed.
* leitz gives adam12 a disdainful look.
<adam12> lulz. JRuby is a hidden gem of the Ruby ecosystem and it's a shame more people don't use it.
* leitz has spent more than a decade dealing with poor Java programming and programmers.
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
blackmesa1 has quit [Ping timeout: 250 seconds]
FlorianFa has quit [Remote host closed the connection]
<leitz> adam12, I've finally gotten to my long term career goal of being a programmer by actual job title. Mostly because of my Linux skill, not because of my super duper OOP-fu.
millerti has joined #ruby
<leitz> Using Ruby to build the OOP-fu, and will later get back to C or Go if a compiled language is needed.
<leitz> I know Java can be written well, I've just suffered from a lot of "not well". As an older fellow, I have only so much time left to learn, so I'm putting it on fun stuff.
absolutejam2 has quit [Ping timeout: 240 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
SeepingN has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
DTZUZO has joined #ruby
tpanarch1st has joined #ruby
minvs1 has quit [Quit: My Mac Pro has gone to sleep. ZZZzzz…]
<NL3limin4t0r> I just started learning Haskell, which (thus far) is also quite fun.
<adam12> leitz: Just saying, in this case, you'd have the JRE installed as a dependency on the platform and then send someone a single JAR file. It might be a great use for you.
<adam12> leitz: But I understand you're opinion of Java :)
<adam12> s/you're/your
leah2 has quit [Ping timeout: 250 seconds]
leah2 has joined #ruby
bluetown has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.6]
drincruz_ has quit [Ping timeout: 240 seconds]
drincruz has joined #ruby
_axx has quit [Quit: The Lounge - https://thelounge.chat]
_axx has joined #ruby
_axx has quit [Client Quit]
absolutejam2 has joined #ruby
<leitz> Heh, I just got a polite "no thanks" when asking of they wanted help.
<NL3limin4t0r> s/of/if/
impermanence has joined #ruby
cthulchu_ has joined #ruby
rapha has left #ruby ["WeeChat 2.3"]
<NL3limin4t0r> leitz: C is a pretty good language to have under your belt. Since it's so low-level it helps you understand a lot of other languages better.
_axx has joined #ruby
absolutejam2 has quit [Ping timeout: 268 seconds]
qolq has quit [Ping timeout: 240 seconds]
cyclonis_ has joined #ruby
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cyclonis has quit [Ping timeout: 250 seconds]
grilix has quit [Ping timeout: 246 seconds]
cyclonis has joined #ruby
cyclonis_ has quit [Ping timeout: 245 seconds]
mossplix has quit [Remote host closed the connection]
<leitz> NL3limin4t0r, most of the job reqs I see in my field are C-ish, Python, or Java. I figure I can build my rapid prototyping resume with Ruby, and then if more performance is needed, put some of it in C.
<leitz> Go is pretty cool, but fewer jobs right now.
al2o3-cr has quit [Quit: WeeChat 2.6]
al2o3-cr has joined #ruby
n88 has quit [Quit: Lost terminal]
tpanarch1st has quit [Ping timeout: 240 seconds]
sputnik13 has joined #ruby
conta has joined #ruby
rippa has joined #ruby
conta has quit [Client Quit]
suukim has quit [Quit: Konversation terminated!]
mossplix has joined #ruby
cthulchu_ has quit [Ping timeout: 245 seconds]
dionysus70 has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
dionysus69 has quit [Ping timeout: 265 seconds]
dionysus70 is now known as dionysus69
xMopx has quit [Ping timeout: 240 seconds]
mossplix has quit [Remote host closed the connection]
troulouliou_div2 has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
xMopx has joined #ruby
paraxial has quit [Quit: The Lounge - https://thelounge.chat]
SzeregowyPosel has joined #ruby
paraxial has joined #ruby
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
blackmesa1 has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
paraxial has quit [Ping timeout: 240 seconds]
paraxial has joined #ruby
dionysus69 has quit [Ping timeout: 268 seconds]
akem has quit [Ping timeout: 265 seconds]
mossplix has joined #ruby
jsaak has joined #ruby
snickers has joined #ruby
dionysus69 has joined #ruby
VSpike has joined #ruby
mossplix has quit [Read error: Connection reset by peer]
DTZUZU has joined #ruby
tdy has joined #ruby
grilix has joined #ruby
SzeregowyPosel has quit [Quit: Bye Bye]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cd has joined #ruby
ropeney has quit [Ping timeout: 268 seconds]
dellavg has quit [Ping timeout: 240 seconds]
mossplix has joined #ruby
nowhere_man has joined #ruby
mossplix has quit [Read error: No route to host]
Inline__ has joined #ruby
NL3limin4t0r is now known as NL3limin4t0r_afk
fphilipe has quit [Ping timeout: 265 seconds]
sgen has joined #ruby
<VSpike> Is this https://dpaste.de/RWKT a reasonable way to transform that data as shown?
Inline has quit [Ping timeout: 264 seconds]
<adam12> VSpike: I'd probably use `each_line`.
<adam12> VSpike: And I might be inclined to not map over it a second time.
<adam12> (depending on the size of it, what you're doing, etc)
<al2o3-cr> VSpike: raw.split.each_slice(2).to_a
<al2o3-cr> maybe
bitwinery has joined #ruby
poontangmessiah has joined #ruby
<al2o3-cr> oh, you want integer pids
<adam12> "7618 bash\n62275 bash\n62859 bash".each_line.map { |line| line.split.yield_self {|pid, name| [pid.to_i, name] } }
bitwinery has quit [Remote host closed the connection]
bitwinery has joined #ruby
kyrylo has joined #ruby
<al2o3-cr> raw.split.each_slice(2).map { |pid, prog| [pid.to_i, prog] }
dionysus69 has quit [Ping timeout: 265 seconds]
<al2o3-cr> adam12: you can use #then for #yield_self
<adam12> al2o3-cr: I try not to in concern of confusing the juniors.
<al2o3-cr> adam12: fair play ;)
cthulchu_ has joined #ruby
<adam12> al2o3-cr: Naming sucks :)
<al2o3-cr> it certainly does.
wildtrees has joined #ruby
<al2o3-cr> raw.split.each_slice(2).with_object([]) { |(pid, prog), container| container << [pid.to_i, prog] }
d^sh has quit [Ping timeout: 276 seconds]
wildtrees has quit [Max SendQ exceeded]
<al2o3-cr> VSpike: there is many ways and yours is also reasonable.
<adam12> Chaining Enumerable is just so enjoyable.
wildtrees has joined #ruby
ropeney has joined #ruby
<NL3limin4t0r_afk> &>> "7618 bash\n62275 bash\n62859 bash".split.each_slice(2).map { |pid, name| [pid.to_i, name] }
<rubydoc> # => [[7618, "bash"], [62275, "bash"], [62859, "bash"]] (https://carc.in/#/r/7u54)
fphilipe has joined #ruby
cyclonis_ has joined #ruby
<leftylink> don't you wish we had CONTROL ARROW
<NL3limin4t0r_afk> al2o3-cr: .split.each_slice(2) is nicely found though, hadn't though about that initially
cyclonis has quit [Ping timeout: 245 seconds]
gix has joined #ruby
<leftylink> hmm how would that work
bambanx has joined #ruby
<al2o3-cr> NL3limin4t0r_afk: i'm very fond of each_slice i use it often
<NL3limin4t0r_afk> I have to go, already marked myself as afk 10 minutes ago. Workday is over =)
<leftylink> hooray
<leftylink> &>> module Arrow def self.first; ->((a, b)) { [(yield a), b] } end end; [[?1, 'bash'], [?2, 'top'], [?3, 'ps']].map(&Arrow.first(&:to_i))
<rubydoc> # => [[1, "bash"], [2, "top"], [3, "ps"]] (https://carc.in/#/r/7u55)
<VSpike> Thanks for all the suggestions :) I'll read up on the ones I don't understand. Little self-contained things like this are a good way to gain familiarity with language idioms so it's great to see a few alternatives
fphilipe has quit [Ping timeout: 252 seconds]
<VSpike> Oh, each_slice is very handy
<leftylink> BUT I just read about it and Arrow is a typeclass over `Category a`
<leftylink> I jsut don't know about any other Categories since using it on 2-tuples is the only time I've used it
<al2o3-cr> VSpike: just benchmarked them and yours runs fastest.
<adam12> al2o3-cr: I find that interesting. I wonder where the performance comes from.
<al2o3-cr> lines 4.8 i/s | each_line 4.1 i/s - 1.16x slower | each_slice 4.1 i/s - 1.18x slower | with_object 4.1 i/s - 1.19x slower
<al2o3-cr> adam12: i'm not sure tbh
<adam12> al2o3-cr: I figured map.map was getting into O(N2) or so, with single map being O(N).
<adam12> Maybe it's not even that. Interesting.
<al2o3-cr> adam12: suprised me too
<VSpike> Heh al2o3-cr ... pure fluke :)
<al2o3-cr> VSpike: ;)
<adam12> al2o3-cr: I wonder if the benchmark would change with larger dataset. My concern with lines over each_line is memory bloat.
<VSpike> Does lines() vs each_line convert to a list vs an enumerable?
<al2o3-cr> adam12: i'm putting a concrete yes to that, it has to do, surely.
<VSpike> Just confirmed that for myself
<adam12> VSpike: #lines is an Array (which includes Enumerable), and #each_line would be an Enumerable.
<VSpike> My background is Python (and C#) so yep, this makes sense
<al2o3-cr> VSpike: lines returns an array, each_line returns an enumerator
<adam12> VSpike: If you were reading in a large file, each_line would likely read until the next newline into a buffer, and return that buffer. So you won't end up with an enormous string containing the entire file.
<VSpike> Yeah ... like using generators in python
<al2o3-cr> VSpike: similar, yes.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dhollinger has quit [Ping timeout: 268 seconds]
grvgr has joined #ruby
dhollinger has joined #ruby
<leftylink> hmm
<leftylink> need to figure out what I call the *** operator
<al2o3-cr> hyper operator?
<al2o3-cr> hyper splat i mean
<al2o3-cr> actually that could of been someone on the bug-tracker.
sputnik13 has quit [Quit: Textual IRC Client: www.textualapp.com]
<leftylink> hmmmmmmm dang, I don't think I can get to use the & to_proc thing if I use ***
<leftylink> &>> module Arrow def self.starstarstar(f, g); ->((a, b)) { [f[a], g[b]] } end end; [[1, 2], [3, 4], [5, 6]].map(&Arrow.starstarstar(:to_s.to_proc, :succ.to_proc))
<rubydoc> # => [["1", 3], ["3", 5], ["5", 7]] (https://carc.in/#/r/7u56)
<leftylink> suggestions gladly taken
ropeney has quit [Quit: ZNC 1.7.4 - https://znc.in]
ropeney has joined #ruby
SzeregowyPosel has joined #ruby
queip has quit [Ping timeout: 252 seconds]
queip has joined #ruby
<al2o3-cr> adam12: suprising results with bigger data. https://gist.github.com/gr33n7007h/58807fd5f664d84c6565684a363220ac
<al2o3-cr> i was almost certain #each_line would be fastest.
<adam12> al2o3-cr: Crazy. Me too.
<adam12> al2o3-cr: I guess each_line _is_ a loop of a loop kinda? where is Array looses the redundant loop.
SzeregowyPosel has quit [Quit: Bye Bye]
<al2o3-cr> i suppose, i'm not quite sure
cthulchu_ has quit [Read error: Connection reset by peer]
orbyt_ has joined #ruby
cyclonis has joined #ruby
<adam12> al2o3-cr: What's with iter.times? Does benchmark/ips not handle that for you? When I drop that inner loop, results are much much different.
<al2o3-cr> hmm...
cyclonis_ has quit [Ping timeout: 245 seconds]
<al2o3-cr> let me run that
<al2o3-cr> adam12: i still get same results with yours
<al2o3-cr> but lines faster than with_object this time
cthulchu has joined #ruby
sameerynho has joined #ruby
<adam12> al2o3-cr: They're so close I imagine the margin of error is undetectable.
<al2o3-cr> that's true
<al2o3-cr> but really it's quite a difference in a benchmark
<adam12> al2o3-cr: I wonder what would happen if test data was separate, and a File object was used as test data.
<al2o3-cr> let's test ;)
falconfox has joined #ruby
Azure has joined #ruby
nowhere_man has quit [Ping timeout: 268 seconds]
greypack has quit [Ping timeout: 240 seconds]
donofrio has joined #ruby
<baweaver> leftylink: Congrats on discovering applicatives
<baweaver> Give this series a read, it'll give you some magnificently bad ideas
TomyWork has quit [Remote host closed the connection]
<baweaver> Well, more of Functors really
<baweaver> interesting how frequently those design patterns intersect
<baweaver> Now for ***, I may be able to make that work
<baweaver> but it'd do real bad things
<baweaver> The easier way is to just use `def self.[]() end
Inline__ has quit [Quit: Leaving]
Inline has joined #ruby
<leftylink> argh, so
<leftylink> &>> 1.** *3
<rubydoc> # => 1 (https://carc.in/#/r/7u59)
<leftylink> so that is valid syntax
<leftylink> can't get rid of the space in between though
<leftylink> and would need to make to_a on procs
<baweaver> to_ary wasn't it?
dionysus69 has joined #ruby
<baweaver> RE: Applicatives
<baweaver> This part specifically: [(*2), (+3)] <*> [1, 2, 3]
<baweaver> [2, 4, 6, 4, 5, 6]
<baweaver> Though the implementation of that `ap` is flattened
<baweaver> and interleaved as well
<baweaver> and not* interleaved
<baweaver> The thing about `ap` and `map` / `fmap` is they're more of contracts or interfaces, you still have to implement them.
<baweaver> For an array, map is defined as applying a function to every element. For any object it could be defined as applying a function to itself
<baweaver> In Ruby these are `map` and `then` / `yield_itself` respectively.
d^sh has joined #ruby
<baweaver> Though now that Proc has `compose` and `<<` those are technically `fmap` like functions too
<baweaver> leftylink: Do you know what a Monoid is?
<baweaver> Those are fun, and real danged useful, even to immediate Ruby programs
<adam12> al2o3-cr: Results unsurprising. https://gist.github.com/4a6778bb04d3ea7c8122d57c960c6847
absolutejam2 has joined #ruby
fphilipe has joined #ruby
<adam12> al2o3-cr: (IO.lines is deprecated on Ruby 2.6 so I silenced warnings from it)
_axx has quit [Quit: The Lounge - https://thelounge.chat]
_axx has joined #ruby
<al2o3-cr> it seems reasonable as its returning enumerators for them three i imagine
impermanence has quit [Ping timeout: 240 seconds]
fphilipe has quit [Ping timeout: 276 seconds]
<havenwood> [2.:*, 3.:+].product([1, 2, 3]).each_tuple.map(&:call)
<havenwood> #=> [2, 4, 6, 4, 5, 6]
<leftylink> oh ha ha you can define ** to take 0 operands lol why would they let you do that
<leftylink> &>> module Arrow refine Proc do def **; self end; def *(g); ->((a, b)) { [self[a], g[b]] } end end end; using Arrow; p [[1, 2], [3, 4], [5, 6]].map(&(:to_s.to_proc.***:succ.to_proc))
<rubydoc> # => [["1", 3], ["3", 5], ["5", 7]]... check link for more (https://carc.in/#/r/7u5f)
<leftylink> why would they allow this!!!!!!
<leftylink> lol
<leftylink> baweaver: I might have once read what a monoid is... but it's not internalised enough where I can look at something and think "I recognise this as a monoid"
wickedbloodfart has quit [Quit: wickedbloodfart]
<baweaver> leftylink: Do you know about Integers and Addition?
<baweaver> You can add two Integers with `+` and get another Integer
jacksoow has quit [Read error: Connection reset by peer]
<leftylink> &>> class Thing; def **; "yup, ** with no args... " end end; Thing.new.*** 5
<rubydoc> # => "yup, ** with no args... yup, ** with no args... yup, ** with no args... yup, ** with no args... yup, ** with no args... " (https://carc.in/#/r/7u5g)
<leftylink> when would someone ever want ** with no args...
<baweaver> You could group them however as long as you retain their order: a + b + c == a + (b + c) == ....
<baweaver> and there's an Integer you can add to any other Integer and get back the same Integer
<baweaver> 0
<baweaver> 0 + 1 == 1 + 0 == 1
<baweaver> Now switch that to Integer and Multiplication, and that empty element becomes `1` instead of `0`
jacksoow has joined #ruby
<baweaver> Or make that Strings with `+` and `""`
<baweaver> Or Array with `+` and `[]`
<baweaver> Or Hash with `merge` and `{}`
<baweaver> All of those start looking suspiciously similar
kri404 has quit [Quit: Leaving]
<phaul> some ppl (like me) don't like down to earth explanations materializing abstractions in concrete examples. It's doesn't work on everyone. I understand abstract concept quite well, just don't give me examples. All I am saying is it doesnt work on everyone.
kri404 has joined #ruby
<baweaver> That's because they're all Monoids. Something which has a `join` operation which gives back something of the same type (Closure), with an empty element that can be joined to anything to get back that thing (identity / empty), and can be grouped as long as you retain order (associativity)
kri404 has quit [Remote host closed the connection]
kri404 has joined #ruby
cd has quit [Quit: cd]
Tempesta has quit [Quit: See ya!]
jacksoow has quit [Read error: Connection reset by peer]
<phaul> an other way to go about it: monoid is a set together with an associative binary operation on it (which is closed on the set) and that operation has a unit.
<al2o3-cr> havenwood: that's pretty cool actually: https://zverok.github.io/blog/2019-10-18-each_with_object.html
jacksoow has joined #ruby
<baweaver> As someone without a math background I'd just stare blankly at that
<baweaver> I mean I get it now because I'd actually bothered to study it, but before? Next to no chance.
<phaul> yeah. It depends on the person. I agree. But for quite a few examples make things confusing. we are different
<baweaver> Nothing wrong with that
<phaul> my usual problem with the examples first approach is that I never know how much of the actual example the abstraction contains. Like for instance integers. they are much more than just a monoid. Like them being a group, haviving two distincts monoids, one with +, and 0 one with * and 1. So I think that's why some ppl like difinition first examples after
matheusmoreira has quit [Quit: leaving]
AJA4351 has joined #ruby
jrafanie has joined #ruby
poontangmessiah has quit [Ping timeout: 245 seconds]
AJA4350 has quit [Ping timeout: 268 seconds]
AJA4351 is now known as AJA4350
<phaul> it's more prominent with monads... are monads container typie things? are they continuations? are they actions? are they IO etc. once I looked at the definition I understood the whole thing, but not through examples
dionysus69 has quit [Ping timeout: 250 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
Tempesta has joined #ruby
jacksoow_ has joined #ruby
jacksoow has quit [Ping timeout: 268 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #ruby
nickjj has joined #ruby
<nickjj> are there any nokogiri wizards around? i'm trying to parse out a specific <ul> element that comes after a specific h2's text -- here's an example and expected output: https://gist.github.com/nickjj/3cca10e989b1c3ba10d0bba5d257bb44
<nickjj> i tried all sorts of things using following-sibling, but it doesn't want to play nice, i always get a bunch of empty output instead of the nodes themselves
SzeregowyPosel has joined #ruby
AJA4351 has joined #ruby
cyclonis has quit [Ping timeout: 246 seconds]
chalkmonster has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
cyclonis_ has joined #ruby
AJA4350 has quit [Ping timeout: 268 seconds]
AJA4351 is now known as AJA4350
<go|dfish> nickjj: '//h2[text() = "Hello World"]/following-sibling::ul[1]'
greengriminal has joined #ruby
<nickjj> go|dfish, what killed me was having // at the start , once i dropped that, things started to get found
<nickjj> i guess it's because i'm working with jekyll and i was only dealing with a fragment of the html, not the entire result
<go|dfish> ah
<nickjj> but oddly enough i wasn't able to iterate over the ul, to get its li children
jeremycw has quit [Ping timeout: 276 seconds]
<nickjj> go|dfish, thanks, your [1] trick did it -- i was using (...).first, which wasn't quite what i wanted to do
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: This computer has gone to sleep]
howdoi has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.6]
jacksoow_ has quit [Ping timeout: 240 seconds]
jacksoow has joined #ruby
cyclonis_ has quit [Ping timeout: 276 seconds]
kri404 has quit [Quit: Leaving]
hiroaki_ has joined #ruby
lxsameer has quit [Ping timeout: 245 seconds]
thomas_25 has quit [Quit: FreeZNC - Visit us! Server: irc.freenode.org Channel: #bnc4you]
jmcgnh has quit [Read error: Connection reset by peer]
jrafanie has joined #ruby
jrafanie has quit [Client Quit]
AJA4351 has joined #ruby
jmcgnh has joined #ruby
AJA4350 has quit [Ping timeout: 276 seconds]
AJA4351 is now known as AJA4350
Technodrome has quit [Remote host closed the connection]
schne1der has joined #ruby
leitz has quit [Quit: Leaving]
stryek has quit [Quit: Connection closed for inactivity]
Fusl has quit [Max SendQ exceeded]
Fusl has joined #ruby
fphilipe has joined #ruby
drincruz has quit [Ping timeout: 240 seconds]
Esa_ has joined #ruby
thomas_25 has joined #ruby
fphilipe has quit [Ping timeout: 245 seconds]
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
aeikenberry has joined #ruby
brool has joined #ruby
afisher has quit [Excess Flood]
afisher has joined #ruby
falconfox has quit [Ping timeout: 276 seconds]
sgen has quit [Ping timeout: 245 seconds]
snickers has quit [Quit: Textual IRC Client: www.textualapp.com]
cyclonis has joined #ruby
sameerynho has quit [Ping timeout: 268 seconds]
aeikenberry has quit [Quit: Be back later ...]
<leftylink> hi, what I miss
<leftylink> ok cool
cd has joined #ruby
<Frankenstein> leftylink: everyone decided to start using perl
xGrind has joined #ruby
reber has quit [Remote host closed the connection]
brool has quit [Ping timeout: 250 seconds]
cthulchu has quit [Ping timeout: 250 seconds]
eljimmy has quit [Quit: This computer has gone to sleep]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
cadeskywalker has quit [Ping timeout: 240 seconds]
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
akemhp has joined #ruby
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
eljimmy has joined #ruby
eljimmy has quit [Client Quit]
absolutejam2 has quit [Ping timeout: 240 seconds]
SzeregowyPosel has quit [Quit: Bye Bye]
cadeskywalker has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 265 seconds]
AJA4351 is now known as AJA4350
blackmesa1 has quit [Ping timeout: 246 seconds]
ogres has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
<nisstyre> Frankenstein: you mean Raku
<Frankenstein> haha
<Frankenstein> is there a method to convert seconds (stored in an Integer) to hours, minutes and seconds?
Nicmavr has joined #ruby
greengriminal has joined #ruby
<leftylink> think we just gotta go for the repeated divmods
<Frankenstein> i was afraid of that
<Frankenstein> thanks
grilix has quit [Ping timeout: 240 seconds]
<Frankenstein> oh hey, Time.at(seconds).utc.strftime("...")
fphilipe has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
d^sh has quit [Ping timeout: 240 seconds]
fanta1 has joined #ruby
fphilipe has quit [Ping timeout: 250 seconds]
dasher00 has quit [Ping timeout: 265 seconds]
d^sh has joined #ruby
Fernando-Basso has quit [Quit: Leaving]