havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.1, 2.6.6, 2.5.8: 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!
plutes has quit [Ping timeout: 260 seconds]
plutes has joined #ruby
u_u has joined #ruby
rmnull has joined #ruby
troulouliou_div2 has quit [Quit: Leaving]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tau has quit [Ping timeout: 272 seconds]
u_u has quit [Ping timeout: 272 seconds]
tau has joined #ruby
jingjinghack has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rmnull has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
ChmEarl has quit [Quit: Leaving]
imode has quit [Quit: WeeChat 2.8]
imode has joined #ruby
sergioro has quit [Quit: Lost terminal]
ElFerna has quit [Quit: ElFerna]
bhaak has quit [Ping timeout: 256 seconds]
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhaak has joined #ruby
axsuul has joined #ruby
jingjinghack has quit [Read error: Connection reset by peer]
baojg has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
donofrio has quit [Remote host closed the connection]
tau has quit [Ping timeout: 246 seconds]
roger_rabbit has joined #ruby
caterfxo has quit [Ping timeout: 256 seconds]
baojg has quit []
gix has quit [Disconnected by services]
renich has quit [Ping timeout: 256 seconds]
Esa__ has quit [Ping timeout: 260 seconds]
sphex has quit [Ping timeout: 260 seconds]
chouhoulis has quit [Remote host closed the connection]
sphex has joined #ruby
sergioro has joined #ruby
gitter1234 has quit [Quit: Connection closed for inactivity]
howdoi has quit [Quit: Connection closed for inactivity]
polishdub has joined #ruby
drincruz has quit [Ping timeout: 272 seconds]
MrCrackPot has joined #ruby
MrCrackPot has quit [Client Quit]
olddogbarks has joined #ruby
olddogbarks is now known as inguz
chalkmonster has joined #ruby
inguz has quit [Quit: I am functioning within established parameters.]
inguz has joined #ruby
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
jetchisel has joined #ruby
Xiti` has joined #ruby
Xiti` has quit [Remote host closed the connection]
polishdub has quit [Remote host closed the connection]
Xiti has quit [Ping timeout: 260 seconds]
sauvin has joined #ruby
Xiti has joined #ruby
inguz has quit [Quit: ZZZzzz…]
<baweaver> havenwood save me
<baweaver> What'd I bork on refinements?
<havenwood> baweaver: I wonder if related to this limitation: https://bugs.ruby-lang.org/issues/12086
<havenwood> baweaver: I was just talking with adam12 about the Proc#using proposal earlier today (was it today? days blend.) https://bugs.ruby-lang.org/issues/16461
chalkmon1 has joined #ruby
chalkmonster has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
r3m has quit [Quit: WeeChat 2.9-dev]
r3m has joined #ruby
imode has quit [Ping timeout: 260 seconds]
vondruch has joined #ruby
wilhelm418 has joined #ruby
ldepandis has joined #ruby
burgestrand has joined #ruby
conta has joined #ruby
wymillerlinux has quit [Read error: Connection reset by peer]
cgfbee has quit [Quit: cgfbee]
ericm has quit [Ping timeout: 272 seconds]
xco has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
batisi[m] has joined #ruby
sergushakov has quit [Quit: WeeChat 2.3]
<jhass> KrzaQ: put it into a loop? begin; ...; end until logged_in?
cgfbee has joined #ruby
wilhelm418 has quit [Ping timeout: 240 seconds]
Technodrome has joined #ruby
rcvalle has quit [Remote host closed the connection]
rcvalle has joined #ruby
schne1der has joined #ruby
jinmiaoluo has joined #ruby
Vashy has quit [Ping timeout: 252 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jinmiaoluo has quit [Client Quit]
jinmiaoluo has joined #ruby
jinmiaoluo has quit [Client Quit]
jinmiaoluo has joined #ruby
rmnull has joined #ruby
rmnull has quit [Client Quit]
Mikaela has quit [Quit: Mikaela]
jetchisel has quit [Ping timeout: 256 seconds]
Mikaela has joined #ruby
spectra has quit [*.net *.split]
batisi[m] has quit [*.net *.split]
execat[m] has quit [*.net *.split]
arekushi has quit [*.net *.split]
afisher has quit [*.net *.split]
jimeh has quit [*.net *.split]
MentalPower has quit [*.net *.split]
Hobbyboy has quit [*.net *.split]
kashike has quit [*.net *.split]
mnemon has quit [*.net *.split]
Hobbyboy|BNC has joined #ruby
execat[m] has joined #ruby
d3bug has quit [Quit: Connection closed for inactivity]
jetchisel has joined #ruby
xco has quit [Ping timeout: 264 seconds]
xMopx has quit [Ping timeout: 246 seconds]
spectra has joined #ruby
batisi[m] has joined #ruby
kashike has joined #ruby
jimeh has joined #ruby
mnemon has joined #ruby
afisher has joined #ruby
MentalPower has joined #ruby
arekushi has joined #ruby
xMopx has joined #ruby
roadie has joined #ruby
kashike has quit [Max SendQ exceeded]
Technodrome has joined #ruby
kashike has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
burgestrand has quit [Quit: burgestrand]
Garb0 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
hassox has joined #ruby
dionysus69 has joined #ruby
gato has joined #ruby
<KrzaQ> jhass: a loop feels weird if I want it to execute once, and only do it twice in exceptional cases. I ended up raising my exception when the code returned wwas 401
impermanence has quit [Ping timeout: 240 seconds]
Vashy has joined #ruby
olavx200 has quit [Quit: killed]
mbarbar has quit [Quit: killed]
turt2live has quit [Quit: killed]
hsiktas[m] has quit [Quit: killed]
batisi[m] has quit [Quit: killed]
stan has quit [Quit: killed]
linuus[m] has quit [Quit: killed]
execat[m] has quit [Quit: killed]
haylon[m] has quit [Quit: killed]
arekushi has quit [Quit: Gateway shutdown]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
olavx200 has joined #ruby
donofrio has joined #ruby
sergioro has quit [Quit: Lost terminal]
jetchisel has quit [Ping timeout: 265 seconds]
jetchisel has joined #ruby
TCZ has joined #ruby
execat[m] has joined #ruby
mbarbar has joined #ruby
turt2live has joined #ruby
hsiktas[m] has joined #ruby
stan has joined #ruby
haylon[m] has joined #ruby
linuus[m] has joined #ruby
Garb0 has quit [Ping timeout: 256 seconds]
chalkmon1 has quit [Quit: WeeChat 2.8]
chalkmonster has joined #ruby
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
Garb0 has joined #ruby
caterfxo has joined #ruby
cd has quit [Quit: cd]
jinmiaoluo has quit [Ping timeout: 256 seconds]
gato has quit [Quit: Connection closed]
burningserenity has joined #ruby
Vashy has quit [Ping timeout: 252 seconds]
Technodrome has joined #ruby
Vashy has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Technodrome has joined #ruby
drincruz has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
jetchisel has quit [Ping timeout: 246 seconds]
Vashy has quit [Ping timeout: 252 seconds]
conta has quit [Quit: conta]
Vashy has joined #ruby
drincruz has joined #ruby
cadbury_ has joined #ruby
<cadbury_> Hi, I need to automate the download of https://mygovtagency.gov/statistics-may-7.xlsx where "may" and "7" obviously differ every day. what is the best way of doing this? ALso note that the name of the month may is in a foreign language! so i'd need some array mapping stuff or something as well...
<cadbury_> I'm trying to create a cron script which will feed it to my website app..
evdubs_ has joined #ruby
evdubs has quit [Remote host closed the connection]
fercell has joined #ruby
nowhere_man has joined #ruby
gato has joined #ruby
burningserenity has quit [Remote host closed the connection]
<jhass> cadbury_: yeah, just have an array for the month names and build the URL with something like "...#{MOTNHS[Time.now.month]}-#{Time.now.day}.xlsx"
Garb0_ has joined #ruby
Garb0_ has quit [Max SendQ exceeded]
TzilTzal has joined #ruby
drincruz has quit [Ping timeout: 256 seconds]
gitter1234 has joined #ruby
burgestrand has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
grimgnr has joined #ruby
grimgnr has quit [Client Quit]
rkoller has joined #ruby
me has joined #ruby
me is now known as Guest723
Guest723 is now known as sergushakov
sergushakov is now known as grimgnr
rmnull has joined #ruby
arekushi has joined #ruby
rmnull has quit [Client Quit]
grimgnr has quit [Quit: WeeChat 2.3]
me1 has joined #ruby
drincruz has joined #ruby
me1 is now known as grimgnr
grimgnr has quit [Client Quit]
me1 has joined #ruby
me1 has quit [Client Quit]
me1 has joined #ruby
nobitanobi has joined #ruby
me1 has quit [Client Quit]
grimgnr has joined #ruby
<nobitanobi> hello - I've installed rbenv and I'm using fish shell. When I run `which irb` I see `/Users/catali/.rbenv/shims//ruby` (notice extra `/ before ruby. However, when I do `echo $PATH`, I see `/Users/catali/.rbenv/bin /Users/catali/.nvm/versions/node/v10.19.0/bin /Users/catali/.nvm/versions/node/v10.19.0/bin /Users/catali/.rbenv/bin /Users/catali/.rbenv/shims/ /usr/local/bin /usr/bin /bin /usr/sbin /sbin` - how can I see who is adding that wr
<nobitanobi> ong route?
<jhass> does it seriously break fish? :D
<jhass> what steps did you follow to install rbenv?
<jhass> I see there's also https://github.com/rbenv/fish-rbenv
<nobitanobi> jhass: I followed the basic Github checkout approach (https://github.com/rbenv/rbenv#basic-github-checkout), which besides adding `.rbenv`, for fish asks you to do `set -Ux fish_user_paths $HOME/.rbenv/bin $fish_user_paths`
<nobitanobi> and when I run the doctor `curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash`, it tells me that shims is not in the path.
<jhass> maybe just skip the init part and do it manually?
<nobitanobi> jhass: I will take a look at that, but notice that when I echo my $PATH I see shims properly in there.
<jhass> doesn't look like it would add that extra / though
quuxman has joined #ruby
<jhass> weren't you complaining about the trailing / in there?
rmnull has joined #ruby
<quuxman> Is there a way to enter the debugger where the last uncaught exception was raised?
<nobitanobi> yep, but that trailing just shows up when doing `which ruby`, is not there when I do echo $PATH :D
<quuxman> (the equivalent of `debug` command in IPython)
<nobitanobi> or when I do `which irb`, the trailing is there too
<jhass> well in your copy paste above it is
<nobitanobi> oh you are right, because it finishes with `/`
<nobitanobi> hmm bummer
<nobitanobi> ok, will uninstall and perhaps I will try that fisher plugin
<nobitanobi> thanks @jhass :)
<jhass> no idea where that would be coming from, doesn't seem to be rbenv itself judging from the source linked above
<nobitanobi> yep, I have no idea either
<quuxman> AFAICT it's impossible in pry, but maybe there's a more advanced debugger or an extension?
<nobitanobi> @jhass no worries, I will see what I find
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #ruby
jinmiaoluo has joined #ruby
<quuxman> jhass: hmmm, but what about calling from pry REPL?
<quuxman> jhass: and related question, how do I call rspec tests from REPL? It's very confusing
<jhass> ah, don't
<jhass> call your repl from your rspec tests by inserting binding.pry into them
<quuxman> Like in Python: `from test.foo import FooTester; tc = FooTester(); tc.foo_good_test()`
<quuxman> jhass: but then I have to know where they're going to blow up first :-(
<jhass> I doubt calling rspec from within pry will be ergonomic
<quuxman> and I also don't like editing files when I'm debugging
burgestrand has quit [Quit: burgestrand]
postmodern has quit [Quit: Leaving]
<quuxman> Is it nicer with Test::Unit (I've only used RSpec so far)
<jhass> maybe, I never felt the need to try something like that
<quuxman> Also with my project the rails instantiation takes a couple seconds, but making any call from the REPL is instant. Also I can hold various useful state between running tests
<jhass> pry-rescue's rspec integration and binding.pry is just perfect for me
sergioro has joined #ruby
<quuxman> it's definitely a huge improvement over running rspec, waiting for failure, canceling tests, opening file, adding break point, saving, then rerunning. I can't believe anybody puts up with that
<quuxman> :-P
<jhass> we just get good at spotting the bug from the initial failure output :P
chouhoulis has joined #ruby
gato has quit [Ping timeout: 240 seconds]
burningserenity has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
<quuxman> I spent a lot of time with a Python project that needed a statistical approach to tests, so needed a several hundred MBs of test results in memory which took a few minutes to generate. Instead of using unit tests we just had a nice library of development tools for running various selections of tests and getting stats out of the results (our unit and integration tests could import this lib)
<quuxman> The only time I would run tests from the command line was to check for regressions before committing
<quuxman> that's why using Pry.rescue method directly could be very useful, mainly for maintaining state between test calls
TCZ has quit [Quit: Leaving]
jinmiaoluo has quit [Quit: WeeChat 2.8]
<quuxman> I bet someone who knows RSpec well enough could come up with a one liner to call a single test from REPL
ldepandis has quit [Remote host closed the connection]
inguz has joined #ruby
<adam12> havenwood baweaver That's eerily what I was trying to do 2 days ago. Very weird.
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
wymillerlinux has joined #ruby
renich has joined #ruby
chalkmonster has joined #ruby
<havenwood> Was that two days ago not earlier today? Hah. According to Steph I have "datetime insanity."
<havenwood> A baby doesn't help that. :)
<havenwood> 52 days old, but no signs of Ruby or Python preference yet.
ChmEarl has joined #ruby
dionysus69 has quit [Quit: dionysus69]
ellcs has joined #ruby
dionysus69 has joined #ruby
<adam12> havenwood: 52 days already! wow
Garb0 has quit [Read error: Connection reset by peer]
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
Garb0 has joined #ruby
rippa has joined #ruby
sergioro has quit [Quit: Lost terminal]
burningserenity has quit [Quit: Leaving.]
lupulo has joined #ruby
<lupulo> why is useful ruby?
<lupulo> is it compatible with django?
<havenwood> lupulo: Ruby is useful for programming.
<olavx200> No
<havenwood> lupulo: Django is written in Python, so it's compatible with Python.
chalkmonster has quit [Quit: WeeChat 2.8]
<havenwood> lupulo: Django is based loosely on a Ruby framework called Rails.
<olavx200> Django is a python framefork. There are Ruby frameworks such as rails though.
<lupulo> havenwood, i used nokogiri, but it seems nowdays obsoled, what i could use to work with json?
renich has quit [Ping timeout: 264 seconds]
<havenwood> lupulo: Nokogiri isn't osoled.
<havenwood> lupulo: JSON ships with the Ruby stdlib.
<havenwood> lupulo: https://stdgems.org/json
<havenwood> lupulo: XML and JSON are different. Nokogiri is for XML.
<lupulo> the ruby develop version doesn't use it
<havenwood> lupulo: I don't understand.
<lupulo> it is true, i mismatch my memories
<lupulo> sorry
chalkmonster has joined #ruby
<havenwood> With irb getting nicer and nicer, I keep getting tempted to use it more and more.
<lupulo> thanks havenwood
<havenwood> My .irbrc is getting growing, heh. https://gist.github.com/havenwood/6d3683bb2835a81f8d736f46e4c28f8f
<havenwood> Anyone have interesting .irbrc settings I could add?? :)
<havenwood> I've started writing little functions for Pry features I miss.
<cadbury_> damn
<cadbury_> this is like how my .bashrc will look like in a million years :)
<havenwood> It seems `clear`, `reset` and `ls` are the ones I miss most.
xco has joined #ruby
xco has quit [Client Quit]
xco has joined #ruby
<havenwood> cadbury_: Haha, I'm not sure if that's good or bad.
<havenwood> cadbury_: Eek, my ~.zshrc has creeped over 100 lines: https://gist.github.com/havenwood/d150bc5a8aff8e920ce8c114773c300d
<cadbury_> ok thats bad :D
<cadbury_> lol
<cadbury_> i dont even maintain a ~.zshrc for that very same fact
<cadbury_> dont want it to creep up over time
<havenwood> cadbury_: I could extract the prompt to get it back down, it looks like.
<cadbury_> havenwood: you need to work on yourself brother. ditch some solutions you thought were mandatory
<havenwood> cadbury_: I don't use Oh My Zsh, so this is quite minimalist.
<havenwood> cadbury_: The prompt is most the file, it looks like. I
<havenwood> cadbury_: I like to ditch dependencies I thought were mandatory and write minimalist alternatives. Sue me!
<cadbury_> oh my zsh is garbage!!!!!!!
<cadbury_> hehe
<cadbury_> well, your approach seems very minimal and kudos for that!
<cadbury_> although, the large walls you've set up around your approach seem less appealing
<havenwood> cadbury_: Large walls?
<havenwood> cadbury_: I just read the manual. ¯\_(ツ)_/¯
<havenwood> Nothing spooky.
<havenwood> (Other than #ls, but that's a work in progress. >.>)
* havenwood puts another brick in the wall.
<havenwood> If anyone tries PryCarePackage let me know if it works for you. :)
<havenwood> The recent irb changes are just great.
<cadbury_> havenwood: yeah making things a bit more difficult than they have to be
<cadbury_> like a .zshrc vs no .zshrc
<cadbury_> lets face it, its not really a needed file...
chalkmonster has quit [Quit: WeeChat 2.8]
<cadbury_> ditching it from your setup would result in hundreds if not thousands of saved man hours
Esa__ has joined #ruby
deimos_ has quit [Quit: leaving]
<havenwood> cadbury_: Ditching my .zshrc would save thousands of hours?
<havenwood> Huh?
TCZ has joined #ruby
Esa__ has quit [Ping timeout: 272 seconds]
<havenwood> cadbury_: I help maintain multiple shell projects and have spent thousands of hours on shell, no doubt. My .zshrc file is totally benign though, and is just one of many setups that helps me be effective along with some placeholder tidbits. I'm super confused why you think it wastes thousands of hours.
<havenwood> Anyways, was hoping to glean some nice .irbrc ideas, if anyone has settings they like.
<havenwood> Hopefully my .irbrc won't waste thousands of people hours. :P
<cadbury_> lol
<cadbury_> you just proved my point havenwood
<havenwood> cadbury_: I did?
<cadbury_> You _are_ millions of years ahead of everyone else!
<cadbury_> As a proponent of Zsh, I'm glad this project has you as a user
<cadbury_> That being said, I don't believe in the need for a .zsh
<cadbury_> /etc/zshrc yes
<cadbury_> /etc/zprofile yes
<havenwood> cadbury_: I've wasted *WAY* more time on this memoizing enumerator: https://gist.github.com/havenwood/58838bbcc5e463b0c3594b16953aa022
<havenwood> On that note, it's interesting that Enumerator::ArithmeticSequence#clone and #dup are broken.
<cadbury_> hehe
<havenwood> &>> 1.step.clone
<rubydoc> stderr: -e:4:in `clone': allocator undefined for Enumerator::ArithmeticSequence (TypeError)... check link for more (https://carc.in/#/r/90xm)
<cadbury_> ... yeah
<cadbury_> get back to you in ten years when i've figured it out? :)
<havenwood> &25>> 1.step.clone
<rubydoc> # => #<Enumerator: 1:step> (https://carc.in/#/r/90xn)
<havenwood> &26>> 1.step.clone
<rubydoc> stderr: -e:4:in `clone': allocator undefined for Enumerator::ArithmeticSequence (TypeError)... check link for more (https://carc.in/#/r/90xo)
<havenwood> &>> 1.step.dup
<rubydoc> stderr: -e:4:in `dup': allocator undefined for Enumerator::ArithmeticSequence (TypeError)... check link for more (https://carc.in/#/r/90xp)
<cadbury_> imagine if bach, vivaldi and mozart were alive today, and were forced to live with computer keyboards instead of piano keyboards
<cadbury_> would probably sound like havenwood :)
<havenwood> cadbury_: I'm more like some guy nobody has heard of that make violin bridges. :P
<cadbury_> ah yeah
<cadbury_> i know that guy :)
renich has joined #ruby
burningserenity has joined #ruby
inguz has quit [Quit: ZZZzzz…]
troulouliou_div2 has joined #ruby
imode has joined #ruby
inguz has joined #ruby
wymillerlinux has quit [Ping timeout: 258 seconds]
burningserenity has quit [Read error: Connection reset by peer]
<havenwood> al2o3-cr: Ooh, good spot.
deimos_ has joined #ruby
burningserenity has joined #ruby
chalkmonster has joined #ruby
wymillerlinux has joined #ruby
burningserenity has quit [Read error: Connection reset by peer]
burningserenity has joined #ruby
<al2o3-cr> havenwood: 👍
burningserenity has quit [Read error: Connection reset by peer]
burningserenity has joined #ruby
sergioro has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
chalkmonster has joined #ruby
troulouliou_div2 has quit [Ping timeout: 260 seconds]
chalkmonster has quit [Client Quit]
fercell has quit [Quit: WeeChat 2.8]
chalkmonster has joined #ruby
lightstalker has joined #ruby
troulouliou_div2 has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.8]
burningserenity has quit [Quit: Leaving.]
burningserenity has joined #ruby
al2o3-cr has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TCZ has quit [Quit: Leaving]
Esa__ has joined #ruby
conta has joined #ruby
hiroaki has quit [Ping timeout: 260 seconds]
stryek has joined #ruby
TzilTzal has quit [Quit: Leaving.]
donofrio has quit [Read error: Connection reset by peer]
donofrio has joined #ruby
hiroaki has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
d3bug has joined #ruby
MrCrackPot has joined #ruby
MrCrackPot has quit [Client Quit]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
stooj has quit [Quit: ZNC 1.7.5 - https://znc.in]
Garb0 has quit [Remote host closed the connection]
sauvin has quit [Ping timeout: 240 seconds]
vondruch has quit [Ping timeout: 256 seconds]
stooj has joined #ruby
cd has joined #ruby
stooj has quit [Quit: ZNC 1.7.5 - https://znc.in]
caterfxo has quit [Ping timeout: 256 seconds]
conta has quit [Remote host closed the connection]
howdoi has joined #ruby
<howdoi> which you be the best way to convert "20" (short year) to "2020"?
<havenwood> howdoi: what year do you want to switch from 19 to 20?
<havenwood> howdoi: 20 and lower?
<havenwood> howdoi: current year and lower?
<kaleido> he wants 20 to convert to 2020, i believe
<havenwood> '20' + '20'
<howdoi> kaleido: yes
<howdoi> the year
<phaul> '20' * 2 # sorry :)
<havenwood> kaleido: I assumed `79` would become `1979` but `20` would become `2020`.
<howdoi> yes
<havenwood> With the problem as stated, phaul is right. :)
<howdoi> `79` can be 2079 but by then...hmm
<havenwood> howdoi: pick what years should be what result.
<howdoi> 20 should be 2020
<howdoi> as this is more like card expiration, it will always be in the feature :D
<howdoi> so if the card expiration number says 22, it means 2022
<havenwood> howdoi: right, you've said 20 is 2020. are you *always* just prepending 20?
<havenwood> howdoi: is 79 going to be 2079?
<havenwood> howdoi: Just prepend "20" or add 2000...
<havenwood> &>> '79'.prepend('20')
<rubydoc> # => "2079" (https://carc.in/#/r/90yj)
<havenwood> &>> '20'.to_i + 2000
<rubydoc> # => 2020 (https://carc.in/#/r/90yk)
<havenwood> howdoi: Do those ^ make sense?
<howdoi> I though that, but would be more better to know the current year and using some Date utils we derive this?
<havenwood> howdoi: You haven't given enough info for us to help.
<kaleido> first is a string, so don't pull a kaleido and make a number a string and then wonder why all your math is failing :(
<kaleido> being a rookie is fun
<havenwood> howdoi: Given these inputs, what are your desired outputs?: 0, 20, 99, -42, 420
<havenwood> howdoi: Or zoom out and tell us why...
sagax has quit [Ping timeout: 260 seconds]
<havenwood> howdoi: Saying "I have 20 and want 2020" is too vague.
<havenwood> howdoi: phaul gave you the answer to that quesion.
<howdoi> havenwood: input are wrong there, consider it like converting `YY` to `YYYY` for the current year
<havenwood> howdoi: Rails with TZ or pure Ruby?
<havenwood> howdoi: Does it need to work after the year 9999?
<howdoi> `Rails with TZ`
<howdoi> `Does it need to work after the year 9999?` hah hah, if credit cards exists till then, yes.
<havenwood> howdoi: Start with: Date.current.year % 100 * 100
<havenwood> howdoi: Date.current uses the timezone, unlike Date.today. By getting the #modulo of 100, you allow for your remaining two digits to fit.
<howdoi> noice, trying
<havenwood> &>> require 'date'; '20'.then { String Integer(_1) + Date.current.year % 100 * 100 }
<rubydoc> stderr: -e:4:in `block in <main>': undefined method `current' for Date:Class (NoMethodError)... check link for more (https://carc.in/#/r/90yl)
<havenwood> Well, this isn't Rails.
<havenwood> &>> require 'date'; '20'.then { String Integer(_1) + Date.now.year % 100 * 100 }
<rubydoc> stderr: -e:4:in `block in <main>': undefined method `now' for Date:Class (NoMethodError)... check link for more (https://carc.in/#/r/90ym)
<havenwood> &>> require 'date'; '20'.then { String Integer(_1) + Date.today.year % 100 * 100 }
<rubydoc> # => "2020" (https://carc.in/#/r/90yn)
<havenwood> Ruby version ^
lupulo has quit [Ping timeout: 260 seconds]
<havenwood> howdoi: def add_century(year); String(Integer(year) + Date.current.year % 100 * 100) end; add_century '20'
<howdoi> works thanks!
<havenwood> howdoi: And it'll work in 99999. :)
<havenwood> Wel...
<havenwood> you're welcome
<howdoi> super
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
Garb0 has joined #ruby
mikecmpbll has quit [Read error: Connection reset by peer]
Garb0 has quit [Max SendQ exceeded]
Garb0 has joined #ruby
Garb0 has quit [Max SendQ exceeded]
mikecmpbll has joined #ruby
Garb0 has joined #ruby
greypack has quit [Quit: All your IRC are belong to ZNC]
greypack has joined #ruby
<havenwood> howdoi: It doesn't work though. I multitask failed.
pwnd_nsfw has joined #ruby
davispuh has joined #ruby
<havenwood> howdoi: I thought divmod and wrote mod not div.
<howdoi> :)
<havenwood> howdoi: Err, or did I get it right?
<havenwood> I'm just confused.
<havenwood> howdoi: Write tests. :)
<howdoi> doing!
<havenwood> Cats are easier to pair program with than babies!
<pwnd_nsfw> havenwood, I believe that 100%
<pwnd_nsfw> a cat won't usually shit in your lap
jetchisel has joined #ruby
roadie has quit [Ping timeout: 265 seconds]
gix has joined #ruby
nobitanobi has quit []
<howdoi> is there a way to trick this RE to accept two strings? https://github.com/Shopify/magnet/blob/master/lib/magnet/parser.rb#L9
<howdoi> is there a way to dynamically create a variable while iterating through hash?
<howdoi> binding?
caterfxo has joined #ruby
<howdoi> instance_variable_set?
davispuh has quit [Ping timeout: 240 seconds]
<phaul> they are really different things. It's not a question of possible, but a question of which one you want.
<phaul> local vars care about lexical scope. intance vars care about self.
roadie has joined #ruby
deathwishdave has joined #ruby
gato has joined #ruby
davispuh has joined #ruby
burningserenity has quit [Quit: Leaving.]
Technodrome has joined #ruby
<adam12> baweaver: wrt proc refining, I'm working in a non-ActiveSupport world but I was looking to recreate it's DSL (kinda) in a block. Something like TimeExpr { 1.day.from_now }. I don't want Integer to always have a #day method so I thought triggering it in the block would work nice.
<adam12> baweaver: If you hear of a solution I'd love to know.
<howdoi> phaul: hmm, okies
<howdoi> x.map { |k,v| [k, foo(v) unless v.nil?]}; is this a right syntax?
romanlevin has quit [Ping timeout: 265 seconds]
<leftylink> IIRC they needed the parens around the secod list item.
<leftylink> in which case, it is valid.
<leftylink> and otherwise, it is not
<howdoi> ah, thanks
Vashy has quit [Read error: Connection reset by peer]
ericm has joined #ruby
TCZ has joined #ruby
romanlevin has joined #ruby
<howdoi> can this me made better: h = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } ?
rkoller has quit [Quit: Textual IRC Client: www.textualapp.com]
matti has joined #ruby
gato has quit [Quit: Connection closed]
<howdoi> x.map { |k,v| [k, (foo(v) unless v.nil?)]}.th_h; works, but can it be better?
mikecmpbll has quit [Ping timeout: 256 seconds]
<havenwood> howdoi: Might `v` be false, or it's `nil` or another value?
<howdoi> safe to think it is always nil, in this case
<havenwood> howdoi: x.transform_values { |v| foo(v) if v }
ur5us has joined #ruby
<havenwood> howdoi: For the former question, it can be made more readable, but that's generally how you man an autoselfvivifying Hash.
<giorgian> xb
<havenwood> howdoi: Of the new numbered parameters: x.transform_values { foo(_1) if _1 }
<havenwood> howdoi: Or have foo handle `nil` and: x.transform_values { foo _1 }
<havenwood> howdoi: There's also a #to_h with block form, but if you're just modifying the key or value, use #transform_values or #tranform_keys instead.
<havenwood> x.to_h { |k, v| [k, v] }
Vashy has joined #ruby
<havenwood> x.tranform_keys { |k| k }
<havenwood> x.transform_values { |v| v }
<howdoi> oh nice, what if foo fails as in it throws a exception?
<havenwood> howdoi: Rescue it or let it blow up—but that's your choice.
<howdoi> I want to rescue inline
<havenwood> howdoi: rescue what?
<howdoi> also, h = {:t1=>"mm", :t2=>"kk"}; I need to execute `foo` on `t1` first, if it fails, then `t2`, that can be in a single line?
<havenwood> howdoi: h.values.find { |value| value && foo(value) rescue nil }
<howdoi> so I want to apply `foo` on `:t2` only of `:t1` fails
<howdoi> *only if
<havenwood> howdoi: The Enumerable method goto if you want to return the first truthy thing is #find.
<howdoi> and that will return the value of `foo(value)` right?
<havenwood> howdoi: It's generally an antipattern to rescue everything, so just rescue the execeptions you might have.
<howdoi> nods
<howdoi> awesome
<havenwood> howdoi: No, #find will return the unmodified receiver, unlike #filter_map style. If #foo is expensive, you can return the value manually.
<howdoi> foo is not expensive
<havenwood> &>> {job_1: [:nope, 'this blows up'], job_2: [:p, 42]}.find { |_job, command| send *command rescue nil }
<rubydoc> # => 42... check link for more (https://carc.in/#/r/90yy)
<havenwood> howdoi: Consider that ^ example.
<havenwood> howdoi: #p there is printing 42, but you could set your value as the side effect.
hagabaka has quit [Remote host closed the connection]
<howdoi> nice havenwood let me give it a shot
<havenwood> howdoi: But think about the error you'll want to rescue. There ^ it'd be NameError.
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<howdoi> luckily in my flow I noticed that the data to this method is already validated :)
<howdoi> either way, will check what exception that foo might raise
<howdoi> foo(v) works, send *foo(v) give a TypeError; send *foo gives an argument error
<havenwood> howdoi: The splat and send are specific to my example.
<havenwood> howdoi: I was hoping to show the concept, but you'll want just your rescue with: foo(value) if value
<howdoi> got it, misread the splat
<howdoi> h.find { |k,v| data = foo(v) } is a bad idea?
ellcs has quit [Ping timeout: 260 seconds]
renich has quit [Remote host closed the connection]
<howdoi> ^ assuming foo won't throw
hagabaka has joined #ruby
inguz has quit [Quit: ZZZzzz…]
inguz has joined #ruby
<howdoi> because my find is returning [:k, v] rather than foo(v)
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
<howdoi> why is there no `find` on https://ruby-doc.org/core-2.5.1/Hash.html ?
<havenwood> howdoi: Hash inherits from Enumerable.
<havenwood> &>> Hash.instance_method(:find).owner
<rubydoc> # => Enumerable (https://carc.in/#/r/90z0)
<havenwood> &>> {}.public_method(:find).owner
<rubydoc> # => Enumerable (https://carc.in/#/r/90z1)
<howdoi> Passes each entry in enum to block. Returns the first for which block is not false nice
<howdoi> but I want it to return the foo(v) and not v
<havenwood> &>> Hash.included_modules.first
<rubydoc> # => Enumerable (https://carc.in/#/r/90z2)
<howdoi> so, I was assigning it within find, which looks like an anti-pattern
<howdoi> nice
<havenwood> howdoi: I was hoping to point out that the #p in my first example was a side effect.
<havenwood> howdoi: You can also: break value
<howdoi> but first will fail if I have a nil, right?
<havenwood> howdoi: It will skip that iteration if it returns nil.
<havenwood> &>> [false, false, false].find(&:itself)
<rubydoc> # => nil (https://carc.in/#/r/90z3)
<havenwood> &>> [false, false, 42].find(&:itself)
<rubydoc> # => 42 (https://carc.in/#/r/90z4)
<havenwood> howdoi: ^
<howdoi> find(&:itself) hah
<howdoi> &>> [false, false, nil].find(&:itself)
<rubydoc> # => nil (https://carc.in/#/r/90z5)
<howdoi> &>> [nil].find(&:itself)
<rubydoc> # => nil (https://carc.in/#/r/90z6)
<havenwood> howdoi: #find returns `nil` if it doesn't find anything.
schne1der has quit [Ping timeout: 260 seconds]
<howdoi> m.find {|k,v| foo(v) if v} is returning me [:k,v] and `.first` gives `:k`
<howdoi> I was expecting m.find {|k,v| foo(v) if v} to return foo(v)
inguz has quit [Quit: ZZZzzz…]
<howdoi> : break value, I would need a block, like how you did for #p, right?
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
renich has joined #ruby
<howdoi> havenwood: sorry if I am missing something obvious here
<havenwood> howdoi: #find just returns the receiver item that matches, unmodified. you'd do: m.find { |_k, v| foo(v) if v }.last.then { |value| foo(value) }
<havenwood> howdoi: Or, instead of printing the value, set an instance variable.
<havenwood> howdoi: (Where I used #p.)
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #ruby
<howdoi> md=nil; m.find {|k,v| md = Magnet::Card.parse(v) if v} works, but it is a bad pattern, right?
troulouliou_div2 has quit [Quit: Leaving]
<howdoi> havenwood: see https://carc.in/#/r/90z8
greypack has quit [Ping timeout: 258 seconds]
<havenwood> &>> [1, 2, 3].find { |n| break(n.to_s) if n.even? }
<rubydoc> # => "2" (https://carc.in/#/r/90zg)
<havenwood> howdoi: The #find is merely decoration there ^
<havenwood> howdoi: Except instead of returning the whole enum receiver like #each, it'll return `nil` if none are found.
<havenwood> howdoi: break(Magnet::Card.parse(v)) if v
dionysus69 has quit [Ping timeout: 240 seconds]
greypack has joined #ruby
Esa__ has quit [Ping timeout: 256 seconds]
<havenwood> howdoi: FWIW, you can implement an Enumerable#find_map to do what you want.
<havenwood> &>> module Enumerable; def find_map; each { |item| yield(item).tap { |yielded| return yielded if yielded }; nil } end end; [1, 2, 3].find_map { |n| n.to_s if n.even? }
<rubydoc> # => "2" (https://carc.in/#/r/90zh)
rmnull has quit [Read error: Connection reset by peer]
roadie has quit [Ping timeout: 240 seconds]
<howdoi> nice, trying
jetchisel has quit [Ping timeout: 260 seconds]
<howdoi> break oh beauty!
<howdoi> havenwood++
<howdoi> havenwood: I guess now you have an extended paternity :D
FolkLore has joined #ruby
renich has quit [Quit: renich]
renich has joined #ruby
jetchisel has joined #ruby
davispuh has quit [Remote host closed the connection]
TCZ has quit [Quit: Leaving]
davispuh has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
inguz has joined #ruby
SeepingN has joined #ruby
gix has quit [Ping timeout: 246 seconds]
gitter1234 has quit [Quit: Connection closed for inactivity]
drincruz has quit [Ping timeout: 272 seconds]
evdubs_ has quit [Quit: Leaving]
evdubs has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
evdubs has quit [Remote host closed the connection]
evdubs has joined #ruby
Arahael has quit [Ping timeout: 264 seconds]
Technodrome has joined #ruby
Arahael has joined #ruby
roadie has joined #ruby
rcvu has joined #ruby