havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.0, 2.6.5, 2.5.7: 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!
<al2o3-cr> nil & (any object) i should say.
<al2o3-cr> &>> [[0].pack('J'), [~0].pack('J')]
<rubydoc> # => ["\x00\x00\x00\x00\x00\x00\x00\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"] (https://carc.in/#/r/8r84)
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
kashike has quit [Ping timeout: 240 seconds]
dhoc has joined #ruby
kashike has joined #ruby
<al2o3-cr> _phaul: can you explain it?
<_phaul> no I can't.. I will look into it, hopefully will come out with some understanding. Give me a break... It's 00:10 I watched friends all day on lockdown... And Ross has just broken up with Rachel
<al2o3-cr> haha, no problem _phaul. shit, i watched that back in the 90's lol :P
zlogan has quit [Ping timeout: 246 seconds]
darkstardevx has joined #ruby
<al2o3-cr> i had thing for lisa kudrow back then :P
<al2o3-cr> &>> -2r ** 2
<rubydoc> # => (-4/1) (https://carc.in/#/r/8r85)
zlogan has joined #ruby
TCZ has joined #ruby
ur5us has quit [Ping timeout: 246 seconds]
<umu> oops my bad wrong chan
<al2o3-cr> oops, not rational but imaginary
<al2o3-cr> &>> -2i.itself ** 2
<rubydoc> # => (-4+0i) (https://carc.in/#/r/8r8a)
caterfxo has quit [Quit: leaving]
caterfxo has joined #ruby
dionysus69 has quit [Quit: dionysus69]
caterfxo has quit [Client Quit]
ur5us has joined #ruby
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo2 has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
dhoc has quit [Quit: dhoc]
jmcgnh has quit [Read error: Connection reset by peer]
kristian_on_linu has quit [Remote host closed the connection]
jmcgnh has joined #ruby
gix has quit [Quit: Client exiting]
sergioro has quit [Quit: leaving]
henninb has joined #ruby
sergioro has joined #ruby
ChmEarl has quit [Quit: Leaving]
meinside has joined #ruby
Translat-Embedde has left #ruby [#ruby]
henninb has quit [Quit: leaving]
cschneid_ has quit [Ping timeout: 256 seconds]
cschneid has joined #ruby
mthsgrc has quit [Ping timeout: 240 seconds]
jingjinghack has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
alfiemax has joined #ruby
TCZ has quit [Quit: Leaving]
ghormoon has quit [Ping timeout: 246 seconds]
drincruz_ has quit [Ping timeout: 250 seconds]
ghormoon has joined #ruby
drincruz_ has joined #ruby
alfiemax has quit [Remote host closed the connection]
donofrio has joined #ruby
drincruz_ has quit [Ping timeout: 246 seconds]
dviola has quit [Quit: WeeChat 2.7.1]
polishdub has joined #ruby
chihhsin has quit [Ping timeout: 256 seconds]
chihhsin has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
plutes has quit [Quit: See ya around!]
Technodrome has joined #ruby
NightMonkey has quit [Quit: ZNC - http://znc.in]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
NightMonkey has joined #ruby
braincrash has quit [Quit: bye bye]
braincrash has joined #ruby
drincruz_ has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
drincruz_ has quit [Ping timeout: 250 seconds]
cschneid has quit [Ping timeout: 256 seconds]
cschneid_ has joined #ruby
_whitelogger has joined #ruby
TzilTzal has joined #ruby
orbyt_ has joined #ruby
<TzilTzal> Hi
<TzilTzal> Does anyone know whether it's possible to create Settinglogic from a string/hash? and not from a file? It seems as thought from a hash it's possible but I keep getting errors.
d3bug has quit [Quit: Connection closed for inactivity]
kristian_on_linu has joined #ruby
<havenwood> TzilTzal: What's a Settinglogic?
<havenwood> TzilTzal: Show the errors?
kristian_on_linu has quit [Remote host closed the connection]
xco has joined #ruby
imadper has joined #ruby
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
dinfuehr has quit [Ping timeout: 264 seconds]
dStromboli has joined #ruby
dinfuehr has joined #ruby
markopasha has joined #ruby
comet23 has joined #ruby
drincruz_ has joined #ruby
polishdub has quit [Quit: leaving]
jetchisel has joined #ruby
drincruz_ has quit [Ping timeout: 246 seconds]
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
dStromboli has quit [Ping timeout: 250 seconds]
alexherbo2 has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tsujp has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
markopasha has quit [Ping timeout: 246 seconds]
bvdw has quit [Read error: Connection reset by peer]
<xco> al2o3-cr xco: make an install message for your gem ;) << by that you meant a post install message? :D
bvdw has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
ur5us has joined #ruby
hiroaki has quit [Ping timeout: 240 seconds]
<pyrmont> TzilTzal: The docs for that gem now live at https://rdoc.info/github/settingslogic/settingslogic/. The constructor in the docs for Settingslogic indicates it's possible to create from a hash. If you do that, the value of the instance of Settingslogic is replaced with the contents of the hash.
<TzilTzal> pyrmont: I know it indicates that.. but when I pass in a hash, I keep getting errors trying to access the structure through members named based on the keys
<pyrmont> Can you paste the code and errors as a gist?
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
william1_ has joined #ruby
iNs has quit [Remote host closed the connection]
iNs_ has joined #ruby
william1_ has quit [Ping timeout: 250 seconds]
schne1der has joined #ruby
drincruz_ has joined #ruby
drincruz_ has quit [Ping timeout: 258 seconds]
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
alfiemax has joined #ruby
<_phaul> al2o3-cr: reading back.. now I get it. But it's pretty much WTF
<_phaul> -2 is just an integer constant -2
<_phaul> &asm>> -2
<rubydoc> I have disassembled your code, the result is at https://carc.in/#/r/8r93
<_phaul> but it changes it's meaning if it's inside an expression like
<_phaul> &asm>> -2 ** 2
<rubydoc> I have disassembled your code, the result is at https://carc.in/#/r/8r94
ur5us has quit [Ping timeout: 260 seconds]
<_phaul> WAT
<_phaul> its*
Gestahlt has joined #ruby
<_phaul> and then it changes back: -2.**(2) is again -2 constant literal
<Gestahlt> Hi, i have a question about rails tho - I use Rails 6 with a new app i write, now i want to dynamically create routes based on a configuration file (and also some more stuff). I assume i have to execute the code after startup of the rails server
<Gestahlt> Well, the funny thing is, i logged the rails startup and see that the class i want to instanciate is loaded (app/lib/klass.rb) but when i call it, it says undefined constant
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
<Gestahlt> when i call it in the console tho, it works, so it is unavailable in config/application.rb (While it is clearly shown with Rails.autoloaders.log! that it is loaded), but i cannot call it from the autoloaders.rb
<Gestahlt> Arrr
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 240 seconds]
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
comet23 has quit [Quit: Connection closed for inactivity]
TomyWork has joined #ruby
william1_ has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cschneid_ has quit [Quit: ZNC 1.7.5 - https://znc.in]
william1_ has quit [Quit: WeeChat 2.6]
sepiol01 has joined #ruby
<sepiol01> hi
<_phaul> sepiol01: hi
alfiemax has quit [Remote host closed the connection]
sepiol01 has quit [Quit: WeeChat 1.9.1]
TzilTzal has quit [Quit: Leaving.]
jacksop has joined #ruby
conta has joined #ruby
cschneid has joined #ruby
conta has quit [Quit: conta]
tsujp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bvdw has quit [Quit: bvdw]
bvdw has joined #ruby
chalkmonster has joined #ruby
alexherbo20 has joined #ruby
chalkmonster has quit [Client Quit]
alexherbo2 has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
alexherbo2 has joined #ruby
alexherbo20 has quit [Ping timeout: 250 seconds]
xco has joined #ruby
dreamreal has quit [Quit: WeeChat 2.7.1]
mistergibson has joined #ruby
sh7d has quit [Quit: meh]
roadie has quit [Ping timeout: 250 seconds]
sh7d has joined #ruby
clemens3 has quit [Quit: quit]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
clemens3 has joined #ruby
drincruz_ has joined #ruby
zlogan has quit [Read error: Connection reset by peer]
drincruz_ has quit [Ping timeout: 256 seconds]
rmnull has quit [Ping timeout: 272 seconds]
rmnull has joined #ruby
gix has joined #ruby
mistergibson has quit [Quit: Leaving]
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
phaul has joined #ruby
Gestahlt has quit [Quit: Leaving]
conta has joined #ruby
code_zombie has quit [Quit: Leaving]
_phaul has quit [Ping timeout: 240 seconds]
Technodrome has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 256 seconds]
Emmanuel_Chanel has joined #ruby
alfiemax has joined #ruby
_phaul has joined #ruby
alfiemax has quit [Ping timeout: 256 seconds]
phaul has quit [Ping timeout: 258 seconds]
sylario has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
sergioro has quit [Quit: leaving]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
roadie has joined #ruby
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
conta has quit [Quit: conta]
alfiemax has joined #ruby
roadie has quit [Ping timeout: 264 seconds]
vondruch_ has joined #ruby
ellcs has joined #ruby
vondruch has quit [Ping timeout: 250 seconds]
vondruch_ is now known as vondruch
ellcs has quit [Ping timeout: 246 seconds]
<hramrach> hello
<hramrach> how can I get all regexp grup matches?
<hramrach> "numbers: one two three # we don't need more numbers defined here".match(/(^[^:]+):([ \t]*[^# \t]+)*/)
<hramrach> => #<MatchData "numbers: one two three" 1:"numbers" 2:" three">
<hramrach> one and two are lost
drincruz_ has joined #ruby
gix has quit [Quit: Client exiting]
gix has joined #ruby
fercell has joined #ruby
dhoc has joined #ruby
roadie has joined #ruby
dhoc has quit [Ping timeout: 260 seconds]
drincruz_ has quit [Ping timeout: 264 seconds]
xco has joined #ruby
burningserenity has joined #ruby
drincruz_ has joined #ruby
roadie has quit [Ping timeout: 260 seconds]
rmnull1 has joined #ruby
rmnull1 has quit [Client Quit]
rmnull has quit [Ping timeout: 246 seconds]
rmnull has joined #ruby
chalkmonster has joined #ruby
zapata has quit [Quit: WeeChat 2.7.1]
zapata has joined #ruby
phaul has joined #ruby
_phaul has quit [Ping timeout: 250 seconds]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
jacksop has quit [Remote host closed the connection]
roadie has joined #ruby
nyuszika7h has joined #ruby
<nyuszika7h> I'm getting this error for a Rails migration and I can't figure out what's wrong, the type does match https://dpaste.org/ptx3
<nyuszika7h> here's the migration: https://dpaste.org/R0DW
jingjinghack has quit [Quit: WeeChat 2.1]
jcalla has joined #ruby
jingjinghack has joined #ruby
burningserenity has quit [Ping timeout: 240 seconds]
GodFather has quit [Ping timeout: 265 seconds]
<nyuszika7h> ah, got it, it's a missing index
<nyuszika7h> in the referenced table
jingjinghack has quit [Quit: WeeChat 2.1]
conta has joined #ruby
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 264 seconds]
burningserenity has joined #ruby
_phaul has joined #ruby
phaul has quit [Ping timeout: 250 seconds]
alfiemax has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
pupsikov has joined #ruby
caterfxo has joined #ruby
jacksop has joined #ruby
vondruch has joined #ruby
vondruch has quit [Client Quit]
noboruma has joined #ruby
fluxAeon has quit [Ping timeout: 250 seconds]
leitz has joined #ruby
fluxAeon has joined #ruby
vondruch has joined #ruby
GodFather has joined #ruby
jacksop has quit [Ping timeout: 240 seconds]
conta has quit [Quit: conta]
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
<leitz> Has anyone done the Ruby certification exam?
jacksop has joined #ruby
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
ellcs has joined #ruby
jacksop has quit [Remote host closed the connection]
cranq has joined #ruby
d3bug has joined #ruby
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #ruby
lucasb has joined #ruby
ChmEarl has joined #ruby
MrCrackPot has quit [Quit: Leaving]
<havenwood> leitz: I did the practice questions, which were kinda fun. I haven't actually taken it, but I remember being interested a while back that they were adding a harder level.
phaul has joined #ruby
<havenwood> hramrach: You can call #captures on the Matchdata.
<havenwood> hramrach: Consider using named captures.
_phaul has quit [Ping timeout: 250 seconds]
<havenwood> &>> "numbers: one two three # we don't need more numbers defined here".match(/(?<type>^[^:]+):(?<amount>[ \t]*[^# \t]+)*/).named_captures
<rubydoc> # => {"type"=>"numbers", "amount"=>" three"} (https://carc.in/#/r/8r9u)
<havenwood> hramrach: Ohhh, I misunderstood your question. Got it now.
caterfxo is now known as itried
itried has quit [Quit: leaving]
caterfxo has joined #ruby
brendan- has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
<leitz> havenwood, they have a Silver and Gold, and the page references Platinum. I figure it'd be useful as an outline to make sure my skills are decently rounded.
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 256 seconds]
<leitz> havenwood, I have actually seen job reqs that want a language certification. Didn't care what, just something. The options are limited: Java, PHP, SQL. Not too many others.
chalkmonster has quit [Quit: WeeChat 2.7.1]
<apotheon> leitz: If I *had* to get a language cert and it didn't matter which, and my choices were Java, PHP, Ruby, and SQL, I would definitely go for Ruby.
davor has quit [Ping timeout: 264 seconds]
<apotheon> . . . just for the sake of not being as annoyed by the cert.
davor has joined #ruby
chalkmonster has joined #ruby
<leitz> apotheon, it gets worse! The Software Engineering certificate is based on Java 5, IIUC. Pretty funny.
<apotheon> lovely
<apotheon> I should establish a Lambda Calculus language certification.
<leitz> But yeah, Ruby is my choice to go from Apprentice to Journeyman, and using the "focus on getting the cert" should help with the process.
* leitz had to look up lambda calculus.
cschneid_ has quit [Quit: ZNC 1.7.5 - https://znc.in]
<leitz> If you can establish a great training methodology, it would probably work.
_phaul has joined #ruby
phaul has quit [Ping timeout: 258 seconds]
fercell has quit [Remote host closed the connection]
<apotheon> I think perhaps the best approach to lambda calculus for the casual autodidact and, thus, for a formal training program, would start with implementing a lambda calculus parser (with a few enhancements, perhaps, kinda like how Perl's regexen aren't proper "regular expressions"), then write various pieces of software with it.
fercell has joined #ruby
* leitz reminds apotheon that Ruby is great for building DSLs...
<havenwood> hramrach: I think a solution is doable with #match and \G. Lemme think.
chalkmonster has quit [Quit: WeeChat 2.7.1]
<apotheon> leitz: Ruby is the only place I've implemented a lambda calculus parser.
phaul has joined #ruby
<apotheon> I should probably try it in SML, too, some day. I think that would mostly consist of . . . not using a lot of the language.
<apotheon> Oh, shit, that means I've already implemented it.
cschneid has joined #ruby
* leitz reminds apotheon that the "Ruby Weekly" e-mail from Peter Cooper would be a great place to send an article about implementing a lambda calculus parser in Ruby.
_phaul has quit [Ping timeout: 256 seconds]
<apotheon> There's already a book that addresses that kind of thing, so my commentary would be redundant.
<apotheon> q.v. Understanding Computation
<leitz> apotheon, what book?
<apotheon> O'Reilly
<leitz> apotheon, that mean I can ask you questions when I dive into the book?
cow[moo] has joined #ruby
phaul has quit [Ping timeout: 250 seconds]
<apotheon> leitz: You may always ask. I'm not sure I'll remember much about it.
<leitz> Thanks! I'm going to focus on the cert first, that should take me a bit. Not sure when life will return to normal.
phaul has joined #ruby
<apotheon> righto
DTZUZU2 is now known as DTZUZU
<leitz> I want to get my Ruby skills to a better level. It'll help my job search, and projects.
TCZ has joined #ruby
TreeAr has joined #ruby
<apotheon> leitz: You'll be coding circles around me in no time.
phaul has quit [Ping timeout: 264 seconds]
orbyt_ has joined #ruby
phaul has joined #ruby
cthu| has joined #ruby
<leitz> apotheon, I've been coding myself in circles for years; that's what I'm trying to fix. :)
ellcs has quit [Ping timeout: 246 seconds]
<apotheon> nice
ellcs has joined #ruby
cloaked1 has joined #ruby
burningserenity has quit [Remote host closed the connection]
burningserenity has joined #ruby
fercell has quit [Ping timeout: 256 seconds]
_phaul has joined #ruby
SeepingN has joined #ruby
phaul has quit [Ping timeout: 246 seconds]
Emmanuel_Chanel has quit [Ping timeout: 256 seconds]
burningserenity has quit [Ping timeout: 240 seconds]
Emmanuel_Chanel has joined #ruby
roadie has quit [Read error: Connection reset by peer]
TomyWork has quit [Remote host closed the connection]
roadie has joined #ruby
phaul has joined #ruby
TomyWork has joined #ruby
clemens3 has quit [Quit: laterz]
<xco> does Ruby happen to have something in-built to parse reformat dates or I'll have to fallback on Rails' AS methods? For example I want a date like this "3/12/20" to be be "March 12, 2020"
burningserenity has joined #ruby
TomyWork has quit [Remote host closed the connection]
_phaul has quit [Ping timeout: 250 seconds]
<leitz> xco, do Date or DateTime have what you need?
<xco> nope
<xco> just check
<xco> checked*
<xco> but i'm seeing Date.strptime maybe i could work with it
sergioro has joined #ruby
clemens3 has joined #ruby
clemens3 has quit [Client Quit]
clemens3 has joined #ruby
<havenwood> &>> require 'date'; Date.strptime('3/2/79', '%m/%d/%y') # xco
<rubydoc> # => #<Date: 1979-03-02 ((2443935j,0s,0n),+0s,2299161j)> (https://carc.in/#/r/8rae)
<xco> yup! :D
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
Xiti has quit [Read error: Connection reset by peer]
Xiti has joined #ruby
<havenwood> hramrach: Hrm, this works on rubular but not in Ruby. I suspect it's doable with \G or \g subexpressions, but I need coffee... https://rubular.com/r/vpZ3Olwoom6xOc
<havenwood> I've wanted to use the experimental (?~subexpression) but haven't had a chance.
<havenwood> (?:(?!subexpression).)*
<havenwood> Anyone know why rubular disagrees with Ruby there ^?
ferche23 has quit [Ping timeout: 250 seconds]
schne1der has quit [Ping timeout: 265 seconds]
<havenwood> &>> 'numbers: one two three # en fin'[/(?<=:)(.*?)#/].scan(/[^# \t]+/)
<rubydoc> # => ["one", "two", "three"] (https://carc.in/#/r/8raf)
TreeAr has quit [Quit: Going offline, see ya! (www.adiirc.com)]
<havenwood> hramrach: If you want to avoid subexpressions or a \G anchor, you might consider scanning. ^
TCZ has quit [Quit: Leaving]
<havenwood> Oh, I misread rubular between attempts. >.>
<havenwood> 1 1 1 1 1
john2496 has joined #ruby
howdoi has joined #ruby
CalimeroTeknik has joined #ruby
ferche23 has joined #ruby
dionysus69 has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
chalkmonster has joined #ruby
roadie has joined #ruby
fercell has joined #ruby
ellcs has quit [Ping timeout: 246 seconds]
cliluw has joined #ruby
cliluw has quit [Ping timeout: 246 seconds]
cliluw has joined #ruby
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
Chiron has joined #ruby
vondruch_ has joined #ruby
dinfuehr has quit [Ping timeout: 258 seconds]
chalkmonster has quit [Quit: WeeChat 2.7.1]
dinfuehr has joined #ruby
vondruch has quit [Ping timeout: 250 seconds]
vondruch_ is now known as vondruch
alfiemax has joined #ruby
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 240 seconds]
alfiemax has quit [Remote host closed the connection]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
hajen has joined #ruby
ellcs has joined #ruby
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
caterfxo has quit [Quit: leaving]
conta has joined #ruby
hiroaki has joined #ruby
burningserenity has quit [Ping timeout: 260 seconds]
_phaul has joined #ruby
phaul_ has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
dinfuehr has quit [Ping timeout: 250 seconds]
_phaul has quit [Ping timeout: 240 seconds]
bhaak has quit [Ping timeout: 265 seconds]
bhaak has joined #ruby
<xco> need help transforming it to this [["title", "A", "C", "E"], ["title", "B", "D", "F"]]
dinfuehr has joined #ruby
<phaul_> that is impossible hash
<phaul_> hash keys are unique
<phaul_> you have key collision on title
<xco> dam it
<xco> right
<havenwood> xco: Give some more context?
<CommunistWolf> add some [{}] until it all makes sense
hiroaki has quit [Ping timeout: 246 seconds]
hajen has left #ruby [#ruby]
<havenwood> xco: values.map(&:values).transpose
<havenwood> xco: Then shovel an empty string on each.
dinfuehr has quit [Ping timeout: 256 seconds]
chalkmonster has joined #ruby
<havenwood> xco: I replied to your gist.
ellcs has quit [Ping timeout: 246 seconds]
<xco> thank you :)
chalkmonster has quit [Client Quit]
<havenwood> yw
ShekharReddy has joined #ruby
dinfuehr has joined #ruby
<havenwood> xco: Just curious, by why the empty string? What's that for?
<xco> i'll put something there :)
<xco> another string
code_zombie has joined #ruby
<phaul_> can we guess? is it "title" ? :D
<xco> hahaha now
<xco> i'll ask for a review a few minutes
<xco> :D :D
<xco> so you'll know what i'm on to
dinfuehr_ has joined #ruby
dinfuehr has quit [Ping timeout: 240 seconds]
cranq has quit [Remote host closed the connection]
hiroaki has joined #ruby
dinfuehr has joined #ruby
sysh has joined #ruby
dinfuehr_ has quit [Ping timeout: 264 seconds]
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
cranq has joined #ruby
ellcs has joined #ruby
fercell has quit [Quit: WeeChat 2.7.1]
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
cschneid_ has quit [Ping timeout: 256 seconds]
cschneid has joined #ruby
dinfuehr has quit [Ping timeout: 256 seconds]
dinfuehr has joined #ruby
ur5us has joined #ruby
conta has quit [Quit: conta]
Frobozz has joined #ruby
dinfuehr has quit [Ping timeout: 264 seconds]
dinfuehr has joined #ruby
cnsvc has joined #ruby
ShekharReddy has quit []
<hramrach> havenwood: the available documentations states it's not posible. In your example you preserve one, two, and three and lose numbers
<apotheon> havenwood: Is there an updated equivalent to interactive_editor?
<hramrach> so anyway it's possible to do with two consecutive less complex regular expressions which is what I am using
alexherbo2 has quit [Ping timeout: 240 seconds]
<havenwood> hramrach: My example isn't right, but I do think it's possible with Ruby Regexp.
<havenwood> hramrach: Lemme try to find an example.
<havenwood> hramrach: I was multitasking and hoping my wild stab would trigger someone else to answer.
<hramrach> &>> caption, content = 'numbers: one two three # en fin'.match(/(^[^:]+):((?:[ \t]*[^# \t]+)*)/).captures ; [caption, *flags.strip.split(/\s/)]
<rubydoc> stderr: -e:4:in `<main>': undefined local variable or method `flags' for main:Object (NameError)... check link for more (https://carc.in/#/r/8rci)
<hramrach> &>> caption, content = 'numbers: one two three # en fin'.match(/(^[^:]+):((?:[ \t]*[^# \t]+)*)/).captures ; [caption, *content.strip.split(/\s/)]
<rubydoc> # => ["numbers", "one", "two", "three"] (https://carc.in/#/r/8rcj)
schne1der has joined #ruby
<hramrach> the thing is it's not overly useful if it's possible but not really readable
<hramrach> it is just unexpected limitation of matchdata that the interface cannot handle repeat groups
<hramrach> but with this limitation you cannot get the matches and there is easy workaround, too
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
dinfuehr_ has joined #ruby
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
dinfuehr_ has quit [Ping timeout: 250 seconds]
ferche23 has quit [Ping timeout: 256 seconds]
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> hramrach: I'm not finding a \g subexpression or \G anchor example that works for your case, like I hoped. Are you using the #match return value other than for the captures? A #scan alone seems doable. For example, this Rubular from SO with #scan: https://rubular.com/r/jOJRhwJvR4
<havenwood> hramrach: Is this a tight look that you need to optimize, or is readability more important?
schne1der has quit [Quit: schne1der]
robotcars has joined #ruby
<robotcars> rubocop'ing `missing.select { |k| bd[k] != ed['metadata'][k] }` equivalent to `missing.reject { |k| bd[k] == ed['metadata'][k] }`
<robotcars> those return the same, but reject is preffered?
<leftylink> interesting choice by rubocop. I see no reason to prefer either one over the other
dinfuehr has quit [Ping timeout: 256 seconds]
<apotheon> I'd prefer the reject option because it requires fewer keypresses.
<robotcars> lol
<apotheon> They're identical in terms of keypresses except != is three keypresses and == is only two, with the bonus that they're both the same key.
schne1der has joined #ruby
<phaul_> it's a bit like if not vs unless. moves the negation into the verb, so more human readable.
d3bug has quit [Quit: Connection closed for inactivity]
<apotheon> Yes, I do use vi. Why do you ask?
<hramrach> havenwood: the heavy lifting happens in system(). The parsing is not really performance critical
<apotheon> phaul_: That too.
<robotcars> thanks leftylink, the logic seemed sound, and the first way is more readable for what i'm doing
<apotheon> (Actually, phaul_ has a better reason than mine, but I like mine too.)
dinfuehr has joined #ruby
<hramrach> and the rubular example with scan does not return variable number of groups, either
d3bug has joined #ruby
<hramrach> can can do variable number of matches of the whole expression but not of subexpression
<havenwood> hramrach: It returns left and rights, so one more parsing stage.
<havenwood> hramrach: I think a more straightforward approach is better, since it's not performance critical. Sec.
<hramrach> oh, right. this does not even process results, it only reads a file with ~50 lines of this stuff
howdoi has quit []
howdoi has joined #ruby
dinfuehr has quit [Ping timeout: 256 seconds]
sysh has quit [Remote host closed the connection]
<hramrach> it would be interesting inconsistency if match returned the repeat groups but I would expect it uses the same underlying engine and hence same result representation
<hramrach> *scan*
dinfuehr has joined #ruby
<hramrach> this will probably fail if the content contains a colon
<havenwood> hramrach: #partion only matches the first colon.
<havenwood> hramrach: Likewise for the lookbehind.
kinduff has quit [Quit: gg]
<havenwood> hramrach: I'd expect it to work.
<hramrach> the lookbehind will probably fail if there is no comment
<havenwood> hramrach: make it optional
<havenwood> hramrach: (I didn't know if a comment is optional.)
<havenwood> Maybe that doesn't make sense.
<havenwood> hramrach: Then I'd change that bit to match up to # or EO{F,L}, whichever comes first.
<havenwood> hramrach: Show a few examples of possible input and desired output and I'm sure folk here can come up with a variety of solutions.
<havenwood> If you provide tests, we can make it pass.
<havenwood> hramrach: string.partition(':').then { [_1, _3.partition('#').first.split] }
kinduff has joined #ruby
<havenwood> hramrach: That ^ should work then, right? Or am I missing something else.
<havenwood> #>> 'numbers: 1 2 3'.partition(':').then { [_1, _3.partition('#').first.split] # hramrach
<havenwood> &>> 'numbers: 1 2 3 # nope'.partition(':').then { [_1, _3.partition('#').first.split] }
<rubydoc> # => ["numbers", ["1", "2", "3"]] (https://carc.in/#/r/8rcu)
<havenwood> Regexp-free solution ran them off. :P
bvdw has quit [Read error: Connection reset by peer]
<havenwood> Oh, haha, thought you left. My IRC client is acting up.
<havenwood> hramrach: What do you think about the double partition, no regexp?
<hramrach> hm, does not work for me
<havenwood> hramrach: What's the fail?
<hramrach> I don't have _1
<havenwood> hramrach: Ah, 2.7 features, sec.
bvdw has joined #ruby
<hramrach> for the lookbehind it fails if comment includes #
<havenwood> 'numbers: 1 2 3 # nope'.partition(':').then { |caption, _, content| [caption, content.partition('#').first.split] }
<havenwood> hramrach: Knowing that req, this is my best stab so far in ^
<hramrach> that's nice, thanks
<havenwood> np, you're welcome
<hramrach> &>> 'numbers: 1 2 3 4:5 6 # #nope'.partition(':').then { |caption, _, content| [caption, *content.partition('#').first.split] }
<rubydoc> # => ["numbers", "1", "2", "3", "4:5", "6"] (https://carc.in/#/r/8rcy)
<havenwood> hramrach: Is that ^ as intended?
<hramrach> yes, that's it
<havenwood> woot
<havenwood> And no Regexp. :)
dinfuehr has quit [Ping timeout: 250 seconds]
<hramrach> so 'then' passes list as block arguments
dinfuehr has joined #ruby
evdubs has quit [Remote host closed the connection]
evdubs has joined #ruby
<hramrach> &>> 'numbers: one two three # en fin'.match(/(^[^:]+):((?:[ \t]*[^# \t]+)*)/).captures.then{|caption, content| [caption, *content.strip.split(/\s/)]}
<rubydoc> # => ["numbers", "one", "two", "three"] (https://carc.in/#/r/8rd1)
<hramrach> "".partition(':').then { |caption, _, content| [caption,*content.partition('#').first.split] }
<hramrach> &>> "".partition(':').then { |caption, _, content| [caption,*content.partition('#').first.split] }
<rubydoc> # => [""] (https://carc.in/#/r/8rd2)
<hramrach> that's nice because match can return nil which is annoying to handle
dinfuehr has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
golevka has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
TCZ has joined #ruby
ellcs has quit [Ping timeout: 246 seconds]
roadie has quit [Ping timeout: 250 seconds]
dinfuehr has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
roadie has joined #ruby
roadie has quit [Ping timeout: 246 seconds]
dinfuehr has quit [Ping timeout: 250 seconds]
dionysus69 has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
cschneid has quit [Ping timeout: 256 seconds]
cschneid has joined #ruby
dinfuehr_ has joined #ruby
<xco> kovid v0.2.1 released! https://github.com/siaw23/kovid
<xco> 🎉
dinfuehr has quit [Ping timeout: 256 seconds]
<havenwood> xco: Congrats!
<xco> havenwood :)
<xco> havenwood btw the require_relative things for covid didn't work :D
<havenwood> xco: Which ones?
<xco> the covid executable
<xco> i did
<havenwood> xco: Ah
<xco> require_relattiv 'kovid'
<havenwood> xco: Huh, unsure why that'd not work.
<xco> i'll figure it out tomorrow when i find some time no worries :)
<xco> thanks
darkstardevx has quit [Quit: Leaving]
<havenwood> xco: #values_at would be nice in multiple places.
<xco> mmm what do you mean?
<xco> talking about some array i'd guess
<havenwood> xco: For example: rows = [cases.values_at('cases', 'deaths', 'recovered'] https://github.com/siaw23/kovid/blob/master/lib/kovid/tablelize.rb#L119
<TCZ> kovid but its not kde based ;p
<havenwood> xco: Method calls are relatively expensive, so it's nice to use a single #values_at rather than multiple #[]s.
<xco> havenwood oh sweet!
<havenwood> xco: It's shorter and faster. :)
<xco> agree
<xco> will fix in next version
<havenwood> xco: 👍🏽
<havenwood> xco: When you see an #each with shoveling, consider #map.
<havenwood> xco: Like here: rows = data.map do |country| https://github.com/siaw23/kovid/blob/master/lib/kovid/tablelize.rb#L78-L80
<havenwood> xco: Then you can ditch the: rows <<
<xco> si senor )
<xco> wow thanks!
<havenwood> xco: I'd then extract a constant. There are a few places I'd still extract constants. It actually increases readability, reduces memory, and is faster too. :)
<xco> too tired to even copy and paste but will be done in next version tomorrow
<havenwood> :)
<xco> yeah you mentioned those
<xco> in time all those will be done
cloaked1 has quit [Ping timeout: 250 seconds]
<havenwood> xco: Looks like COUNTRY_OUTCOMES is used a few places.
<havenwood> That makes for a nice constant.
<havenwood> And constants can build on each other. That's fine.
<havenwood> FOO = 'ok'; BAR = "#{FOO}ay"
<xco> really!?! :D :D
<xco> 🤣
Arahael has quit [Ping timeout: 246 seconds]
<havenwood> xco: So like here you can have: CASES_FETCH_URL = "#{BASE_URL}#{CASES_PATH}" https://github.com/siaw23/kovid/blob/master/lib/kovid/request.rb#L46
Arahael has joined #ruby
<xco> +1
<havenwood> xco: I'd skip this local variable assignment, and just use the constant directly as a keyword argument value.
<havenwood> xco: headings: CASES_DEATHS_RECOVERED, rows: rows
<havenwood> xco: That said, the local variable assignment is cheap, so not a big deal.
<xco> makes sense :)
<xco> noted
<havenwood> xco: I wonder about persisting the cache to disk. It only works for the duration of each command at the moment, since it's in process memory.
<xco> that i know
<xco> but if you persist to a disc
<xco> what's the points?
<xco> it'll expire
<xco> and you'll have ot fetch again
roadie has joined #ruby
<xco> the expiry time is 15min
<havenwood> xco: It'd just be if you say wanted to compare various countries, to not repeatedly fetch them.
<havenwood> Disk access is way faster than web, but probably doesn't matter. Just made me wonder since you had a cache.
<havenwood> Often HTTP calls are cached to disk or something persistent.
<xco> you know what i could use that disc cache for?
<xco> for a new feature "new cases since you last visited"
<xco> been thinking about that
schne1der has quit [Ping timeout: 240 seconds]
<havenwood> xco: that's a good use
<xco> that's the next feature i'd like to work on
<xco> that'd mean i'll have to write to a file instead
<xco> of using a memory cache though
<xco> i'd want to**
<havenwood> xco: You could use PStore or YAML::Store for "a file based persistence mechanism based on a Hash."
<havenwood> "The transactional behavior ensures that any changes succeed or fail together. This can be used to ensure that the data store is not left in a transitory state, where some values were updated but others were not."
<havenwood> xco: Or YAML::DBM, if you want a very lightweight DB that operates on the same principles.
<xco> will look into that
<xco> thanks
<havenwood> xco: Here's a tiny library that shows PStore used as a Hash: https://github.com/havenwood/persist
<havenwood> np
Arahael has quit [Ping timeout: 250 seconds]
<havenwood> They're pretty painless to use directly, just a bunch of transaction blocks.
brool has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
Arahael has joined #ruby
robotcars has left #ruby [#ruby]
TCZ has quit [Quit: Leaving]
drincruz_ has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 264 seconds]
roadie has quit [Ping timeout: 264 seconds]
Frobozz has quit [Quit: quit]
postmodern has joined #ruby
troulouliou_dev has joined #ruby
roadie has joined #ruby