havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first! | BLM <3
_whitelogger has joined #ruby
al2o3-cr has quit [Ping timeout: 256 seconds]
al2o3-cr has joined #ruby
fercell has quit [Quit: WeeChat 2.9]
edk_ is now known as deadk
ldepandis has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.9]
TCZ has quit [Quit: Leaving]
Jonopoly has joined #ruby
Jonopoly is now known as Jons
weaksauce has quit [Ping timeout: 246 seconds]
crankharder has joined #ruby
crankharder has quit [Ping timeout: 240 seconds]
infinityfye has quit [Ping timeout: 240 seconds]
crankharder has joined #ruby
TCZ has joined #ruby
al2o3-cr has joined #ruby
bmurt has joined #ruby
l0g has joined #ruby
burgestrand has quit [Quit: burgestrand]
markong has quit [Ping timeout: 272 seconds]
donofrio has joined #ruby
impermanence has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.9]
aesthe has joined #ruby
spacesuitdiver has joined #ruby
l0g has left #ruby [#ruby]
akem has joined #ruby
infinityfye has joined #ruby
Rudd0 has quit [Ping timeout: 256 seconds]
ChmEarl has joined #ruby
chouhoulis has joined #ruby
Nowaker has quit [Ping timeout: 246 seconds]
`brian has left #ruby ["WeeChat 1.9.1"]
<aesthe> I'm reading some code in ruby and noticed a line that is like: variable = (var_that_is_an_int - other_var_that_is_an_int). Why would the parentheses need to be there?
<havenwood> aesthe: they don't need to be. remove them.
<havenwood> aesthe: you *can* just add a ton of parens, just like math or writing.
<havenwood> aesthe: but don't.
<havenwood> &>> 2 ** 3 * 7 + 5 == (((2 ** 3) * 7) + 5)
<rubydoc> # => true (https://carc.in/#/r/9v4d)
<havenwood> Or (((2.**(3)).*(7)).+(5))
Jons has quit [Quit: WeeChat 2.9]
<aesthe> oh ok. it weirded me out
<havenwood> aesthe: `=` is lower precedence than `-` so the assignment happens after the subtraction.
TCZ has quit [Quit: Leaving]
<havenwood> aesthe: (Just like with algebra.)
<havenwood> And you can add unnecessary parens when precedence is clear, also just like algebra.
moeSizlak has joined #ruby
<moeSizlak> excuse teh noob question. in this html .erb template file, am i allowed to have local variables like in this pic: https://i.imgur.com/25MHxkr.png
<moeSizlak> it seems like these variables are not accessible later in the erb file, in different <% %> blocks
<adam12> moeSizlak: It's because they're in a block, which means they are scoped to tha tblock.
<adam12> moeSizlak: Actually, you didn't show the whole file. If you're in the @prcrs.each_with_index block, they should be available. If you're outside of the block, then likely not.
<havenwood> &>> require 'erb'; ERB.new('<% (1..10).each do |n| %><%= n %><%= n %><% end %>').result(binding)
<rubydoc> # => "1122334455667788991010" (https://carc.in/#/r/9v4e)
<havenwood> &>> require 'erb'; ERB.new('<% (1..10).each do |n| %><%= n %><% end %><%= n %>').result(binding)
<rubydoc> stderr: (erb):1:in `<main>': undefined local variable or method `n' for main:Object (NameError)... check link for more (https://carc.in/#/r/9v4f)
<havenwood> moeSizlak: To illustrate what adam12 said ^, the variable is available repeatedly, but not outside the scope where it'd be visible in Ruby.
Rounin has joined #ruby
<moeSizlak> adam12, even in the each_with_index block, theyre not available
<adam12> moeSizlak: Paste the entire block in something like dpaste.de so we can take a look.
<adam12> moeSizlak: What's the error?
<moeSizlak> theres no error, it just acts like the variables dont exist
<havenwood> meimeix: You don't have an = sign.
<havenwood> meimeix: <%=
<havenwood> meimeix: If the local variable wasn't available, it'd blow up with an error saying so.
<moeSizlak> i dont need a = there
<havenwood> moeSizlak I mean, ooops
<havenwood> sorry meimeix
<adam12> moeSizlak: Can you share the full code? Without it, not sure we can give a good answer without an exception backtrace.
<adam12> moeSizlak: instead of asssigning `nil` to mystatus and mystatusHTML, assign something random like "SIMPSONS" and see if it outputs.
<havenwood> ?gist moeSizlak
<ruby[bot]> moeSizlak: https://gist.github.com - Multiple files, syntax highlighting, even automatically with matching filenames, can be edited
<moeSizlak> look at line 183
<moeSizlak> it just prints as
<moeSizlak> <!-- '' -->
<moeSizlak> <!-- '' -->
<adam12> moeSizlak: What happens if you do what I said, by assigning mystauts = "SIMPSONS"
<adam12> Oh actually I see it
<adam12> myStatus
<adam12> mystatus
<moeSizlak> lol i am a failure
<adam12> mystatusHTML, myStatusHTML
<moeSizlak> :|
<havenwood> did_you_mean ftw
<moeSizlak> ty for the help everyone
<havenwood> moeSizlak: strictly following convention with snake_case at least helps avoid this type of error
<havenwood> moeSizlak: my_status
<havenwood> moeSizlak: never myStatus, or mystatus, or MyStatus. always my_status.
<havenwood> I guess local variables *can't* be MyStatus.
<havenwood> But methods can, and they should be my_status() too.
<adam12> ASL
orbyt_ has joined #ruby
burgestrand has joined #ruby
<iamgr00t> 69/m/us
<iamgr00t> u?
infinityfye has quit [Read error: Connection reset by peer]
<adam12> Heh
TomyWork has quit [Remote host closed the connection]
<isene> (RTFM) Now we're talking - got syntax highlighting working via `bat` - parsing all color codes and other fluff and outputting to right pane just nicely (http://isene.com/x/2020-10-22-144959_1920x1043_scrot.png
Rudd0 has joined #ruby
linuus[m] has left #ruby ["Kicked by @appservice-irc:matrix.org : Idle for 30+ days"]
burgestrand has quit [Quit: burgestrand]
crankharder has quit [Ping timeout: 258 seconds]
crankharder has joined #ruby
<havenwood> isene: Fancy!
<havenwood> isene: Is it feature complete now? Want any code review?
banisterfiend has joined #ruby
cthulchu_ has joined #ruby
<isene> I've been at this for only 25 hours so far, and I do want more features (like Readline input in bottom window, search via "/", maybe fzf integration... but yeah, if you want to review the code, I'll be happy to have the input. I'm not really a Ruby developer even though I've used the language for 15 years, so anything I can learn is cool :-)
banisterfiend has quit [Read error: Connection reset by peer]
al2o3-cr has joined #ruby
<havenwood> isene: Consider cutting a gem!
<havenwood> isene: It's worth making it a gem, even if you don't upload it to RubyGems.
<havenwood> isene: Just move `rtfm` to a bin/ dir and move its logic to a lib/ dir.
<isene> I have no idea how to even approach that. But it's probably not hard and should be doable with an hour research, perhaps?
<havenwood> isene: Yeah, it's a nice process. It'd not be a big change from what you have.
<havenwood> isene: Just move your code to a bin/ and lib/ folder and create a rtfm.gemspec, along these lines: https://github.com/havenwood/digest-sip_hash/blob/master/digest-sip_hash.gemspec
elagost has joined #ruby
<isene> Ah, links. Thanks. Will check in the weekend as I'm arranging an eSports tournament until Saturday
<havenwood> isene: Nice
<isene> And it's my birthday tomorrow.
<havenwood> isene: You might like using `<<~HELP_TEXT` so you can indent nicely without the extra whitespace getting added.
<havenwood> Usually requires go at the top. I think that's worth leaning towards unless there's a reason not to.
<havenwood> isene: I'd say `Dir.home` instead of `ENV['HOME']`.
<isene> You're on 🔥. Cool. Would you mind putting it all into an email (easier to use as a to-do list)? (g@isene.com)
<havenwood> isene: Nifty project. Happy birthday!
<isene> 👍🎂
chouhoulis has quit [Remote host closed the connection]
summerisle has joined #ruby
markong has joined #ruby
justache is now known as justHaunted
markong has quit [Remote host closed the connection]
markong has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
joshuacronemeyer has joined #ruby
davispuh has joined #ruby
blackmesa has joined #ruby
RiPuk has joined #ruby
cnsvc has joined #ruby
aesthe has quit [Quit: Leaving]
<crankharder> is ruby known to read from the RUBY_EXTRA_CONFIGURE_OPTIONS env variable when configuring? asking because I see some Stack overflows referencing it, but it doens't appear to work for me in the context of installing rubyies with rvm on OSX. Thanks!
<adam12> crankharder: No reference to it in the Ruby source. Might just be an rvm thing.
moeSizlak has left #ruby ["Leaving"]
<havenwood> crankharder: Looks like an asdf thing.
akem has quit [Remote host closed the connection]
ldepandis has joined #ruby
akem has joined #ruby
landakram has joined #ruby
cthulchu_ has quit [Ping timeout: 256 seconds]
stryek has joined #ruby
cthulchu has joined #ruby
cnsvc has quit [Quit: WeeChat 2.9]
rippa has joined #ruby
landakram has quit [Ping timeout: 260 seconds]
impermanence has quit [Ping timeout: 256 seconds]
crankharder has quit [Ping timeout: 256 seconds]
go|dfish has quit [Remote host closed the connection]
go|dfish has joined #ruby
vondruch has quit [Ping timeout: 246 seconds]
roshanavand has quit [Ping timeout: 260 seconds]
hiroaki has joined #ruby
imode has joined #ruby
cd has joined #ruby
ap4y has joined #ruby
weaksauce has joined #ruby
powerhouse has quit [Read error: Connection reset by peer]
crankharder has joined #ruby
powerhouse has joined #ruby
TCZ has joined #ruby
blackmesa has quit [Quit: WeeChat 2.9]
crankharder has quit [Ping timeout: 260 seconds]
burgestrand has joined #ruby
ellcs has joined #ruby
burgestrand has quit [Quit: burgestrand]
crankharder has joined #ruby
summerisle has quit [Quit: In my vision, I was on the veranda of a vast estate, a palazzo of some fantastic proportion.]
summerisle has joined #ruby
chouhoulis has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roshanavand has joined #ruby
dcunit3d has quit [Ping timeout: 272 seconds]
ur5us has joined #ruby
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hiroaki has quit [Ping timeout: 246 seconds]
dcunit3d has joined #ruby
Seich has joined #ruby
howdoi has joined #ruby
acovrig has joined #ruby
<acovrig> I feel like I'm missing something simple, how is this an "invalid date"? `DateTime.strptime('10/1/2020 01:02:03', '%D %T')`
Seich has quit [Quit: Gone fishing.]
Seich has joined #ruby
tubbo has joined #ruby
<adam12> acovrig: Bug maybe?
<adam12> acovrig: Actually it's not; %D won't take a 4 digit year.
<adam12> acovrig: Ironically, it will if it's on it's own. But once you put it with ` %T` it complains.
<acovrig> OK, I was gonna say, but it does (as I test on it's own w/out the time) lol
<adam12> &>> require "time"; Time.strptime("10/01/2020", "%D")
<rubydoc> # => 2020-10-01 00:00:00 +0000 (https://carc.in/#/r/9v6o)
<adam12> acovrig: Yeah. Instead of using %D, you'll probably have to build up your own. %m/%d/%Y
<adam12> &>> require "time"; Time.strptime("10/01/2019", "%D")
<rubydoc> # => 2020-10-01 00:00:00 +0000 (https://carc.in/#/r/9v6p)
<adam12> I stand corrected; %D works for this year, but won't for next / previous years :O
cow[moo] has joined #ruby
<acovrig> &>> require "time"; DateTime.strptime('10/1/2020 01:02:03', '%m/%d/%Y %T')
<rubydoc> # => #<DateTime: 2020-10-01T01:02:03+00:00 ((2459124j,3723s,0n),+0s,2299161j)> (https://carc.in/#/r/9v6t)
<acovrig> &>> require "time"; DateTime.strptime('10/1/2020 01:02:03', '%D %T')
<rubydoc> stderr: -e:4:in `strptime': invalid date (Date::Error)... check link for more (https://carc.in/#/r/9v6u)
<acovrig> interesting indeed lol
<acovrig> &>> require "time"; DateTime.strptime('10/1/2020', '%D')
<rubydoc> # => #<DateTime: 2020-10-01T00:00:00+00:00 ((2459124j,0s,0n),+0s,2299161j)> (https://carc.in/#/r/9v6v)
orbyt_ has joined #ruby
acovrig has quit [Remote host closed the connection]
cow[moo] has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
CalimeroTeknik has quit [Ping timeout: 256 seconds]
crankharder has quit [Ping timeout: 260 seconds]
<al2o3-cr> that's correct behaviour %D = %m/%d/%y
<al2o3-cr> %y = year without century, so, 2 digits.
CalimeroTeknik has joined #ruby
<al2o3-cr> &>> require 'date'; DateTime.strptime('10/1/1944987324798234', '%D') # good, only one format specifier. will stop when matched.
<rubydoc> # => #<DateTime: 2019-10-01T00:00:00+00:00 ((2458758j,0s,0n),+0s,2299161j)> (https://carc.in/#/r/9v76)
<al2o3-cr> &>> require 'date'; DateTime.strptime('10/1/1944 01:02:03', '%D %T') # bad, two format specifiers matching '??/??/??<space>??:??:??'
<rubydoc> stderr: -e:4:in `strptime': invalid date (Date::Error)... check link for more (https://carc.in/#/r/9v77)
<al2o3-cr> &>> require 'date'; DateTime.strptime('10/1/19 01:02:03', '%D %T') # good, two format specifiers matching '??/??/??<space>??:??:??'
<rubydoc> # => #<DateTime: 2019-10-01T01:02:03+00:00 ((2458758j,3723s,0n),+0s,2299161j)> (https://carc.in/#/r/9v78)
TCZ has quit [Quit: Leaving]
hiroaki has joined #ruby
<al2o3-cr> which why it seems confusing.
hiroaki has quit [Remote host closed the connection]
crankharder has joined #ruby
hiroaki has joined #ruby
burgestrand has joined #ruby
crankharder has quit [Ping timeout: 260 seconds]
Seich has quit [Quit: Gone fishing.]
Seich has joined #ruby
daemonwrangler has quit [Ping timeout: 265 seconds]
aloy has quit [Ping timeout: 260 seconds]
shortdudey123 has quit [Ping timeout: 260 seconds]
hiroaki has quit [Ping timeout: 272 seconds]
TCZ has joined #ruby
aloy has joined #ruby
Emmanuel_Chanel has quit [Read error: Connection reset by peer]
Emmanuel_Chanel has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Seich has quit [Quit: Gone fishing.]
orbyt_ has joined #ruby
Seich has joined #ruby
daemonwrangler has joined #ruby
Seich has quit [Client Quit]
Seich has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has quit [Ping timeout: 240 seconds]
Seich has quit [Quit: Gone fishing.]
Seich has joined #ruby
burgestrand has quit [Quit: burgestrand]
Seich has quit [Client Quit]
Seich has joined #ruby
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
CalimeroTeknik has quit [Quit: バイバイ]
CalimeroTeknik has joined #ruby
stryek has quit [Quit: Connection closed for inactivity]
crankharder has joined #ruby
summerisle has quit [Quit: In my vision, I was on the veranda of a vast estate, a palazzo of some fantastic proportion.]
summerisle has joined #ruby
orbyt_ has joined #ruby
TCZ has quit [Quit: Leaving]
crankharder has quit [Ping timeout: 260 seconds]
dionysus69 has quit [Ping timeout: 260 seconds]
TCZ has joined #ruby
crankharder has joined #ruby
crankharder has quit [Ping timeout: 272 seconds]
crankharder has joined #ruby