<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)
<rubydoc>
stderr: -e:4:in `<main>': undefined method `to_jsona' for {:"1"=>:foo}:Hash (NoMethodError)... check link for more (https://carc.in/#/r/7tyb)
<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/)
<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]
<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 :)
<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]
<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.
<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.
<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.
<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]
<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]