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!
ropeney has joined #ruby
davispuh has joined #ruby
duderonomy has joined #ruby
sh7d has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
ropeney has quit [Ping timeout: 265 seconds]
ropeney has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has quit [Quit: WeeChat 2.7]
Swyper has quit [Remote host closed the connection]
ropeney has quit [Ping timeout: 268 seconds]
fphilipe has joined #ruby
anveo has joined #ruby
<havenwood> Scriptonaut: gem install bundler --version '~> 1.0'
<havenwood> Scriptonaut: bundler _1.17.3_ install
drincruz_ has quit [Ping timeout: 258 seconds]
davidw has quit [Ping timeout: 258 seconds]
fphilipe has quit [Ping timeout: 248 seconds]
ropeney has joined #ruby
<Scriptonaut> I ended up upgrading ruby gems and it fixed it
<Scriptonaut> was just super confused why I had two identical machines and it only gave me that on one of them
<Scriptonaut> thanks for the help
Swyper has joined #ruby
davidw has joined #ruby
davidw has quit [Changing host]
davidw has joined #ruby
Swyper has quit [Remote host closed the connection]
Xeago has quit [Read error: Connection reset by peer]
Xeago has joined #ruby
bmurt has joined #ruby
ropeney has quit [Ping timeout: 268 seconds]
ropeney has joined #ruby
tryhard21 has quit [Ping timeout: 265 seconds]
cthu| has quit [Ping timeout: 240 seconds]
troulouliou_div2 has quit [Remote host closed the connection]
davidw has quit [Ping timeout: 240 seconds]
turbo_choo has quit [Ping timeout: 268 seconds]
turbo_choo has joined #ruby
turbo_choo has quit [Ping timeout: 258 seconds]
turbo_choo has joined #ruby
jaequery has quit [Remote host closed the connection]
jaequery has joined #ruby
jaequery has quit [Ping timeout: 240 seconds]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
akemhp_ has joined #ruby
akemhp has quit [Ping timeout: 260 seconds]
duderonomy has joined #ruby
im0nde_ has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
im0nde has quit [Ping timeout: 248 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<craz> What is the proper way to test an api since I have no data in my DB? Do I put stuff in there or stub the response or whats the right way?
william1_ has joined #ruby
<hramrach> hello
<hramrach> is it normal to get the same fd multiple times in accept?
william1_ has quit [Ping timeout: 260 seconds]
Swyper has joined #ruby
hays has quit [Ping timeout: 260 seconds]
jaequery has joined #ruby
<hramrach> hm, variable scoping most like
Swyper has quit [Remote host closed the connection]
duderonomy has joined #ruby
DaRock has joined #ruby
jrhorn424 has quit [Quit: Connection closed for inactivity]
vampirehunter has quit [Ping timeout: 245 seconds]
DaRock has quit [Read error: Connection reset by peer]
DaRock has joined #ruby
alex`` has quit [Ping timeout: 240 seconds]
AJA4350 has quit [Remote host closed the connection]
drincruz_ has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
fphilipe has joined #ruby
hays has joined #ruby
fphilipe has quit [Ping timeout: 252 seconds]
bruce_lee has quit [Ping timeout: 268 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
jaequery has quit [Remote host closed the connection]
hays has quit [Ping timeout: 268 seconds]
Swyper has joined #ruby
jaequery has joined #ruby
alexherbo2 has joined #ruby
hays has joined #ruby
wildtrees has quit [Quit: Leaving]
alex`` has joined #ruby
DaRock has quit [Ping timeout: 240 seconds]
DaRock has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bruce_lee has quit [Ping timeout: 258 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
Swyper has quit [Remote host closed the connection]
craz has quit [Ping timeout: 265 seconds]
bambanx has quit [Quit: Leaving]
drincruz_ has quit [Ping timeout: 268 seconds]
gix has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
alex`` has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 265 seconds]
william1_ has joined #ruby
william1_ has quit [Ping timeout: 258 seconds]
Swyper has joined #ruby
Rob__ has quit [Read error: Connection reset by peer]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
xall has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
AarC10 has joined #ruby
xall has quit [Quit: xall]
fphilipe has joined #ruby
fphilipe has quit [Ping timeout: 260 seconds]
Swyper has quit [Remote host closed the connection]
jaequery has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
markopasha has quit [Remote host closed the connection]
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 260 seconds]
hays has quit [Ping timeout: 258 seconds]
cthulchu_ has joined #ruby
ur5us has joined #ruby
AarC10 has quit [Quit: Leaving]
skx86 has quit [Quit: Connection closed for inactivity]
suukim has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
william1_ has joined #ruby
fphilipe has joined #ruby
william1_ has quit [Ping timeout: 258 seconds]
fphilipe has quit [Ping timeout: 260 seconds]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
hstl has joined #ruby
<hstl> anybody here? what can you say about this code? https://i.ibb.co/ky1vzp0/2020-01-10-14-50-21-Window.jpg
<hstl> it looks like a small piece of bigger script, right?
sphex has quit [Read error: Connection reset by peer]
sphex has joined #ruby
Buggys has quit [Excess Flood]
Buggys has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
sauvin has joined #ruby
sauvin has quit [Max SendQ exceeded]
cthulchu_ has quit [Ping timeout: 260 seconds]
sauvin has joined #ruby
fphilipe has joined #ruby
skx86 has joined #ruby
TomyWork has joined #ruby
andikr has joined #ruby
Omnilord has joined #ruby
ellcs has joined #ruby
fphilipe has quit [Ping timeout: 248 seconds]
dionysus69 has joined #ruby
william1_ has joined #ruby
william1_ has quit [Ping timeout: 240 seconds]
<ytti> hstl, do you have specific question?
<ytti> hstl, it is probably metasplit exploit
conta has joined #ruby
fphilipe has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.7]
al2o3-cr has joined #ruby
vondruch has joined #ruby
suukim has quit [Quit: Konversation terminated!]
nowhere_man has quit [Ping timeout: 268 seconds]
<NL3limin4t0r> hramrach: I wouldn't find it weird. I've worked with sockets in C and you tippically split of a new thread to handle the incomming connection, then close the socket on the main thread and listen for incomming connections again. So the file descripor should be availble on the main thread again.
akemhp_ has quit [Ping timeout: 240 seconds]
feep[work] has joined #ruby
<feep[work]> hi
<feep[work]> why does rubocop ignore files listed on the commandline if they don't have a ruby extension?
<feep[work]> like, if I specifically give you the file, it stands to reason that should override filters?
<feep[work]> repro: touch foo; rubocop foo
<feep[work]> background: I can't lint rakefile
<feep[work]> Include doesn't work either
<hramrach> NL3limin4t0r: if you don't take care to pass the fd as block argument it is teh same in concurrent threads
<hramrach> as in Ruby loops don't have own scope so you get same scope for each iteration of the accept loop and the update of the fd in the accept loop applies to all threads that reference the fd from the accept loop local scope
akemhp has joined #ruby
<feep[work]> found a workaround: #!/usr/bin/rake at the top of rakefile
<feep[work]> bit hacky
<feep[work]> I still want to know why rubocop ignores it otherwise.
Tuor has joined #ruby
william1_ has joined #ruby
<Tuor> Hi I just installed rbenv and wanted to install ruby 2.7.0 but it's not available. I'm running kubuntu 19.10 and did install rbenv with apt.
Lyubo1 has quit [Ping timeout: 240 seconds]
Jonopoly has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
<Tuor> I think it's because it's an old version of rbenv.
<leftylink> speaking of Ruby 2.7... does carcinogen have that yet?
<leftylink> &>> RUBY_VERSION
<rubydoc> # => "2.6.0" (https://carc.in/#/r/8d9b)
<leftylink> guess I'm on my own then
Fusl has quit [Excess Flood]
Fusl has joined #ruby
<feep[work]> while we're at it, wtf is up with Style/ClassVars?
<feep[work]> it's a linter error that's like ... "this ruby feature, doing exactly what it's supposed to, is 'bad' because we don't trust you to understand what it does"
<feep[work]> a linter should not be a tool for backdoor language design.
<feep[work]> oh well, another cop to disable
<ytti> linter should be opinionated
<ytti> the goal should be to have one answer to every question and enforce that answer
<ytti> the utility of having same thing same way always is significnat
<feep[work]> yes, but the question should not be "should ruby be designed the way it is"
<feep[work]> and the answer should not be "no"
<feep[work]> there is a process for that, it's called deprecation
<ytti> lot of linters are opinionated about language features
<ytti> and do not allow specific language features
<feep[work]> sure, for basically-unmaintained languages
<feep[work]> like C
<ytti> black does that for python
<feep[work]> where releases are yearly and require a committee
<ytti> 'we dont like it, because we dont like it'
<ytti> and i'm fine by that
<ytti> gofmt does that for go
<ytti> i think being highly opinionated is good, not bad
<feep[work]> I think it's bad there too
<feep[work]> nothing wrong with being opinionated, I just think it's the wrong forum
<ytti> it's foru mwhere they can implement the change NOW
<feep[work]> the forum for being opinionated about language design is the language's dev ml.
<ytti> that may never happen
<feep[work]> then it shouldn't happen in the linter either.
<ytti> in the mean time, your project has different opinions on same problem
<ytti> i personally want the linter to decide on competing language features which one is the right one
<feep[work]> yes, but those are not competing language features!
<feep[work]> this is a language feature, that was decided to be in the language, and is not scheduled for deprecation
<feep[work]> and there's a cop that says "this entire feature is bad, remove"
<feep[work]> and it's *on by default*
<feep[work]> this is broken.
<ytti> i for one agree
<ytti> if you need @@ it's almost always wrong
<ytti> if it's not wrong, add exception for _that_ line
<feep[work]> I mean, what I'll actually do is turn the cop off, but ... why is that wrong?
<ytti> there is no wrong or right, just what people prefer
<ytti> you prefer on thing
<NL3limin4t0r> Both a class instance variable and a class variable have their own use cases. However if you're not familiar with a class variable in Ruby the class instance variable is the safer option, that is why it's recommended by RuboCop.
<ytti> i prefer the thing it does
<feep[work]> you said "it's almost always wrong" so why is it wrong?
<feep[work]> NL3limin4t0r: but ... they don't solve the same problem...
<ytti> i'd need to see the code
<ytti> to say if in that case it 's needed or not
<ytti> but in most cases, there is cleaner solution to the problem, where they are not needed
<ytti> in some cases, the cleanest solution available uses them
<feep[work]> okay, I hope so, so I'll just ask for the cleaner solution
<feep[work]> what we basically want is a namespace, ie. a class with just static methods
<NL3limin4t0r> They dont solve the same problem, but there is a lot of overlap.
<feep[work]> it's never inherited and never instantiated
<ytti> usually people use module for namespace (and include that when needed)
<feep[work]> right, but I want to write Foo.method()
<feep[work]> can I do that with module?
<ytti> yes
<feep[work]> okay, then nevermind the whole topic :DD
<feep[work]> x-y strikes again~
<ytti> oh not .
* feep[work] eyebrows
<feep[work]> ... not .?
<NL3limin4t0r> &>> module Foo; class << self; def some_method; puts 'Hello world!'; end; end; end; Foo.some_method
<rubydoc> # => Hello world!... check link for more (https://carc.in/#/r/8d9c)
<feep[work]> NL3limin4t0r: okay, so how do I do member variables inside the module?
<ytti> it does not sound 'i only want namespace' then
<ytti> it seems you want class :)
<feep[work]> variables are a namespaced thing
<feep[work]> I have a bunch of variables shared by a bunch of methods called with Foo.method
<NL3limin4t0r> What do you mean by member?
<feep[work]> and I want them to be hidden away
<feep[work]> inside that namespace
<ytti> he means instance variables
<feep[work]> no
<ytti> he needs class
<feep[work]> I don't
<NL3limin4t0r> A module can have it's own instance variables, give me a sec for an example.
<ytti> you have multiple methods which need to see same value for given variable
<ytti> you should create and instantiate class
<feep[work]> NL3limin4t0r: basically I want to say "static variables" without prejudicing the question
<ytti> and transport that instance as needed
<feep[work]> ytti: but I don't want to instantiate a class, because I never want to reference more than one version of the class
<feep[work]> this is global state
<ytti> i really don't understaned why
<ytti> why not just
<ytti> FOO = Class.new
<ytti> and never reinstanttiate
<feep[work]> because that already exists
<ytti> use thne FOO instance where ever
<feep[work]> and it's called "static variables and static methods"
<feep[work]> and I don't see a reason to pretend that feature doesn't exist so I can badly emulate it with another feature
<feep[work]> just to make the linter happy
<feep[work]> I mean, what I really want here is module namespacing
<feep[work]> but ruby doesn't have that, so...
<feep[work]> maybe?
<feep[work]> hoping for example for module with variables
<NL3limin4t0r> &>> module Foo; class << self; attr_accessor :some_value; def some_method; puts "The value is: #{some_value}"; end; end; end; Foo.some_method; Foo.some_value = "something"; Foo.some_method
<rubydoc> # => The value is:... check link for more (https://carc.in/#/r/8d9g)
<NL3limin4t0r> ^ check the link
<feep[work]> NL3limin4t0r: Ooh. Can I give attr_accessor a default value?
<NL3limin4t0r> Yes, you can either set it after defining it or write a curom getter that has a default value.
<feep[work]> okay but can I give it a default value without that
<feep[work]> because rn I can just write @@foo = []
<ytti> &>> module Foo; K=100; def self.a; K*2;end; def self.b; K/2;end;end;p Foo.a;Foo.b
<rubydoc> # => 200... check link for more (https://carc.in/#/r/8d9k)
<ytti> but i wouldn't do this
<feep[work]> I also wouldn't do this
<feep[work]> because it's bad :p
<ytti> yes, class is better and just instantiate it once
<NL3limin4t0r> &>> module Foo; @some_value = "default" class << self; attr_accessor :some_value; def some_method; puts "The value is: #{some_value}"; end; end; end; Foo.some_method
<rubydoc> stderr: -e:4: syntax error, unexpected class, expecting end... check link for more (https://carc.in/#/r/8d9l)
conta has quit [Ping timeout: 240 seconds]
<NL3limin4t0r> oops
<NL3limin4t0r> &>> module Foo; @some_value = "default"; class << self; attr_accessor :some_value; def some_method; puts "The value is: #{some_value}"; end; end; end; Foo.some_method
<rubydoc> # => The value is: default... check link for more (https://carc.in/#/r/8d9m)
<feep[work]> NL3limin4t0r: Ooh.
<NL3limin4t0r> You can even leave out the accessor if you want
<NL3limin4t0r> &>> module Foo; @some_value = "default"; class << self; def some_method; puts "The value is: #{@some_value}"; end; end; end; Foo.some_method
<rubydoc> # => The value is: default... check link for more (https://carc.in/#/r/8d9q)
<feep[work]> cool
<NL3limin4t0r> The accessor is intended for outsid setting/getting of the value.
<feep[work]> NL3limin4t0r: how does that differentiate from @@?
<feep[work]> this seems like p much 1:1 what I want
<ytti> that's same as i showed :)
<ytti> just @k instead of K
<feep[work]> ytti: nope, because namespaced
<ytti> and you wanted static variable
<feep[work]> K is global
<ytti> no
<ytti> it's not
<ytti> 'it's namespaced to Foo
<feep[work]> o.o
<feep[work]> K in module is namespaced?
<ytti> yes
<feep[work]> huh, I thought that was a global ns, thanks for the lesson!
<ytti> it's just const (static)
<ytti> where as NL3's example it's instance
<feep[work]> ... it's module, how is it instance
<ytti> but all of these are imho antipattern
<ytti> it's module instance
<NL3limin4t0r> a module is an instance of Module
<ytti> module is instances of Module class
<ytti> all of these examples are antipattern
<ytti> and Foo = Class.new
<ytti> is imho, far more ruby idiomatic way to do what you want
<feep[work]> um
<ytti> just because you can instanttiate it many times, does not mean you should
<NL3limin4t0r> &>> module Foo; end; Foo.class.ancestors
<rubydoc> # => [Module, Object, Kernel, BasicObject] (https://carc.in/#/r/8d9z)
<feep[work]> yeah but ... this is just bad language design imo
<feep[work]> I don't want to even leave the option to instantiate it
<feep[work]> you shouldn't have to rely on discipline to get correct behavior
<feep[work]> in that sense, module seems perfect
<feep[work]> thanks NL3limin4t0r!
<ytti> if you share that code with people familiar with ruby, they won't like it
<feep[work]> ytti for debate too :)
<NL3limin4t0r> You can't instantiate a module, but a module is an instance itself if that makes sence.
<feep[work]> NL3limin4t0r: that makes perfect sense
<ytti> but at least we covered 'usually more idiomatic solution than using @@var'
<ytti> since while this is not what i'd do, it's still more idiomatic than original
Omnilord has quit [Quit: Leaving]
<NL3limin4t0r> I guess in your usecase the differnces between @@var and @var isn't terribly noticable, since you only use the module as namespace for "module function". But mostly an instance variable @var is what you want, there are reasons to use @@var but you first have to know where they differ.
<feep[work]> I mean, that goes for every nontrivial language feature, right?
<feep[work]> I don't think we should be so afraid of noobs using the wrong feature that we sacrifice the capacity
<NL3limin4t0r> However if your module where to be included in a class you might notice some differnces.
<NL3limin4t0r> But I guess ^ isn't the intent of your module
phaul has joined #ruby
<feep[work]> yep
Lyubo1 has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
<NL3limin4t0r> if your variable is a constant you should use SOME_CONSTANT like ytti suggested
<feep[work]> it's not
<feep[work]> this is feature configuration
<feep[work]> you do stuff like Feature.set(bla)
<ytti> @@var is needed when you need multiple instances and you need these instances to share value
<ytti> which is already highly atypical need
<ytti> and probably can be refactored away
<NL3limin4t0r> feep[work]: Like you can see in my example above, OpenStruct lends itself pretty well for configurable variables.
<ytti> i wrote this on top of openstruct - https://github.com/ytti/asetus
<ytti> basically reads YAML/TOML/JSON file and offers read/write to keys as.string.of.methods
<ytti> creating default configuration for user, if needed
<ytti> with ability to load config from global and user and system, and merge results
<ytti> so /etc could have one config and ~home another, and they are merged with home taking precedence
<NL3limin4t0r> ActiveSupport also has a Configurable class, if you need a more complex config object.
<feep[work]> NL3limin4t0r: noted, but I'll stick with the simple way
<ytti> openstruct is the simple way :)
<feep[work]> neh
<NL3limin4t0r> instance variables will do, but are less dynamic
al2o3-cr has quit [Ping timeout: 256 seconds]
<feep[work]> I'm very fine with that.
antholog has quit [Ping timeout: 260 seconds]
al2o3-cr has joined #ruby
greenhat has quit [Ping timeout: 260 seconds]
greenhat has joined #ruby
fphilipe has quit [Ping timeout: 260 seconds]
fphilipe has joined #ruby
<NL3limin4t0r> feep[work]: Here is the example I provided earlier, but multi-line so you can better see what's happening.
davispuh has joined #ruby
davispuh has quit [Client Quit]
maloik has joined #ruby
<maloik> Hey folks. Not strictly a ruby question, but I'm wondering if anyone has any tips for technology and/or services that would be able to identify climbing holds on a picture of a climbing wall
<NL3limin4t0r> maloik: never worked with it myself, but you might want to look into "computer vision" there is for example: https://github.com/ruby-opencv/ruby-opencv/
greengriminal has joined #ruby
<NL3limin4t0r> Which is a wrapper for OpenCV, most of the documention can be found on https://opencv.org/
<maloik> Yea I've googled that before but didn't find much. They have an IRC channel though, I'll ask there too. Thanks
antholog has joined #ruby
emilych has joined #ruby
<NL3limin4t0r> can't help you any further than that since I don't have any experience with the wrapper gem nor OpenCV itself
gigetoo has quit [Ping timeout: 265 seconds]
<emilych> Hi, I have a small ruby script:
davispuh has joined #ruby
<maloik> no worries, vague directions like this are a good start since I literally have no idea where to even begin
greenhat has quit [Ping timeout: 268 seconds]
davispuh has quit [Remote host closed the connection]
<NL3limin4t0r> emilych: I can't see your script, but if it's multi-line you might want to make a gist or use https://dpaste.de
<emilych> class CsvExporter def input "foo" end@input = inputend
fphilipe has quit [Read error: Connection reset by peer]
<emilych> I'm getting: NameError (undefined local variable or method `input' for CsvExporter:Class)
greenhat has joined #ruby
tryhard21 has joined #ruby
<emilych> I'm trying to assign @input the return value of method input
<NL3limin4t0r> That is because the `input` method as defined is an instance method, not a class method
<emilych> ah, of course, i see!
<emilych> thanks!
<NL3limin4t0r> tl;dr use `def self.input` to define your method
<emilych> thanks again!
<emilych> yes!
lunarkitty has quit [Ping timeout: 248 seconds]
<NL3limin4t0r> fyi, don't forget there is a CSV standard library
lunarkitty has joined #ruby
<NL3limin4t0r> ^ don't know what you are doing, but it might save you some time
suukim has joined #ruby
<emilych> I'm doing this :) https://dpaste.org/Zc3R
davispuh has joined #ruby
gigetoo has joined #ruby
<emilych> it works but if you find something odd I'd be glad to improve the code
akemhp has quit [Remote host closed the connection]
akemhp has joined #ruby
alexherbo2 has joined #ruby
bsdbandit-01 has joined #ruby
akemhp has quit [Ping timeout: 268 seconds]
lunarkitty has quit [Ping timeout: 260 seconds]
alex`` has joined #ruby
lunarkitty has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
<emilych> 2.6.3 (main):0 > file = File.open("final_result.json");new_hash = JSON.parse(file) TypeError: no implicit conversion of File into String
<emilych> how can I fix this?
<emilych> ah, i found the solution
<NL3limin4t0r> data = JSON.parse(File.read('final_result.json'))
<emilych> yes, thanks!
snappy has joined #ruby
<NL3limin4t0r> `File.read('final_result.json')` directly returns a string while File.open will return a file that you still have to read from (and close if you don't use a block).
<snappy> q: i'm running 'test do system bin/"dsvpn", "--help"' for homebrew, is htere a way to check the return is value 254?
<feep[work]> man, given a new rubocop cop it
<feep[work]> 's about 50/50 if I end up following it or turning it off permanently
<feep[work]> that's not a good ratio
phaul has joined #ruby
<feep[work]> (turned off so far: AbcSize, BlockLength, BlockNesting, MethodLength, HeredocDelimiterNaming, AndOr, Not, ClassVars, ConditionalAssignment, FrozenStringLiteralComment, HashSyntax, LineEndConcatenation, MutableConstant
<feep[work]> )
<feep[work]> and like, that's not "I don't want to bother fixing this", it's "what on earth where they thinking"
<feep[work]> were*
<NL3limin4t0r> RuboCop comes with defaults, but should be configured to your own liking
<feep[work]> right, which is so far mostly taking the form of turning off parts of it...
<NL3limin4t0r> configure the settings you don't like
<feep[work]> right, I'm doing that
<feep[work]> I'm just griping, ignore me
AJA4350 has joined #ruby
<NL3limin4t0r> emilych: there is quite a lot that can be improved, for example your method `transform_to_array` merges the `month` and `doc_count` into a string. I would keep the data seperated as long as possible until there is the need to merge it. Keeping it seperated would for example make it way easyier to check if a month is already present.
william1_ has quit [Ping timeout: 268 seconds]
<emilych> yes, you're right!
hstl has quit [Ping timeout: 265 seconds]
x0n has quit [Quit: ZNC - https://znc.in]
turbo_choo has quit [Ping timeout: 258 seconds]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
turbo_choo has joined #ruby
donofrio has joined #ruby
davispuh has joined #ruby
davispuh has quit [Read error: Connection reset by peer]
x0n has joined #ruby
DTZUZO_ has quit [Read error: Connection reset by peer]
DTZUZO_ has joined #ruby
chalkmonster has joined #ruby
davispuh has joined #ruby
akemhp has joined #ruby
ellcs has quit [Remote host closed the connection]
ellcs has joined #ruby
maloik has quit [Ping timeout: 260 seconds]
fphilipe has joined #ruby
voker57 has quit [Quit: voker57]
hays has joined #ruby
hays has quit [Client Quit]
juvenal has joined #ruby
tsujp has joined #ruby
<emilych> Hi, I have this array and like to remove the datestamp in all elements: m = %w[2019-01-01T00:00:00.000Z 2019-02-01T00:00:00.000Z: 2019-03-01T00:00:00.000Z:\ 12341234 ]
<emilych> row.reject { |e| e.match(/^\d{4}-\d{2}-\d{2}T[0:.]*Z(:|)/) }
<emilych> ah, I think I got it!
<emilych> moment
ellcs has quit [Ping timeout: 268 seconds]
Tikku has joined #ruby
Tikku has quit [Client Quit]
ellcs has joined #ruby
turbo_choo has quit [Ping timeout: 258 seconds]
bmurt has joined #ruby
<feep[work]> okay, here's another super weird question
<feep[work]> I have a config file that contains some eval strings that do some stuff
<feep[work]> I want the eval strings to be able to call some functions with foo(), I want those functions to have access to some local context, but I also need global definitions made in the eval block to be inserted into the global namespace
<feep[work]> and preferably I want to do this without defining any global variables myself, currently I use a temporary which is ugly
<feep[work]> temporary global*
<feep[work]> I can't use lambda because then it's foo.call(), not foo()
<feep[work]> I can't eval in a class context because then the globals will land in the class, not the surroundings
rapha has left #ruby ["WeeChat 2.3"]
anveo has joined #ruby
<feep[work]> alternately, is there any way to let me call a proc as a method
<feep[work]> ie. with foo()
lucasb has joined #ruby
<feep[work]> may have found a way!
jcalla has joined #ruby
<feep[work]> haha yes, eval inside instance_eval
<feep[work]> FOO = "bla" goes to the surrounding namespace, but you can call methods as if you're in the class
turbo_choo has joined #ruby
chalkmonster has quit [Remote host closed the connection]
fuzzface has joined #ruby
impermanence has joined #ruby
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<NL3limin4t0r> emilych: here is some inspiration: https://gist.github.com/3limin4t0r/e1471b051080e8f96acaee5faca369d3
<NL3limin4t0r> I'm not entirely sure if I've got the output you want though
<emilych> OHHH, wow! My head is exploding!
<emilych> cool, you reduced my script to half and it's much clearer and more robust! thank you very much!
<emilych> third= one third
<NL3limin4t0r> np, I currently wrote it in plain script form, but you can hang it in a class or module if you want. possibly extracting some logic into private methods
<emilych> not half even to one third
<emilych> yes, I'll do! thanks again!
<feep[work]> hm
<feep[work]> is this intended to work? ie. may this get broken by a future ruby update?
<NL3limin4t0r> I've also opted use OpenStruct as object class for JSON parsing, since that allows you to navigate the objects using dot syntax (`object.attribute`) which makes mapping attributes a lot cleaner (`array.map(&:attribute)` instead of `array.map { |object| object['attribute'] }`).
<feep[work]> ie. blocks evaluated in classes with instance_eval still being able to set global constants
<emilych> cool! I read some time ago about openstruct, good to see an use case in my example!
Swyper has joined #ruby
drincruz_ has joined #ruby
<NL3limin4t0r> feep[work]: Why use an eval string? Can't you use a proc instead, that you invoke at the point you need it? Is it serialized from a yml/json file, because that's a valid reason you can't use a proc.
<ellcs> NL3limin4t0r: when using ostruct, dont you have performance considerations?
juvenal has joined #ruby
juvenal has quit [Client Quit]
<feep[work]> NL3limin4t0r: because we didn't understand how procs worked when we wrote allllll this config, and now we're stuck with it :D
william1_ has joined #ruby
<feep[work]> (also because we want to inject variables into it)
craz has joined #ruby
<feep[work]> are there better ways? yes. definitely, yes.
<feep[work]> not worth the effort of switching tho
Swyper has quit [Remote host closed the connection]
<NL3limin4t0r> ellcs: I haven't taken performence into account. It might be a bit slower, but imo way more readable.
Swyper has joined #ruby
<NL3limin4t0r> ellcs: Performence only matters at the point that it's actively hindering you. Otherwise I would go over readability 95% of the times.
Swyper has quit [Remote host closed the connection]
<NL3limin4t0r> Since I don't know how large the api response is going to be I use OpenStruct, since most apis limit the response to a certain number that leaves quite a lot of margin before throtteling. If an array of 10k elments is returned you might start noticing some issues.
sergioro has joined #ruby
<NL3limin4t0r> feep[work]: So basically you have some legacy strings that must be evaluated.
<feep[work]> yep
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Jonopoly has quit [Quit: WeeChat 2.5]
Swyper has joined #ruby
<NL3limin4t0r> You can dynamically create methods and pass them a proc. Say you have a proc `foo = proc { ... }` you can define a method `foo` by using `define_method(:foo, &foo)` or `define_singleton_method(:foo, &foo)` depending on your context. Note that if you `eval` your string while the variable `foo` is still in scope "foo()" will refer to the method, but "foo" will refer to the variable.
<feep[work]> right but it also can't be a method
<feep[work]> that's the hilarious part
<feep[work]> cause it has to also be able to define global variables
<feep[work]> non-class-namespaced global variables
<ellcs> couldn't resist and wrote a small benchmark. the only situation i would avoid using ostruct, is when setting values `o.b = 2`.
<NL3limin4t0r> you can define global variables from within a method
<feep[work]> NL3limin4t0r: yes but they're namespaced to the class
<feep[work]> owait
<feep[work]> NL3limin4t0r: I understand what you mean
<feep[work]> this is coool
<feep[work]> that might be the much easier way
andikr has quit [Remote host closed the connection]
<NL3limin4t0r> global variables are defined with a dollar sign at the front
<NL3limin4t0r> `$foo` would be global
<feep[work]> I mean allcaps globals, .... constants?
<NL3limin4t0r> and is accessible everywhere in the program
<feep[work]> NL3limin4t0r: yep, define_method did it, thanks a bunch
<feep[work]> hm
<feep[work]> NL3limin4t0r: hm
<feep[work]> though
dionysus69 has quit [Quit: dionysus69]
<feep[work]> if I do this in a loop in a module, won't the defined methods be global?
<NL3limin4t0r> ellcs: the JSON library uses os['attribute'] = 'value' to set all propperties in `JSON.parse(json, object_class: OpenStruct)`
ste512 has joined #ruby
<NL3limin4t0r> feep[work]: Correct, the methods aren't global.
<NL3limin4t0r> To define global methods you should define them on Kernel.
<NL3limin4t0r> those are avaible everywhere (except in BasicObject)
bruce_lee has quit [Ping timeout: 258 seconds]
<feep[work]> NL3limin4t0r: ie. define_method(:foo) made a method that outlived the local block, unlike variables
ste512 has left #ruby [#ruby]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
<feep[work]> that's unpleasant enough that I think the "create a class instance and evaluate in it" is probably the better approach
<feep[work]> a nice isolated scratch space
meinside has quit [Quit: Connection closed for inactivity]
craz has quit [Ping timeout: 248 seconds]
chalkmonster has joined #ruby
SeepingN has joined #ruby
ellcs has quit [Remote host closed the connection]
feep[work] has quit [Ping timeout: 260 seconds]
juvenal has joined #ruby
<NL3limin4t0r> hmm feep[work] is already gone, here is a link for the #ruby log so I can find it back later https://repl.it/repls/DrabPreciousCamel
conta1 has joined #ruby
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troulouliou_div2 has joined #ruby
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
juvenal has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
<NL3limin4t0r> &>> require 'json'; Foo = Class.new; JSON.parse('{"a": 1}', object_class: Foo)
<rubydoc> stderr: /usr/lib/ruby/2.6.0/json/common.rb:156:in `parse': undefined method `[]=' for... check link for more (https://carc.in/#/r/8dat)
<NL3limin4t0r> eldritch: ^
<NL3limin4t0r> Oops, sorry. That should be ellcs, but guess they left.
chalkmonster has quit [Quit: WeeChat 2.7]
bsdbandit-01 has joined #ruby
Esa_ has joined #ruby
troulouliou_div2 has quit [Ping timeout: 240 seconds]
chalkmonster has joined #ruby
turbo_choo has quit [Ping timeout: 268 seconds]
DaRock has quit [Ping timeout: 258 seconds]
turbo_choo has joined #ruby
conta1 has quit [Quit: conta1]
troulouliou_div2 has joined #ruby
jcutrell has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
greengriminal has quit [Quit: Leaving]
greengriminal has joined #ruby
donofrio_ has joined #ruby
jcutrell has quit [Quit: jcutrell]
dkmueller has joined #ruby
davidw has joined #ruby
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
Xiti` is now known as Xiti
Xiti has quit [Quit: Xiti]
Swyper has quit [Remote host closed the connection]
Xiti has joined #ruby
drincruz_ is now known as drincruz
chalkmonster has quit [Quit: WeeChat 2.7]
lineus has quit [Ping timeout: 240 seconds]
conta1 has joined #ruby
impermanence has quit [Remote host closed the connection]
catbusters has joined #ruby
lineus has joined #ruby
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troulouliou_div2 has quit [Remote host closed the connection]
gix has joined #ruby
chalkmonster has joined #ruby
juvenal has joined #ruby
bsdband96 has joined #ruby
sagax has quit [Ping timeout: 240 seconds]
bsdbandit-01 has quit [Ping timeout: 265 seconds]
cloaked1 has joined #ruby
cloaked1 has joined #ruby
cloaked1 has quit [Changing host]
fphilipe has quit [Ping timeout: 268 seconds]
chalkmonster has quit [Quit: WeeChat 2.7]
cthulchu_ has joined #ruby
eddof13 has joined #ruby
greengriminal has quit [Quit: Leaving]
bsdband96 has quit [Ping timeout: 248 seconds]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
BTRE has quit [Remote host closed the connection]
phaul has quit [Ping timeout: 240 seconds]
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
bvdw has quit [Read error: Connection reset by peer]
juvenal has joined #ruby
bvdw has joined #ruby
BTRE has joined #ruby
bsdbandit-01 has joined #ruby
Ai9zO5AP has joined #ruby
sergioro has quit [Quit: Lost terminal]
yield has joined #ruby
phaul has joined #ruby
yield has quit [Client Quit]
phaul has quit [Ping timeout: 268 seconds]
fig-le-deunch has joined #ruby
davispuh has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troulouliou_div2 has joined #ruby
troulouliou_div2 has quit [Remote host closed the connection]
jaequery has joined #ruby
harmaahy1je has joined #ruby
chalkmonster has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
NODE has quit [Remote host closed the connection]
NODE has joined #ruby
phaul has joined #ruby
bruce_lee has quit [Ping timeout: 260 seconds]
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
bruce_lee has joined #ruby
davispuh has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
davispuh has quit [Client Quit]
harmaahy1je is now known as harmaahylje
fig-le-deunch has quit [Quit: Konversation terminated!]
code_zombie has quit [Quit: Leaving]
sagax has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
william1_ has quit [Ping timeout: 260 seconds]
Esa_ has quit []
phage has joined #ruby
tag has quit [Quit: Updating details, brb]
tag has joined #ruby
tag has quit [Client Quit]
tag has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
conta1 has quit [Quit: conta1]
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
fphilipe has joined #ruby
davispuh has joined #ruby
fphilipe has quit [Ping timeout: 260 seconds]
phage has quit [Ping timeout: 248 seconds]
duderonomy has joined #ruby
jenrzzz has quit [Ping timeout: 258 seconds]
fuzzface has quit [Quit: Leaving]
mossplix has joined #ruby
tvl has joined #ruby
tvl is now known as tobiasvl
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dkmueller has quit [Quit: WeeChat 2.7]
dkmueller has joined #ruby
dkmueller has quit [Client Quit]
alexherbo28 has joined #ruby
alex`` has quit [Ping timeout: 258 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo28 is now known as alexherbo2
phaul has joined #ruby
dkmueller has joined #ruby
cloaked1 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
alex`` has joined #ruby
evert has quit [Ping timeout: 260 seconds]
evert has joined #ruby
suukim has quit [Quit: Konversation terminated!]
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phaul has quit [Ping timeout: 265 seconds]
phage has joined #ruby
juvenal has joined #ruby
eddof13 has quit [Quit: eddof13]
dkmueller has quit [Quit: WeeChat 2.7]
alex`` has quit [Ping timeout: 268 seconds]
fphilipe has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
catbusters has quit [Quit: Connection closed for inactivity]
bmurt has joined #ruby
alexherbo28 has joined #ruby
alexherbo28 is now known as alexherbo2
alex`` has joined #ruby
fphilipe has quit [Ping timeout: 248 seconds]
millerti has joined #ruby
fphilipe has joined #ruby
NL3limin4t0r has quit [Ping timeout: 265 seconds]
chalkmonster has joined #ruby
NL3limin4t0r has joined #ruby
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #ruby
fphilipe has quit [Ping timeout: 248 seconds]
juvenal has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #ruby
fphilipe has joined #ruby
eddof13 has joined #ruby
fphilipe has quit [Ping timeout: 246 seconds]
fphilipe has joined #ruby
gray_-_wolf has quit [Quit: WeeChat 2.7]
gray_-_wolf has joined #ruby
jenrzzz has joined #ruby
sameerynho has joined #ruby
phage has quit [Read error: Connection reset by peer]
fphilipe has quit [Ping timeout: 240 seconds]
tryhard21 has quit [Quit: WeeChat 1.9.1]
drincruz_ has joined #ruby
emilych71 has joined #ruby
drincruz has quit [Ping timeout: 258 seconds]
TCZ has joined #ruby
skx86 has quit [Quit: Connection closed for inactivity]
drincruz has joined #ruby
drincruz_ has quit [Ping timeout: 260 seconds]
etupat has joined #ruby
fphilipe has joined #ruby
alexherbo20 has joined #ruby
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo20 is now known as alexherbo2
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #ruby
fphilipe has quit [Ping timeout: 248 seconds]
chalkmonster has quit [Quit: WeeChat 2.7]
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
bsdband90 has joined #ruby
bsdbandit-01 has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
bsdband90 has quit [Ping timeout: 268 seconds]
davispuh has joined #ruby
emilych71 has quit [Remote host closed the connection]
fphilipe has joined #ruby
NL3limin4t0r has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fphilipe has quit [Ping timeout: 268 seconds]
NL3limin4t0r has joined #ruby
buckworst has joined #ruby
william1_ has joined #ruby
buckworst has quit [Client Quit]
buckworst has joined #ruby
silviu20 has joined #ruby
Mia has quit [Read error: Connection reset by peer]
Axy has joined #ruby
Axy has joined #ruby
Axy has quit [Changing host]
silviu has quit [Remote host closed the connection]
skx86 has joined #ruby
william1_ has quit [Ping timeout: 268 seconds]
buckworst has quit [Quit: WeeChat 2.3]
teclator has quit [Quit: No Ping reply in 180 seconds.]
teclator has joined #ruby
mossplix has quit [Remote host closed the connection]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
davispuh has joined #ruby
markopasha has joined #ruby
phaul has joined #ruby
alexherbo29 has joined #ruby
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo29 is now known as alexherbo2
alexherbo2 has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 268 seconds]
kristian_on_linu has joined #ruby
bambanx has joined #ruby
AJA4350 has quit [Ping timeout: 265 seconds]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
alexherbo2 has joined #ruby
AJA4350 has joined #ruby
pwnd_nsfw has joined #ruby
alexherbo29 has joined #ruby
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo29 is now known as alexherbo2
alex`` has joined #ruby
davispuh has joined #ruby
lineus has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
TCZ has quit [Quit: Bye Bye]
davor_ has joined #ruby
davor has quit [Ping timeout: 258 seconds]
davor_ is now known as davor
ellcs has quit [Remote host closed the connection]
buckworst has joined #ruby
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #ruby
Lyubo1 has quit [Ping timeout: 268 seconds]
Lyubo1 has joined #ruby
chalkmonster has joined #ruby
cthulchu_ has quit [Read error: Connection reset by peer]
cthulchu_ has joined #ruby
etupat has quit [Remote host closed the connection]
lucasb has quit [Quit: Connection closed for inactivity]
etupat has joined #ruby
akemhp_ has joined #ruby
buckworst has quit [Quit: WeeChat 2.3]
akemhp has quit [Ping timeout: 265 seconds]
etupat has quit [Ping timeout: 248 seconds]
ouemt has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
TCZ has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
Swyper has quit [Remote host closed the connection]
bvdw has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
turbo_choo has quit [Ping timeout: 268 seconds]