havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.5.1, 2.4.4, 2.3.7, 2.6.0-preview2: https://www.ruby-lang.org | Paste 4+ lines of text to https://gist.github.com | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby
nicht has quit [Ping timeout: 256 seconds]
jcarl43 has quit [Quit: WeeChat 2.1]
agent_white has quit [Quit: bbl]
shinnya has joined #ruby
gizmore has quit [Read error: Connection reset by peer]
GodFather has quit [Ping timeout: 276 seconds]
kmurphy4 has joined #ruby
nicht_ has quit [Ping timeout: 245 seconds]
nicht has joined #ruby
dviola has quit [Quit: WeeChat 2.1]
workmad3 has joined #ruby
wontruefree has quit [Quit: this is not the client you are looking for]
sytherax has joined #ruby
workmad3 has quit [Ping timeout: 240 seconds]
amatas has quit [Ping timeout: 240 seconds]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dviola has joined #ruby
BlopMonster has joined #ruby
za1b1tsu has joined #ruby
bbobb has quit [Ping timeout: 256 seconds]
za1b1tsu has quit [Ping timeout: 256 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Azure|dc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cyberg has quit [Remote host closed the connection]
rcs has joined #ruby
TomyLobo has quit [Read error: Connection reset by peer]
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
agent_white has joined #ruby
karapetyan has quit [Remote host closed the connection]
sytherax has quit [Remote host closed the connection]
tty has joined #ruby
sytherax has joined #ruby
elomatreb has quit [Quit: ZNC - https://znc.in]
sytherax has quit [Ping timeout: 256 seconds]
weird_error has joined #ruby
weird_error has quit [Client Quit]
c0ncealed2 has quit [Remote host closed the connection]
c0ncealed2 has joined #ruby
sytherax has joined #ruby
bga57 has joined #ruby
chouhoulis has joined #ruby
TinkerT has quit [Read error: Connection reset by peer]
TinkerT has joined #ruby
chat_ has joined #ruby
FernandoBasso has quit [Quit: Leaving]
chat has quit [Ping timeout: 240 seconds]
elomatreb has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 256 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
scorpionillumin has joined #ruby
gnufied has quit [Quit: Leaving]
<scorpionillumin> soooo did anyone answer my question about learning ruby?
<scorpionillumin> anyone here?
scorpionillumin has quit [Client Quit]
darkhanb has joined #ruby
andrewray has joined #ruby
andrewray has quit [Client Quit]
jrafanie has joined #ruby
yokel has quit [Ping timeout: 268 seconds]
karapetyan has joined #ruby
<agent_white> We regret that the entire planet is temporarily closed.
karapetyan has quit [Ping timeout: 240 seconds]
ur5us has quit [Remote host closed the connection]
za1b1tsu has joined #ruby
yokel has joined #ruby
ur5us has joined #ruby
konsolebox has quit [Ping timeout: 255 seconds]
eckhardt has quit [Quit: Textual IRC Client: www.textualapp.com]
za1b1tsu has quit [Ping timeout: 240 seconds]
konsolebox has joined #ruby
<t0xik> lol
gix has quit [Ping timeout: 265 seconds]
regedit has joined #ruby
gix has joined #ruby
workmad3 has joined #ruby
ramfjord has quit [Ping timeout: 256 seconds]
millerti has quit [Quit: Textual IRC Client: www.textualapp.com]
nicht has quit [Ping timeout: 245 seconds]
workmad3 has quit [Ping timeout: 245 seconds]
srruby has joined #ruby
<srruby> rvm: Should I install it locally? This is on my laptop development machine.
<elomatreb> If you need to version switch, rvm is one option. You don't need it just to get user-local installation
<elomatreb> A combination of https://github.com/postmodern/ruby-install and https://github.com/postmodern/chruby is preferred by a lot of people here though
dendazen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<srruby> elomatreb: Thanks
gigetoo has quit [Ping timeout: 256 seconds]
srruby has quit [Remote host closed the connection]
dhollinger has quit [Ping timeout: 245 seconds]
soniya29 has joined #ruby
chouhoulis has quit [Remote host closed the connection]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chouhoulis has joined #ruby
srruby has joined #ruby
gigetoo has joined #ruby
chouhoulis has quit [Ping timeout: 248 seconds]
sleetdrop has joined #ruby
sleetdrop has quit [Client Quit]
gigetoo has quit [Ping timeout: 240 seconds]
gigetoo has joined #ruby
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
gigetoo has quit [Ping timeout: 240 seconds]
chihhsin has quit [Ping timeout: 256 seconds]
nicht has joined #ruby
chihhsin has joined #ruby
braincrash has quit [Quit: bye bye]
dhollinger has joined #ruby
braincrash has joined #ruby
gigetoo has joined #ruby
BlopMonster has quit [Ping timeout: 265 seconds]
gix- has joined #ruby
gix has quit [Disconnected by services]
sytherax has quit [Remote host closed the connection]
bauruine has quit [Ping timeout: 245 seconds]
sytherax has joined #ruby
bauruine has joined #ruby
za1b1tsu has joined #ruby
za1b1tsu has quit [Ping timeout: 264 seconds]
gigetoo has quit [Ping timeout: 276 seconds]
akaiiro has joined #ruby
chat has joined #ruby
AJA4350 has quit [Quit: AJA4350]
chat_ has quit [Ping timeout: 276 seconds]
dviola has quit [Quit: WeeChat 2.1]
dreamthese has quit [Remote host closed the connection]
soniya29 has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
dreamthese has joined #ruby
chouhoulis has quit [Remote host closed the connection]
BlopMonster has joined #ruby
nicht has quit [Ping timeout: 245 seconds]
SeepingN has joined #ruby
chat_ has joined #ruby
chat has quit [Ping timeout: 256 seconds]
sytherax has quit [Remote host closed the connection]
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
karapetyan has joined #ruby
donofrio has quit [Remote host closed the connection]
karapetyan has quit [Ping timeout: 276 seconds]
jcarl43 has joined #ruby
BlopMonster has quit [Ping timeout: 248 seconds]
ciscam has quit [Ping timeout: 265 seconds]
ciscam has joined #ruby
TinkerT has quit [Read error: Connection reset by peer]
TinkerT has joined #ruby
workmad3 has joined #ruby
baweaver is now known as baweaver_away
jamesaxl has quit [Quit: WeeChat 2.1]
workmad3 has quit [Ping timeout: 265 seconds]
gigetoo has joined #ruby
akaiiro has quit [Ping timeout: 268 seconds]
sytherax has joined #ruby
agent_white has quit [Quit: brb]
gigetoo has quit [Ping timeout: 240 seconds]
ogres has joined #ruby
sytherax has quit [Ping timeout: 240 seconds]
Aleeious has quit [Quit: Quit]
jud has joined #ruby
agent_white has joined #ruby
sspreitz has quit [Ping timeout: 256 seconds]
sspreitz has joined #ruby
za1b1tsu has joined #ruby
chat has joined #ruby
chat_ has quit [Ping timeout: 264 seconds]
za1b1tsu has quit [Ping timeout: 264 seconds]
cadillac_ has quit [Ping timeout: 264 seconds]
cadillac_ has joined #ruby
karapetyan has joined #ruby
karapetyan has quit [Ping timeout: 248 seconds]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
theRoUS has quit [Ping timeout: 240 seconds]
theRoUS has joined #ruby
anisha has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
vondruch has quit [Ping timeout: 264 seconds]
sspreitz has quit [Ping timeout: 256 seconds]
bbobb has joined #ruby
troys has quit [Quit: Bye]
konsolebox has quit [Ping timeout: 264 seconds]
sspreitz has joined #ruby
za1b1tsu has joined #ruby
noizex has quit [Ping timeout: 248 seconds]
ciscam has quit [Ping timeout: 260 seconds]
reber has joined #ruby
ciscam has joined #ruby
gigetoo has joined #ruby
dionysus69 has joined #ruby
RougeR has joined #ruby
gigetoo has quit [Ping timeout: 256 seconds]
gigetoo has joined #ruby
byte00 has joined #ruby
byte00 has quit [Remote host closed the connection]
conta has joined #ruby
j0bk has quit [Ping timeout: 240 seconds]
conta has quit [Quit: conta]
wmoxam has quit [Ping timeout: 248 seconds]
aupadhye has joined #ruby
srruby has quit [Quit: Leaving]
akkad has quit [Remote host closed the connection]
sauvin has joined #ruby
<syndikate> Is there an opposite of Hash#slice in ruby? Like I can provide a key which I don't want and display the hash with rest of the key and values?
<elomatreb> Rails has that (#except I think?), but I don't think there is in vanilla.
<syndikate> Okay, I doubt if it works on hashes, let me check
za1b1tsu_ has joined #ruby
<dminuoso> syndikate: You can always to_a, reject/select, to_h
<dminuoso> >> h = { a: 1, b: 2, c: 3 }; h.reject { |(k, v)| k == :a }.to_h
<ruby[bot]> dminuoso: # => {:b=>2, :c=>3} (https://eval.in/1019276)
<syndikate> Okay, so there is no ready method which would accept just a key I would have to provide a block
za1b1tsu has quit [Ping timeout: 260 seconds]
<dminuoso> No and I dont think it'd be a wise thing to have.
<syndikate> Why so?
<elomatreb> >> h = { a: 1, b: 2, c: 3, d: 4 }; v.values_at *(h.keys - [:b, :c]) # hmm
<ruby[bot]> elomatreb: # => undefined local variable or method `v' for main:Object (NameError) ...check link for more (https://eval.in/1019277)
<elomatreb> >> h = { a: 1, b: 2, c: 3, d: 4 }; h.values_at *(h.keys - [:b, :c]) # hmm
<ruby[bot]> elomatreb: # => [1, 4] (https://eval.in/1019278)
<elomatreb> Oh wait nevermind
<elomatreb> lol
<dminuoso> syndikate: For the simple reason that I just showed you. The code to do what you want is highly trivial, and it's not common.
<dminuoso> To have methods to do uncommon and trivial things just makes you look for "DSL" more instead of solving problems.
<dminuoso> It's the Rails disease.
braindead_ has joined #ruby
biberu has joined #ruby
<elomatreb> Ruby already has a very expansive standard library, if it added every function that "could be useful" it'd grow huge
<syndikate> Makes sense. Guess I have that rails disease
<elomatreb> You can pull in ActiveSupport (the library extension part of Rails) independently of Rails, if you *really* want
<syndikate> In fact #except works as well like elomatreb said. But, good to know these. Thanks elomatreb dminuoso
<syndikate> I already have it but I wanted to know about ruby as well :)
<dminuoso> syndikate: You just make it harder for Rubyists to read your code.
<syndikate> dminuoso, if I use rails methods?
<dminuoso> syndikate: Rails is not standard, their implementations are *weird* with a lot of guess magic, frequently slow.
<elomatreb> This is getting into opinion territory, personally I like using this specific one since it's definitely quicker to get what it does than the reject/to_h combo
<dminuoso> If I get to see code using .except Im gonna purge that in favour of h.reject { |(k, v)| k == :a }.to_h
sytherax has joined #ruby
<dminuoso> elomatreb: Are you sure about that?
<dminuoso> elomatreb: Will except be indifferent wrt to strings and symbols?
<syndikate> ^ Nope
<dminuoso> ^- this amongst other problematic behaviors is why I avoid ActiveSupport.
<syndikate> I faced that issue
<syndikate> And was irked
<elomatreb> Arguably in that case the actual problem is that you're mixing strings and symbols, but I get what you mean
<syndikate> I kept providing keys for a while and was wondering why the method is not working
<syndikate> Keys == symbols
rippa has joined #ruby
za1b1tsu_ has quit [Quit: WeeChat 2.1]
workmad3 has joined #ruby
Scriptonaut has left #ruby [#ruby]
clemens3_ has joined #ruby
clemens3 has joined #ruby
Zladivliba has joined #ruby
<Zladivliba> hello everyone
workmad3 has quit [Ping timeout: 240 seconds]
konsolebox has joined #ruby
Zladivliba has quit []
bobdobbs has joined #ruby
andikr has joined #ruby
srruby has joined #ruby
amar has joined #ruby
dr3w_ has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
clemens3 has quit [Ping timeout: 256 seconds]
jcarl43 has quit [Quit: WeeChat 2.1]
Zaab1t has joined #ruby
karapetyan has joined #ruby
t0xik has quit [Quit: Connection closed for inactivity]
Furai has quit [Quit: WeeChat 2.1]
bbobb has quit [Quit: bbobb]
Furai has joined #ruby
bauruine has quit [Ping timeout: 265 seconds]
karapetyan has quit [Ping timeout: 265 seconds]
clemens3 has joined #ruby
drale2k_ has joined #ruby
bauruine has joined #ruby
srruby has quit [Quit: Leaving]
TomyWork has joined #ruby
drale2k_ has quit [Read error: Connection reset by peer]
yohji has joined #ruby
amar has quit [Remote host closed the connection]
kmurphy4 has quit [Quit: kmurphy4]
ellcs has joined #ruby
armando has quit [Ping timeout: 260 seconds]
armando has joined #ruby
schleppel has joined #ruby
sysvalve has joined #ruby
sytherax has quit [Remote host closed the connection]
Beams has joined #ruby
vondruch has joined #ruby
armando has quit [Ping timeout: 240 seconds]
armando has joined #ruby
megamos has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
sytherax has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
sytherax has quit [Ping timeout: 255 seconds]
t0xik has joined #ruby
sphenxes has joined #ruby
sytherax has joined #ruby
nadir has joined #ruby
rfv_ has quit []
rfv has joined #ruby
mikecmpbll has joined #ruby
ellcs has joined #ruby
jottr has joined #ruby
Burgestrand has joined #ruby
amar has joined #ruby
amar has quit [Read error: No route to host]
amar has joined #ruby
ellcs has quit [Ping timeout: 248 seconds]
workmad3 has joined #ruby
amar has quit [Ping timeout: 276 seconds]
amar has joined #ruby
dr3w_ has joined #ruby
dr3w_ has quit [Client Quit]
tomeaton17 has quit [Quit: ZNC 1.7.0 - https://znc.in]
tomeaton17 has joined #ruby
workmad3 has quit [Ping timeout: 276 seconds]
amar has quit [Ping timeout: 256 seconds]
amar has joined #ruby
sytherax has quit [Remote host closed the connection]
sytherax has joined #ruby
megamos has quit [Remote host closed the connection]
spooky_d has joined #ruby
spooky_d has left #ruby [#ruby]
ramfjord has joined #ruby
meinside has joined #ruby
ramfjord has quit [Ping timeout: 248 seconds]
amar has quit [Ping timeout: 256 seconds]
vaios has joined #ruby
vaios has left #ruby [#ruby]
workmad3 has joined #ruby
regedit has quit [Quit: Connection closed for inactivity]
vondruch has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
kapil___ has joined #ruby
jottr has quit [Ping timeout: 265 seconds]
ramfjord has joined #ruby
sytherax has quit [Remote host closed the connection]
mikecmpbll has quit [Quit: inabit. zz.]
ramfjord has quit [Ping timeout: 260 seconds]
mikecmpbll has joined #ruby
<Bish> >> h = {};h[:t] = *[1]
<ruby[bot]> Bish: # => [1] (https://eval.in/1019343)
<Bish> why wouldn't it be 1?
<Bish> i mean.. i h[k] = *x not equivalent with h.[]=(*args)
karapetyan has joined #ruby
za1b1tsu has joined #ruby
Guest64970 has quit [Ping timeout: 255 seconds]
<Bish> >> h = {};h[:f] = *[1];h[:s].[]=(:s,*[1]);h
<ruby[bot]> Bish: # => undefined method `[]=' for nil:NilClass (NoMethodError) ...check link for more (https://eval.in/1019344)
<Bish> >> h = {};h[:f] = *[1];h[]=(:s,*[1]);h
<ruby[bot]> Bish: # => /tmp/execpad-1548a7909d18/source-1548a7909d18:2: syntax error, unexpected ',', expecting ')' ...check link for more (https://eval.in/1019345)
<Bish> fml
<dminuoso> asm>> h = {};h[:t] = *[1]
<ruby[bot]> dminuoso: I have disassembled your code, the result is at https://eval.in/1019346
<Bish> >> h = {};h[:f] = *[1];h.[]=(:s,*[1]);h
<ruby[bot]> Bish: # => {:f=>[1], :s=>1} (https://eval.in/1019347)
balo has quit [Ping timeout: 245 seconds]
<Bish> asm>> h = {};h[:f] = *[1];h.[]=(:s,*[1]);h
balo has joined #ruby
<dminuoso> Bish: for the same reason that:
<dminuoso> a = *[1] # gives you [1] in a
tekk has joined #ruby
karapetyan has quit [Ping timeout: 245 seconds]
<Bish> but the splat doesnt do squid
<dminuoso> The main problem is that you are using this `*` thing without really knowing what it does.
ur5us has joined #ruby
<dminuoso> And the reason you don't know, is because we don't have a real specification that tells you the semantics of it.
<Bish> well in that case, it doesnt do anything
<dminuoso> The ISO standard that does exist is behind a paywall.
gil_ has quit [Ping timeout: 255 seconds]
<dminuoso> The real question should be: Why do we have these completely magical things in Ruby that are not documented anywher.
<Bish> well in any case i expected []=(k,v) to be equivalent with [k]=v
jottr has joined #ruby
<dminuoso> Bish: No
<Bish> no matter what i understand wrong about ruby
<apeiros_> Bish: because of auto-unsplat
<dminuoso> 11:11 dminuoso | The real question should be: Why do we have these completely magical things in Ruby that are not documented anywher.
<apeiros_> a,* = *[1]; a
<apeiros_> >> a,* = *[1]; a
<ruby[bot]> apeiros_: # => 1 (https://eval.in/1019348)
apeiros_ is now known as apeiros
<apeiros> >> a = 1,2,3; a
<dminuoso> Bish: Ruby is learned by means of anecdotes and stories.
<ruby[bot]> apeiros: # => [1, 2, 3] (https://eval.in/1019349)
NL3limin4t0r has joined #ruby
<apeiros> IMO one of the unfavorable choices.
<apeiros> I'd prefer explicit splat/unsplat rules
<Bish> so.. can i splat a single element array into an assignment?
<Bish> how would explizit look
pragmatism has quit [Ping timeout: 245 seconds]
<dminuoso> Unlike basically *every other language on this planet* Ruby has a lot of magic undocumented features.
<apeiros> Bish: as I showed, by not having a single left-hand side
<dminuoso> You learn them by randomly asking on reddit, SO or IRC.
<dminuoso> Or digging into the source code
<Bish> thats what makes ig good
<Bish> mysterious
<Bish> im kidding.
<apeiros> one way of "not having a single lhs" is by using `,*`
ectos has quit [Ping timeout: 255 seconds]
<apeiros> >> a,* = *[1]; a # <-- this
<ruby[bot]> apeiros: # => 1 (https://eval.in/1019350)
<dminuoso> And yes. Id *love* to be able to point people to an official reference documentation that explained the meaning and behavior of things
<Bish> apeiros: well, and how does it wok?
<Bish> what do i actually say that, and how is that equivalent with
<Bish> h.[]=(k,v)
ellcs has joined #ruby
pragmatism has joined #ruby
<apeiros> Bish: essentially if ruby detects a single lhs and a splat on rhs, it will "unsplat", i.e. turn rhs into an array
<apeiros> by forcing a splat on lhs, that's avoided
<Bish> lhs?
<Bish> ah i get it
<apeiros> lhs/rhs = left hand / right hand side
megamos has joined #ruby
<apeiros> i.e. left and right of the assignment operator
<Bish> and why does it do that?
<apeiros> *that* is an entirely different question. ask matz :)
<apeiros> I *assume* it was thought to be convenient.
<apeiros> as said, it goes counter to my intuition and preference.
<Bish> what datatypes are splated by default?
<Bish> i mean.. you will have to do that explicitly..
<Bish> and then it unsplats, eh?
<Bish> i don't follow
ectos has joined #ruby
<apeiros> sadly it does autosplat. see:
<apeiros> >> a,b,c = [1,2,3]; c
<ruby[bot]> apeiros: # => 3 (https://eval.in/1019353)
gil_ has joined #ruby
gil_ has joined #ruby
gil_ has quit [Changing host]
<apeiros> and I *think* it does that with everything that responds to to_ary
<apeiros> >> class Foo; def to_ary; [1,2,3]; end; end; a,b,c = Foo.new; c
<ruby[bot]> apeiros: # => 3 (https://eval.in/1019354)
<apeiros> ^ would indicate my recollection is correct
bobdobbs has quit [Ping timeout: 264 seconds]
<Bish> so
<Bish> >> a,b,c = d = [1,2,3,4];[d,a,b,c]
<ruby[bot]> Bish: # => [[1, 2, 3, 4], 1, 2, 3] (https://eval.in/1019355)
<apeiros> >> class Foo; end; a,b,c = Foo.new; c # counter-test
<ruby[bot]> apeiros: # => nil (https://eval.in/1019356)
<Bish> ohshit, lol
<dminuoso> Bish: It's defined right there under 11.4.2.4 Multiple assignments
<dminuoso> 11.5.2.2.4 The case expression
<dminuoso> and: 11.3.2 Method arguments
<dminuoso> Beautiful.
hfp_work has quit [Ping timeout: 256 seconds]
Es0teric has joined #ruby
za1b1tsu has quit [Quit: WeeChat 2.1]
hfp_work has joined #ruby
jottr has quit [Ping timeout: 276 seconds]
sytherax has joined #ruby
<Bish> well but thats more ugly then just calling .first on the array
jottr has joined #ruby
sytherax has quit [Ping timeout: 240 seconds]
<dionysus69> this is so weird!
<dionysus69> 0.48 - 0.2
<dionysus69> => 0.27999999999999997
<dminuoso> What is weird about that?
<Bish> welcome to IEEE754
<dionysus69> to get correct answer I should do to_d.to_f???
Haradani has joined #ruby
<dionysus69> that way I get 0.28
<Bish> i have a better one for yah
<Bish> >> 0.1+0.2
<ruby[bot]> Bish: # => 0.30000000000000004 (https://eval.in/1019465)
<dionysus69> haha
<dminuoso> dionysus69: Use Rational.
<dminuoso> Dont use floating point numbers if you dont understand the implications.
<dionysus69> hmm ok let me look it up
<Bish> or if you care about the implications
<dionysus69> what do you mean use rational? dminuoso
<apeiros> Rational or BigDecimal are the choices.
<dionysus69> oh
<Bish> dionysus69: if you find a better way to express floating point numbers with a finite and fixed number of bits, tell me
<apeiros> >> 1/2r.class
<ruby[bot]> apeiros: # => Class can't be coerced into Fixnum (TypeError) ...check link for more (https://eval.in/1019466)
<apeiros> >> (1/2r).class
<ruby[bot]> apeiros: # => Rational (https://eval.in/1019467)
<dionysus69> need to get float as a result so to_d.to_f sounds simplest so far
conta has joined #ruby
<dminuoso> dionysus69: That sounds absolutely terribly wrong.
<apeiros> "need to get float as a result" - why?
<dionysus69> then what is your solution for let's say 0.48 - 0.2
<dminuoso> I cant fathom what you are trying to do, but Im convinced you are doing this wrong.
<dionysus69> I need to pass it to a service, it accepts only floats
<dminuoso> So whats wrong with 0.27999999999999997
<dionysus69> needs to be precise :D
<apeiros> >> require 'bigdecimal'; BigDecimal("0.48") - BigDecimal("0.2") # dionysus69
<dionysus69> that is just wrong lol
<ruby[bot]> apeiros: # => #<BigDecimal:40b8172c,'0.28E0',9(18)> (https://eval.in/1019469)
<dionysus69> that returns e0 notation
<apeiros> dionysus69: you are passing a binary float representation to the service?
<dionysus69> then I would have to_f it anyway :D
<apeiros> I very seriously doubt that
<dionysus69> imagine cents in cents
<apeiros> you almost certainly pass a *string* representation of a decimal to the service, and NOT a float.
<dminuoso> 11:44 dionysus69 | needs to be precise :D
<dminuoso> You do not seem to understand what you are saying
<dionysus69> you cant pass 0.2888888 cents for 29 cents right?
<dminuoso> Do. Not. Use. FP. For. Money.
<apeiros> ^ that.
<apeiros> there's like tons of material about that on the net.
<dionysus69> I mean, I am doing all of the things in bigdecimal
<Bish> what about bitcoins
<Bish> they use floats for money
<dminuoso> dionysus69: Do. Not. Use. FP. For. Money.
<Bish> *ducks*
<dionysus69> but at the end, I need to transform it into floaT :D :D
<dionysus69> Bish: exactly
<dminuoso> dionysus69: do your calculations in Rational.
<apeiros> dionysus69: again - you are almost certainly NOT passing a binary float to the service
<Bish> dionysus69: then people will lose money :D :D
<apeiros> dionysus69: so NO, you do NOT need a float.
<apeiros> "1.23" is NOT a float. it's a string.
<dionysus69> yea, I meant string float
<dionysus69> not a binary float
<apeiros> yeah, stop using that term
<dminuoso> dionysus69: if you want to calculate with money, use rational, integers or a money library.
<Bish> dionysus69: no.. bitcoins are represented by bits already, there is no way to have a "wrong" result with them
<apeiros> that's not a float. period.
<dionysus69> ok :D so how do I get string float from a BigDecimal("0.48") - BigDecimal("0.2")
<Bish> are you talking about cryptocurrency?
fmcgeough has quit [Quit: fmcgeough]
<apeiros> dionysus69: you don't. you get decimal string from it using to_s("F")
<dionysus69> year
<dionysus69> yea*
<dminuoso> dionysus69: you subtract *centwise*
<apeiros> >> require 'bigdecimal'; (BigDecimal("0.48") - BigDecimal("0.2")).to_s("F")
<dminuoso> dionysus69: turn the whole thing into *cents*, then use Integer.
<ruby[bot]> apeiros: # => "0.28" (https://eval.in/1019473)
<apeiros> ^ dionysus69
<dionysus69> ok great string conversion gave me the correct answer
<dminuoso> Sigh..
<dionysus69> :D
<dminuoso> dionysus69: You need to use *INTEGER*
spooky_d has joined #ruby
<apeiros> dminuoso: they'll just divide by 100 getting a float again and convert that to a string. so you're just pushing the issue around ;-p
<spooky_d> Hi guys
<dionysus69> for what dminuoso?
Haradani has quit [Remote host closed the connection]
<dminuoso> apeiros: not really.
<spooky_d> How can I build a proper binding for an eval that will call require_relative?
<dminuoso> apeiros: it becomes a string > int parsing issue.
<apeiros> dminuoso: if the service wants a string with a dot in it, it's an int -> decimal string conversion issue
<apeiros> and I'm pretty sure dionysus69's solution to that would be what I said ;-)
<dminuoso> apeiros: yes but then you can just divmod it.
<dminuoso> >> 413.divmod(100)
<ruby[bot]> dminuoso: # => [4, 13] (https://eval.in/1019480)
<dminuoso> voila. euros and cents.
<apeiros> dminuoso: sure, you and I would :D
<Bish> is there a counter part to empty?
<apeiros> spooky_d: provide the eval a filename
<apeiros> spooky_d: also you commit 2 sinds - you're using eval and require_relative. you should go into the corner and think about that for a while :-p
<apeiros> *sins
<dminuoso> dionysus69: please tell me the name of the website you are working for
<dminuoso> So I can put it on my avoidance list.
<dionysus69> :D wtf
shinnya has quit [Ping timeout: 265 seconds]
<dionysus69> I am doing this in development mode lol, I am not pushing this stuff to production ^.^
<cdunklau> dionysus69: that's what they all say
<spooky_d> apeiros: tell me how not to sin. I have a ruby script with require_relative, and I want to invoke it from C.
<Bish> BadFloatingCoin ICO
<cdunklau> i'm pretty sure bitcoin uses ints
<Bish> cdunklau: .. well bitcoin itself as a finitie precision..
<Bish> lowest being satoshi..
<Bish> so it's kinda equivalent
<spooky_d> And I want to invoke it in such a way that it won't pollute stuff with global constants.
<apeiros> spooky_d: let your executable set up $LOAD_PATH and use require instead of require_relative
<apeiros> spooky_d: as for invoke ruby from C - well, I guess that will indeed be some form of eval, so you're absolved of that sin ;-)
<spooky_d> I don't really choose if require_relative is used or not, and I know for certain it is used.
<cdunklau> Bish: right, so the right way of doing bitcoins is to do it all in ints
<apeiros> (just like `ruby some_script.rb` is essentially a glorified eval)
<Bish> well.. or just floats with the amount of bits in btc..
<cdunklau> and then just divide by 1e8
<Bish> because it's not possible to add/substract 2 valid values from each other
<Bish> and get problems
<Bish> but yeah.. whoever does not do money with integers, is crazy
<dminuoso> Bish: Ideally you would not do it with integers either.
<Bish> sure.. but it doesn't matter, actually since being equivalent at some level
<Bish> but since its easier to model.. yeah int
<spooky_d> Thank you :)
<dminuoso> dionysus69: floating point numbers are represented as `significant * (base ^ exponent)`
<dminuoso> dionysus69: with `base` usually being 2 (IEEE 754 also allows for base being 10, but for efficiency reasons that's usually not implemented)
Es0teric has quit [Quit: Computer has gone to sleep.]
<apeiros> it'd be really nice if we had hardware base10 floats :-/
<dminuoso> IEEE754 then defines multiple precision levels. With single precision the exponent has exactly 8 bits and the significand has exactly 23 bits.
<dminuoso> dionysus69: ^- with this it should be obvious that IEEE754 is only able to represent certain discrete numbers.
\void has quit [Quit: So long, and thanks for all the fish.]
<Bish> apeiros: how does the precision matter? i mean even if you had magicially base10 digits
<Bish> if you don't have endless of them
<Bish> it doesn't matter
<cdunklau> we should just use trinary floats so 1/3 would be exactly representable!
<Bish> how does the base matter*
<dionysus69> Those things are little vague to me but I get the essence :)
<dminuoso> dionysus69: THe specification then talks how arithmatic works. If you look close you will note that FP arithmetic breaks pretty much most mathematic laws you'd expect.
<dminuoso> For example in IEEE754 it is not guaranteed that `a == a # => true`
<dionysus69> btw rubocop gave me warning, BigDecimal.new is deprecated, seems like BigDecimal("0.1") does the job
<dminuoso> dionysus69: Seriously. Just use integers, its not hard.
<Bish> god, i hate .infinite? and .nan?
<Bish> so much
<dionysus69> hmm
<dionysus69> I actually do have an integer, but then I divide it by a million to get needed precision with decimal places
<dminuoso> What?
<dminuoso> apeiros ^- tell me you read this
<dionysus69> service returns integer as balance, but I need decimals in my app
<dminuoso> dionysus69: what do you mean "I need decimals in my app"
<dminuoso> dionysus69: "1,50" is a *representation* form, not a storage form.
<cdunklau> dionysus69: if you need to display them with decimal points, just do the division right before you format it for display
<tbuehlmann> Money.new(cents).to_s ding ding ding
<dionysus69> so I have to convert it to decimals and then return back to integers
<dminuoso> dionysus69: dont convert to decimals *at all*
<dionysus69> I need to show decimals to users, like you wouldn't want to show cents to the users
<dminuoso> dionysus69: You have Integer and some string representation.
<dionysus69> hmm ok I get what you are saying, I actually tried that
<dionysus69> but that meant modifying methods for this particular currency
<dionysus69> others dont use integers
<dminuoso> >> def pretty_money(cents); e, c = cents.divmod(100); sprintf("%d,%02d€", e, c); end; pretty_money(10)
<ruby[bot]> dminuoso: # => "0,10€" (https://eval.in/1019486)
<dminuoso> >> def pretty_money(cents); e, c = cents.divmod(100); sprintf("%d,%02d€", e, c); end; pretty_money(173)
<ruby[bot]> dminuoso: # => "1,73€" (https://eval.in/1019487)
<dionysus69> others like bitcoin use 8 precision decimals, string decimals at least
venmx has joined #ruby
conta has quit [Quit: conta]
<dminuoso> dionysus69: a "decimal" is just a fancy word for rational./
<dminuoso> When we write: 0.01 we actually mean 1/100
<dminuoso> The main problem is that programming languages have made a habit of considering 0.01 as floating point, which is something we dont ever think in.
karapetyan has joined #ruby
<Bish> be rational!
<dminuoso> dionysus69: Just use Integer. you can use the method I just showed you to pretty it. Or follow tbuehlmann's advice and use Money.
<dionysus69> yes rationals make sense, but user inputs a floating point string for transferable amount
<dminuoso> No they dont.
<dminuoso> They input *A STRING*
<dminuoso> A *TEXT*
<dionysus69> ok ok I get it :D
<Bish> so it's a float?
<dionysus69> hahaha :D
<dionysus69> thanks dminuoso :D you are nice :P
<dminuoso> So yes. You will probably want an inverse of pretty_print, one that *PARSES* some user input into cents or fails.
<dminuoso> A naive implementation might be
<dionysus69> yea I'll figure something out :)
<Bish> >> user_input = "1.1"; eval "#{user_input}r"
alex`` has joined #ruby
<ruby[bot]> Bish: # => (11/10) (https://eval.in/1019489)
<Bish> :D no im kidding dont do that
<spooky_d> class C1; X=100; def p; eval("puts X; require_relative 'test'", binding, '/home/spooky/x.cfg'); end; end;
<spooky_d> C1.new.p
<spooky_d> if test.rb contains a puts X
<spooky_d> it complains about X being not defined.
<spooky_d> Does this make sense?
<spooky_d> Anyway, here's what I need, really, because I'm probably asking the wrong question
venmx has quit [Quit: leaving]
<spooky_d> I want to run a ruby script (preferably with load)
venmx has joined #ruby
<spooky_d> and clean the global_constants of all the constants it defines.
<dminuoso> dionysus69: Or you could rely on the Money gem. It should have what you want built in already - and its not bad.
<spooky_d> Because then I get the output corrupted with warnings.
<dminuoso> dionysus69: But it's not a hard problem. You should use it as practice perhaps
<spooky_d> And I don't want to disable those warnings, but I need the output clean.
<dionysus69> dminuoso: nah, I prefer doing it manually, I ll change methods to deal with integers I guess, it's safest
<dionysus69> other currencies so far all of them had 8 precision floating strings so all was good
<dminuoso> dionysus69: what is a "8 precision floating string"
<dminuoso> what does that even mean?
tty has quit [Quit: tty]
<Bish> they have 8 base10 digits
Burgestrand has quit [Quit: Closing time!]
<dionysus69> 0.00000001 that is one satoshi in bitcoin world for example
<dionysus69> 1btc ^ -8
<dionysus69> haha I know i came up with that name on the fly :D
<dminuoso> stop using the word floating here.
<dionysus69> ok :D
<Bish> and 1^-8 is 1
<dionysus69> 1*10 ... ok ok
<dionysus69> lol
<dminuoso> the reason why floating point is called floating point, is because the *point* can float from left to right during arithmetic.
<dminuoso> or in both directions rather
<dionysus69> yea I know, I've heard of the floating point processor, inside the cpu :)
<dminuoso> dionysus69: "102301.231" is just a decimal representation of a *fraction*
<dminuoso> that is, it's a way to express the division: 102301231 / 1000
<dionysus69> yea makes sense :)
<dminuoso> dionysus69: now bitcoin can be thought of as consisting of just μBTC.
<dminuoso> or.. no I think msat is the smallest?
<dionysus69> yea but the btc node itself receives and returns values based on btc not μBTC
<dminuoso> dionysus69: That's just a representation form.
<dionysus69> oh that is 0.000001 not satoshi though
<dminuoso> dionysus69: In reality you still transmit millisatoshis.
Haradani has joined #ruby
<dionysus69> well, yea I guess
<dminuoso> it's similar how the information 2,45EUR can be thought of conveying 245 cents.
<dionysus69> but I had to adapt to the API, not to how the node works in the source
<dminuoso> dionysus69: correction its satoshis :)
<dminuoso> (at least on the blockchain)
<dminuoso> so you could think that "satoshis" are like cents and BTC are like dollars.
<dminuoso> except the factor is not 100 but 100 million.
<dionysus69> yea I see it like that :D
<dionysus69> yep
<dminuoso> "1.0000000001" is really just 1 bitcoin and 10 satoshis (dunno if I got the digits right, but you get the idea)
<dminuoso> So it's not "floating point". It's a rather precise denomination
tvw has joined #ruby
<dminuoso> "1.00000001BTC" is just a string representation for some amount of currency.
<dminuoso> With swapped endianness and a different comma sign some other folks might write it as: "CTB10000000_1"
<dminuoso> But it's still the same information inside.
<Radar> Other currencies do this same kind of precision but I don't remember which ones.
* dminuoso pokes Radar with a radar
* Radar slaps dminuoso around with a rusty lifetime
<Radar> *around a bt
<Radar> well, you know what I mean
<dminuoso> You borrowed that from some language, right?
<Radar> badum tish
<Radar> I remember distinctly having to deal with currencies that weren't two-digit-precise-after-the-decimal-point when working in ecommerce land.
Haradani has quit [Ping timeout: 264 seconds]
sytherax has joined #ruby
<dminuoso> Radar: what does "two-digit-precise-after-the-decimal-point" mean?
<Radar> dminuoso: $10.45
<Radar> Not: $10.456
<dminuoso> The biggest problem I see with money is just the conflation of "representation" and "value"
ur5us has quit [Remote host closed the connection]
<dminuoso> Radar: Ah yeah. Not a big issue if you just use rational.
ur5us has joined #ruby
<dminuoso> (or fractionals as they are sometimes called)
<Radar> i think it was the displaying of the money always rounded up to two decimal points
<Radar> It's a silly mistake. Like all software.
<dminuoso> Radar: we had such an exact bug in our tax software. It caused a real big shitstorm, eventually costing us in the 5 digits in man hours to fix it in all the necessary places.
<dionysus69> Usually bitcoin forks stick with 8 precision
<dminuoso> Reason? Our tax report was off by 2 cents.
<dionysus69> it's quite complicated I imagine to change that
<Radar> 5 digits in manhours? fuck
<dminuoso> *5 digits in EURs
<dminuoso> Sorry!
weird_error has joined #ruby
<Radar> oh!
<dminuoso> Heh.
<dminuoso> Still hilarious.
weird_error has quit [Client Quit]
sphenxes has quit [Quit: Leaving]
<Radar> hey at least your tax system is mostly sensible
<dminuoso> I dont know about that..
<dionysus69> ye that sounds expensive
<dionysus69> tell me the site you work for, I ll add it to my hosts file xD
<Radar> dionysus69: oh that's nice of you. So that the DNS server doesn't have to resolve the address every time you visit?
<Radar> dminuoso: at least it's not the US tax system where different zip codes have different tax _rates_ and _rules_
<dminuoso> Radar: The annoying thing was "it wasnt really an issue" or a "horrible bug" - just some tedious work. All because the tax report was off by 2 cents. But it's better to spend tons of money than to explain to the IRS why your report is off"
<Radar> dminuoso: in NYC, an uncut bagel is tax free. A cut bagel is taxed.
<dminuoso> Radar: Oh we have plenty of such things here too.
sytherax has quit [Ping timeout: 268 seconds]
<dionysus69> I meant like, it would redirect me to google.com or something, but it's responsive jk ^.^
<Radar> dminuoso: iirc your tax system is tiered
<dminuoso> Radar: that's the correct flow chart to figure out the taxation of a christmas tree.
<Radar> hahahahaha
ur5us has quit [Ping timeout: 264 seconds]
<Radar> Yes that sounds about right
<dminuoso> Radar: I dont think its fair to compare the US with Germany in that respect though.
<dminuoso> Structurally the US is closer to the EU
<Radar> dminuoso: well I can't think of many other respects where US would come out on top ;)
<dminuoso> Our countries just happen to have more sovereignity
agent_white has quit [Quit: night]
<dminuoso> Radar: But different *zipcodes*.. is that different zip codes in the same state?
<Radar> dminuoso: correct
<Radar> dminuoso: And I can't find the map for it right now, but I know there's a map out there that lets you click around and it tells you the tax rate for that exact location. There's a city in Colorado that's split into two separate zip codes and the two different sides have two different tax rates.
<Radar> So you could _cross the street_ and be taxed _less_
<Radar> or more
<dminuoso> Haha thats hilarious
<cdunklau> dminuoso: germany has federal, state, district, and city/town/village laws right?
<dminuoso> cdunklau: We don't really have the notion of districts in the same sense that the US do.
<cdunklau> the US does too. taxes can be applied at each level
<cdunklau> dminuoso: sure you do. Kreis ~= County
<cdunklau> dminuoso: district is a generic word, county is the normal US-specific one
<cdunklau> except in Louisiana, they have parishes instead
<cdunklau> i just don't know what the rules are for taxation at the various levels in germany. In the US, each administrative level can levy their own taxes
<cdunklau> i'm just a filthy Ausländer, i pay whatever they tell me :P
<cdunklau> (in germany)
aufi has joined #ruby
drale2k_ has joined #ruby
<apeiros> 12:30 Radar: I remember distinctly having to deal with currencies that weren't two-digit-precise-after-the-decimal-point when working in ecommerce land.
papajo has joined #ruby
<Radar> apeiros: yes that is something I said
<apeiros> Radar: bancs never use 2 digits of precision for currency, even if that's how the denomination works
<apeiros> i.e. even for dollar and euro, they use 3 digits
<Radar> I'd imagine it would be hard to accurately calculate rounding without the 3rd digit
<apeiros> and as for currencies with 3 digits, lira was one, but since that's now euro-zone :)
<cdunklau> dminuoso: ah looks like it's similar, according to wikipedia at elast: "The municipalities and the districts (Kreise) can decide on some minor local taxes like the taxation of dogs (Hundesteuer)."
<cdunklau> s/elast/least
papajo has left #ruby [#ruby]
<apeiros> Radar: well, it's still not accurate with 3 digits. but the loss/diff is at least less.
<Radar> apeiros: they need to have 11 digits. That'll fix it
<apeiros> :D
<apeiros> it won't. but… you knew that already.
<apeiros> I'm all for symbolic notation for money.
<apeiros> "this costs 3π$"
<Radar> I dunno that seems kinda irrational
<Radar> I mean it'd send people squar
<Radar> square
<apeiros> :D
<apeiros> ICOs can use complex numbers since their product is imaginary anyway.
<cdunklau> zing
karuna has joined #ruby
<cdunklau> (what's an ICO)
<apeiros> initial coin offering
<cdunklau> ah
<Radar> oh sweet precious innocent soul
<apeiros> 😂
vondruch_ has joined #ruby
vondruch has quit [Ping timeout: 268 seconds]
vondruch_ is now known as vondruch
fmcgeough has joined #ruby
Burgestrand has joined #ruby
VladGh_ has quit [Remote host closed the connection]
<dionysus69> dminuoso: just dropping this here
<dionysus69> this is the solution I came up with in case of user input
<dionysus69> ("0.3".to_d * 1000000).to_i
<dionysus69> so that is 300000 ada lovelaces
<dionysus69> service requires word64 haskell datatype, doesn't accept anything else
VladGh has joined #ruby
<dionysus69> which is a horrible name btw because at first I thought it was a string data type
pavelz has quit [Quit: leaving]
fmcgeough has quit [Quit: fmcgeough]
gregf_ has quit [Ping timeout: 260 seconds]
jamesaxl has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
<NL3limin4t0r> dionysus69: the reason it's called word, is not because it contains a string, but has to do with it's size
shinnya has joined #ruby
ldnunes has joined #ruby
ramfjord has joined #ruby
mguex has joined #ruby
<dminuoso> dionysus69: Stop with these terrible hacks.
<dminuoso> dionysus69: You could use a simple regular expression that will probably work well enough.
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
ramfjord has quit [Ping timeout: 248 seconds]
AJA4350 has joined #ruby
c0mrad3 has joined #ruby
dendazen has joined #ruby
<dminuoso> dionysus69: https://eval.in/1019642
Beams has quit [Remote host closed the connection]
<apeiros> dminuoso: no anchors, sad.
<dminuoso> apeiros: Im too spoiled with parser combinators in Haskell that I forgot how to regex.
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
millerti has joined #ruby
<dminuoso> But yeah you are right :<
Beams has joined #ruby
apparition47 has joined #ruby
za1b1tsu has joined #ruby
<za1b1tsu> Hello, anybody using RubyMine, is there a built in way to open a gem's folder as a project?
<dminuoso> apeiros: https://eval.in/1019688 better? =)
<apeiros> dminuoso: (without looking) you had a problem, you used a regex to solve it. you now have 2 problems 😂
<Zarthus> za1b1tsu: if it's in a vendor/ folder, it's already opened in your project.
noron99 has joined #ruby
<dminuoso> apeiros: Someone should really write a good parser combinator implementation in Ruby.
<dminuoso> A monadic parser combinator with backtracking.
<apeiros> dminuoso: maybe somebody did?
<dminuoso> Nobody did :(
<apeiros> but nobody writes amazing code!
<apeiros> personally I prefer `raise blah unless md`
<apeiros> but that's just me
<dminuoso> apeiros: I've stopped post-if/unless because it hampers the reading flow.
<apeiros> also :larger and :lesser? I expected more from you 😄
<dminuoso> apeiros: such as?
<dminuoso> big/small?
<apeiros> dminuoso: interesting. I use them exactly because I like the reading flow. but really only if the condition is a single word.
<dminuoso> apeiros: a lot of ruby promotes "ruby code should read like english text"
<dminuoso> apeiros: the problem is that execution doesn't follow that direction
<tbuehlmann> that makes sense if you ask me
<tbuehlmann> see if at the end!
<za1b1tsu> Zarthus: my vendor folder has assets with javascript with stylesheets..
<dminuoso> Its a YMMV case I suppose.
<dminuoso> I even avoid `unless` in many cases in favour for `if !...~
synthroid has joined #ruby
<apeiros> dminuoso: fun, I'm actually not sure. I thought of significand and mantissa, but that's actually wrong for this.
<apeiros> dminuoso: I understand what you mean. there's a point in knowing before reading an instruction that it's only conditionally executed.
<dminuoso> apeiros: For what its worth, I did spend some thought on the naming of those capture groups. Ended up with lesser/greater because I didn't have any better words. :)
<apeiros> and tbh, with raise, I often use a 3 line statement because the exception message is too long for it to fit into my "suffix if/unless is fine"
<apeiros> +rule
<apeiros> dminuoso: maybe integer & fraction? dunno. I was just pulling your leg anyway :)
<dminuoso> apeiros: I only responded because I was hoping that maybe you had a better idea =)
<apeiros> heh
<apeiros> and I faaaaailed, oh nooooes :(
<dminuoso> integer/fraction might actually work
<dminuoso> but lets not bikeshed this
<apeiros> given that I've written code like that for certainly two dozen times, you'd think I'd remember which words I used.
<dminuoso> apeiros: By the way: perl-style $ groups or MatchData?
<apeiros> matchdata
sytherax has joined #ruby
<dminuoso> +1
<apeiros> $ should die
<apeiros> and more nuanced: $ should be available via command line option --golf
<apeiros> and that command line option should also load some standard libs
<apeiros> idea being: allow to be ultra-short for one-off scripts
<dminuoso> apeiros: I found that even in those cases they blow.
<apeiros> so e.g. you can write: `ruby -Gpe 'gsub(blah) { $1.upcase }'`
<dminuoso> apeiros: One truth that programmers dont like to admit, writing a few characters is basically not the issue. Even when you write 200 lines of code, chances are it might take you a day to write it.
<apeiros> dminuoso: yeah, same. IMO the only place is really just with -e
fmcgeough has joined #ruby
<apeiros> (-e could imply --golf :D)
<dminuoso> Or sometimes even a week while you ponder about your code base and its implications.
Beams_ has joined #ruby
<dminuoso> My entire focus on code style boils down to readability, especially when I have to see the code 5 years later from now, having forgotten its meaning entirely.
alex`` has quit [Ping timeout: 256 seconds]
Guest62369 has quit [Quit: ZNC 1.7.0 - https://znc.in]
<cdunklau> dminuoso: how about a PEG https://github.com/evanphx/kpeg
sytherax has quit [Ping timeout: 255 seconds]
<cdunklau> (i have no idea how good that lib is)
Beams has quit [Ping timeout: 260 seconds]
<apeiros> dminuoso: mine has split in 2 variants: code for myself, and code for the team
<apeiros> the latter is a lot less "clever"
<dminuoso> cdunklau: monadic parser combinators feel more natural to me
<cdunklau> there's that damn word again :D
<apeiros> and the former, I go for more readability than a couple years ago too. same reason as you.
<dminuoso> cdunklau: it's a ridiculously simple concept to use.
<apeiros> but I'll use things I know I understand, but which would require explanations in a team.
coffeecupp__ is now known as comrade_RMS
<dionysus69> ok thanks for that method dminuoso :)
gnufied has joined #ruby
elsurudo has joined #ruby
aufi has quit [Ping timeout: 260 seconds]
<cdunklau> dminuoso: jesus i do *not* know ruby well enough to even begin understanding that :d
<cdunklau> :D
<cdunklau> or is that even ruby
<dminuoso> Yes it is.
<dminuoso> "first get some digits"
<cdunklau> neat
<dminuoso> when parsed, they will be available in the variable "eur" later
<dminuoso> then parse a comma, disregard that result
<dminuoso> thgen parse some digits, they will be avialable in the variable "cents" later
<dminuoso> then parse an optional EUR sign, and the result of the entire parser is some Eur object.
<cdunklau> dminuoso: is this something that works, or something that you wish worked? :)
<dminuoso> cdunklau: I have some working implementations for that.
<cdunklau> neat
<cdunklau> dminuoso: so the >-> and >> bits... are those just methods or what
<dminuoso> cdunklau: >> is just a method, and the >-> is just a visual trick Im playing on you.
<dminuoso> the last is just the > method
<dminuoso> followed by a stabby lambda -> ... {}
<cdunklau> "stabby lambda"?!?
<cdunklau> wie geil
<dionysus69> this should return 200_000
<dionysus69> :S
sytherax has joined #ruby
drale2k_ has joined #ruby
<dminuoso> cdunklau: https://gist.github.com/dminuoso/6e411676f681471ab12bb7d1f2bfdb58 this is an annotated version
za1b1tsu has quit [Ping timeout: 264 seconds]
<dminuoso> cdunklau: so the "combinator" part refers to the fact that you begin to supply certain primitives like `maybe` or `many` and `some` that take an existing parser and somehow "enhance" it
<dminuoso> char(',') is a parser that parses exactly one comma
<dminuoso> maybe takes a parser that may fail, and backtracks if necessary
<cdunklau> wouldn't it be better to indent that
<dminuoso> If you prefer sure.
elsurudo has quit [Quit: elsurudo]
<cdunklau> dminuoso: would this be a reasonable indentation? https://gist.github.com/cdunklau/588151dd6de2a040941d87e9eddb8c04
<dminuoso> cdunklau: No.
<cdunklau> damn it
<dminuoso> cdunklau: One way to think of monads is "programmable semicolons"
<dminuoso> cdunklau: So there's a deep reason why I intentionally line them up like that.
<dminuoso> cdunklau: So the trick is: In a tradicional scenario you might write: eur = digits; char(','); cents = digits; maybe(char('€')); return Eur.new(eur, cents)
alex`` has joined #ruby
<dminuoso> cdunklau: However: How do I capture this parser as a first class value that I can pass it to other combinators? How do you backtrack on failure?
<dminuoso> So in a twisted sense each >-> acts as a programmable assignment =
<dminuoso> (followed by a programmable semicolon)
<dminuoso> while >> acts as a programmable semicolon
<cdunklau> jesus
<cdunklau> i think this is so difficult for me because i'm not used to expression langauges
Beams_ has quit [Remote host closed the connection]
sytherax has quit [Remote host closed the connection]
<dminuoso> cdunklau: So these types of parsers are common in Haskell. What I write as >-> is called >>= in Haskell, and >> is the same. Haskell however has a syntax sugar that makes it a bit more readable.
<dminuoso> cdunklau: the cool thing in the end is, that `eurParser` itself is just a simple parser like digits or char(',')
Beams has joined #ruby
<dminuoso> cdunklau: https://gist.github.com/dminuoso/2a3af36e9525e8792e7c0a17a3311afa so you can use it to build larger parsers..
<cdunklau> i get the composibility part
kapil___ has joined #ruby
<cdunklau> i just don't get how the fuck this code works
<dminuoso> cdunklau: Are you familiar with ML style type annotations?
<cdunklau> dminuoso: hahah no
<dminuoso> cdunklau: It's very simple
<cdunklau> dminuoso: you keep using that word. i do not think it means what you think it means :)
<dminuoso> Haha
<dminuoso> cdunklau: Formally a parser can be thought of a function that `takes a string` and `returns a pair of a result and the remaining string`
<cdunklau> ok that's clear
<dminuoso> char = -> str { c, rest = str; return [c, rest] }
<dminuoso> is a simple parser, one that parses exactly one parser off a stream
<cdunklau> dminuoso: -> str { ... } is the lambda, right?
<dminuoso> right
<cdunklau> ok
<dminuoso> however that's not good enough because we dont know how to describe failure or backtracking
<dminuoso> so we augment that with a slight twist
<cdunklau> oh wait
<dminuoso> a parser is a functoin that `takes a string` and `returns a *list* of pairs, each of which consists of a possible result and the remaining string`
Bish has quit [Remote host closed the connection]
<dminuoso> each element in that list represents "one possible way to parse it, with the respective result and remaining stream"
<cdunklau> c, rest = str is that a real thing or shorthand for c, rest = str[0], str[1:] or so
<dminuoso> Yes and yes.
<dminuoso> ;)
<dminuoso> or.. well. shorthand
<cdunklau> blarg ok
<dminuoso> good catch =)
<cdunklau> oh ok good
<dminuoso> so
<dminuoso> by definition we say:
<dminuoso> if a parser returns an empty list, it denotes a failed parse
<dminuoso> if a parser returns a list of exactly one pair, it denotes a success
<dminuoso> if a parser returns a list of multiple pairs, it denotes an ambiguous parse
<dminuoso> so first we say we have some `Pair = Struct.new(:result, :rest)`
<dminuoso> so our char parser would actually look like
<dminuoso> char = -> str { c, rest = str[0], str[1..]; return [Pair.new(c, rest)]; }
<dminuoso> cdunklau: so far?
<cdunklau> following yes
<dminuoso> cdunklau: so now we define a function that sequences two parsers
<dminuoso> lets call it sequence
<dminuoso> sequence = -> parser1, parser 2 { ... }
<dminuoso> how would you implement this?
<cdunklau> hmm
<dminuoso> sequence = -> parser1, parser2 { ... }
jrafanie has joined #ruby
<cdunklau> { return [parser2(pair.rest) for pair in parser1(str)]; }
<cdunklau> if list comps are a thing
<dminuoso> cdunklau: that wont do it.
<cdunklau> or just some mappy thing
<dminuoso> remember you have to return a *parser*
<cdunklau> oh right
<dminuoso> so start from that fact.
<cdunklau> { return -> str { return [parser2(pair.rest) for pair in parser1(str)]; }; }
<cdunklau> sequence = -> str { return -> str { return [parser2(pair.rest) for pair in parser1(str)]; }; }
<dminuoso> cdunklau: I think that pseudo code looks about right.
<dminuoso> well, except you didnt correctly build the Pair.
<cdunklau> ah right
sytherax has joined #ruby
<cdunklau> well no i did. the pair is the thing parser2 returns
<cdunklau> but i don't know if that's correct
<dminuoso> Ah right. No it looks good.
<dminuoso> cdunklau: So that's basically just >>. `q = parser1 >> parser2` gives you a new parser back.
<dminuoso> One that (internally) first executes parser one, and then parser two.
<dminuoso> cdunklau: So next up lets do the monadic part.
<dminuoso> Now assume you have a function f
<dminuoso> f has this shpape:
<dminuoso> "take the result from a previous parser, and then *give a parser back*"
t0xik has quit [Quit: Connection closed for inactivity]
Beams_ has joined #ruby
<cdunklau> so that's like (Pair[]) -> Parser ?
<cdunklau> no
<dminuoso> cdunklau: In ML lingo you'd consider Parser a parametrized type
<dminuoso> so `Parser Char` would be some `String -> [(Char, String)]`
<dminuoso> Right?
<dminuoso> So your sequence has the shape: Parser a -> Parser b -> Parser b
amar_ has joined #ruby
<dminuoso> Now you want some `Parser a -> (a -> Parser b) -> Parser b`
Beams has quit [Ping timeout: 265 seconds]
<cdunklau> you lost me there. give me a bit
<cdunklau> let me roll it around in my head
<dminuoso> cdunklau: it may be easier if you try to define some concrete parser first
<dminuoso> though.. its easier to write them if you have that function.
<dminuoso> so no.
<cdunklau> heh
<cdunklau> but your euro parser thing
karapetyan has quit [Remote host closed the connection]
<dminuoso> cdunklau: >-> is that thing. > is a function that takes a lambda. that lambda gets the *result* of the previous parser (if it succeeds), and then makes a decision on a new parser to run afterwards.
<dminuoso> cdunklau: Its the same thought process of >> really
<cdunklau> \d+,\d{2}€? is the regex right?
leitz has joined #ruby
<dminuoso> Somewhat similar yes.
<samosaphile> is there a reason why haskell has no or few libraries/frameworks but OOP stuff (java, python, c# / .NET, etc) have tons? despite haskell being older language? well, i guess you could say java was backed by sun/oracle and c# by MS, which helped but ruby/python weren't ...
<dminuoso> samosaphile: Haskell has a a very healthy set of mature libraries.
<dminuoso> Most of them are well documented and many of exceptional quality.
sytherax has quit [Ping timeout: 256 seconds]
<cdunklau> samosaphile: python and ruby aren't as scary-looking
karuna has quit [Quit: Connection closed for inactivity]
<cdunklau> dminuoso: let me mull this over for a bit
<dminuoso> cdunklau: You should try to implement the >-> thing by the way. =)
<dminuoso> Alright
<dminuoso> cdunklau: Feel free to do it in python instead if it helps.
millerti has quit [Ping timeout: 245 seconds]
<dminuoso> cdunklau: It may be easier to ignore the `list` at first.
<dminuoso> (And then extend to allow for the list afterwards)
<samosaphile> what happens if you need a library in python/ruby but write something in haskell? is it possible to use libraries from different languages?
<dminuoso> Not with Haskell at the moment.
<samosaphile> k, was just curious
gustavn64 has joined #ruby
<dminuoso> samosaphile: Here our issues are actually switching to Haskell. So our rails apps start calling into Haskell APIs that listen on local unix domain sockets
<dminuoso> That way we can gradually switch over.
<dminuoso> cdunklau: While you are at it, you should also write the function `pure` which takes one argument and then returns a parser that readily has that result, and does not consume any input
<gustavn64> I'm creating a little interpreter for a programming language, in Ruby, and I want to represent the value nil (my kind of nil, not Ruby's). But I don't want to conflate my kind of nil with Ruby's kind of nil (since both occur in my interpreter). What would be a good, idiomatic way to do this?
<gustavn64> Just define a class like this?
<gustavn64> class Nil; end
conta1 has joined #ruby
<dminuoso> gustavn64: what kind of interpreter are you writing?
<gustavn64> To be honest, I don't really need a new instance for every time, either
<dminuoso> gustavn64: a stack machine? some AST interpreter?
<gustavn64> dminuoso: AST
<dminuoso> gustavn64: You could have some `NilNode = Object.new(ASTNode)`
karapetyan has joined #ruby
<dminuoso> err
<dminuoso> NilNode = Class.new(ASTNode)
<dminuoso> Assuming you have some base class to represent your AST nodes with
elsurudo has joined #ruby
<cdunklau> dminuoso: i suspect this would be difficult to write reasonable in python because of how badly lambda is crippled... and a decorator API would probably look awful
<dminuoso> cdunklau: just do it manually, its not a beauty contest.
<dminuoso> cdunklau: And its a bit annoying to read, but the entire purpose is to hide this plumbing behind >
<gustavn64> dminuoso: Yeah I guess that's kind of what I thought of. I don't have a common base class yet, but I see your point
<gustavn64> The problem is that it doesn't really feel like this right thing to do. I won't need a new instance if NilNode each time
<gustavn64> Oh wait, I guess I could actually do:
<gustavn64> NilNode = Object.new
conta1 has quit [Ping timeout: 276 seconds]
<gustavn64> How's that? Good Ruby style?
<dminuoso> gustavn64: If that works for you then sure.
<dminuoso> 15:16 gustavn64 | The problem is that it doesn't really feel like this right thing to do. I won't need a new instance if NilNode each time
<dminuoso> That wont be an issue as you can simply use a global `Nil = NilNode.new` - the point is to have a common interface you can later use to interact with the AST
<gustavn64> dminuoso: Ah. Is there any way to create the class NilNode, with methods and everything, but not giving it a name (only using it to instanciate Nil)?
<dminuoso> cdunklau: Just make some NilNode = Class.new(...)
<dminuoso> cdunklau: Even if just for the reason you might want to ask `node.class` later on ;)
gil_ has quit [Ping timeout: 276 seconds]
<dminuoso> Sorry gustavn64 =)
<samosaphile> dminuoso: what are your thoughts on python and c# / .NET ? do you equally detest them like javascript and ruby / rails? :P
<dminuoso> samosaphile: Yes.
<samosaphile> LOL
<samosaphile> i don't understand dminuoso if you really hate web so much, why not just use rust instead?
<dminuoso> samosaphile: Im in the process of switching some of our parts to Haskell.
gil_ has joined #ruby
gil_ has joined #ruby
gil_ has quit [Changing host]
<samosaphile> i see
mzo has joined #ruby
kmurphy4 has joined #ruby
bmurt has joined #ruby
theRoUS has quit [Changing host]
theRoUS has joined #ruby
aupadhye has quit [Quit: Leaving]
aupadhye has joined #ruby
karapetyan has quit [Remote host closed the connection]
saTchymoto has joined #ruby
bmurt has quit [Ping timeout: 264 seconds]
<gustavn64> dminuoso: Alright, thanks for the tips
<gustavn64> dminuoso: Why do you hate C# btw? haha
Burgestrand has quit [Quit: Closing time!]
<dminuoso> gustavn64: I like languages that actively pursue some goal and design decisions. The majority of mainstream languages are very close clones of one another.
<dminuoso> Just try programming in Prolog for a month and you will see what I mean.
aufi has joined #ruby
<gustavn64> dminuoso: I have used Prolog and I enjoyed it a lot
Rapture has joined #ruby
<gustavn64> Yeah I mean, I was mainly curious. I hate most mainstream languages in a mild sense too, but that's probably because I hate software engineering
Burgestrand has joined #ruby
<cdunklau> i'm still thinking about what you mean by the f with shape "take the result from a previous parser, and then *give a parser back*"
<dminuoso> cdunklau: check my last gist
<dminuoso> "# Runs one parser, feeds the result into the function, and then runs the resulting parser."
<dminuoso> the resulting thing must be a parser. too.
<cdunklau> dminuoso: sequence doesn't strictly need to be curried though, right?
griffindy has joined #ruby
<dminuoso> cdunklau: Nope.
sytherax has joined #ruby
<cdunklau> dminuoso: what's kf here bind = -> parser, kf { ... }.curry
<dminuoso> cdunklau: thats just the name of that function
<dminuoso> the function that accepts the result of the previous parser, and gives you a new parser to run back
<cdunklau> dminuoso: "result of the previous parser" meaning the list of pairs?
<dminuoso> cdunklau: especially in FP we tend to not think of a list as "multiple" but rather as some "fuzzy/non-deterministic" answer
<dminuoso> that is [1,2,4] is a number (but we're not quite sure *which*)
<dminuoso> and `map` lets you interact with that number (and since we're not sure *which* we apply it to each number)
<dminuoso> Does this help?
bmurt has joined #ruby
<cdunklau> dminuoso: that's a rather long-winded way of saying "yes" :)
<cdunklau> but that does illuminate things, sure
griffindy has quit [Ping timeout: 256 seconds]
pastorinni has joined #ruby
aufi has quit [Ping timeout: 240 seconds]
sytherax has quit [Ping timeout: 268 seconds]
erlendf has joined #ruby
MihaRekar has joined #ruby
<dminuoso> cdunklau: Almost.
<dminuoso> cdunklau: Its kind of wrong
za1b1tsu has joined #ruby
<dminuoso> cdunklau: So `kf` first want a single *result*
<dminuoso> Not a list of ParsePair
<cdunklau> oh that's what you meant by map
erlend has quit [Ping timeout: 268 seconds]
erlendf is now known as erlend
<dminuoso> cdunklau: and remember that `kf` only wants the raw *result*, not the pair
<dminuoso> (this is an important part to the DSL)
dviola has joined #ruby
c0mrad3 has quit [Quit: Connection closed for inactivity]
<livcd> is rubinius still a thing ?
snickers has joined #ruby
millerti has joined #ruby
<dminuoso> cdunklau: then when you are done, we'll get rid of your clunky digits and char parser and start with combinators instead.
<cdunklau> heh
<dminuoso> You'll be amazed I promise =)
<cdunklau> so when i map kf i get a list of parsers...
<dminuoso> Yup.. =)
cyberg has joined #ruby
<cdunklau> [kf(pp.result) for result in parserA(string)]
anisha has quit [Quit: This computer has gone to sleep]
<dminuoso> what is pp?
<cdunklau> err s/result/pp/
<cdunklau> err
<cdunklau> bad sed :(
<cdunklau> [kf(pp.result) for pp in parserA(string)]
<dminuoso> cdunklau: Alright.. but you dont want a list of parser, you want a list of pairs!
<cdunklau> dminuoso: OH
<dminuoso> Because again, you are *constructing a parser*
<cdunklau> [kf(pp.result)(pp.rest) for pp in parserA(string)]
<dminuoso> Yes.
<cdunklau> got it
<dminuoso> Voila. Your first monad.
<dminuoso> Now implement `pure`
<dminuoso> To round it up
<dminuoso> cdunklau: the point of bind is basically this:
ramfjord has joined #ruby
<cdunklau> dminuoso: pure is... ready_result -> string -> [Pair(ready_result, string)]
<cdunklau> right?
<dminuoso> Yup =)
<dminuoso> cdunklau: it creates an "effect" free parser (because it doesnt consume any input)
<dminuoso> hence "pure"
<dminuoso> cdunklau: alright. now write a simple parser item that consumes a single character and gives that character as a result
<dminuoso> (you'll need to develop a small set of basic utilities - those are usually all provided by a combinator libraries)
<cdunklau> dminuoso: a single specific character or just the first one
<dminuoso> the first one.
<dminuoso> call it `item`
<dminuoso> then write a function `satisfy` that takes a predicate, a parser, and then runs a parser, tests the result with the predicate. "fail" if the predicate gives you a false, and "return" the result if gives you a true. You will need to use `bind` and `pure`
<dminuoso> (remember what "parse failure" means?)
<dminuoso> then you can write some `isChar` function using `satisfy`
<cdunklau> item_parser
ramfjord has quit [Ping timeout: 248 seconds]
<dminuoso> yup great
<dminuoso> now write satisfy.
shinnya has quit [Ping timeout: 256 seconds]
<cdunklau> dminuoso: satisfy returns a parser that does the thing right?
<dminuoso> cdunklau: satisfy :: (a -> Bool) -> Parser a -> Parser a
subroot has joined #ruby
<dminuoso> cdunklau: it returns a parser that.. runs the passed parser, and uses the predicate to determine whether it should fail or not.
<dminuoso> cdunklau: at this point you will *stop* to build parsers from scratch, and instead use the existing functions
<dminuoso> (so that you start to lose the focus on the exact inner workings)
<dminuoso> cdunklau: `bind` is my > by the way.
<dminuoso> so when I write: digits >-> d { ... }
<dminuoso> then > is just the infix `bind`
<dminuoso> -> d { .. }
<dminuoso> is the kf
<cdunklau> oh bind has to be curried doesn't it
snickers has quit [Quit: Textual IRC Client: www.textualapp.com]
<dminuoso> it might be useful, perhaps not *shrugs*
<dminuoso> digits > (-> d { ...})
<dminuoso> bind(digits, (-> d { ...})
<dminuoso> cdunklau: And if you want you can also reimplement `sequence` in terms of `bind`
saTchymoto has quit []
<dminuoso> cdunklau: You might find this paper enlightening: http://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf
<dminuoso> Even though its in haskell its mild. You should be able to read it.
gustavn64 has quit [Quit: Page closed]
<cdunklau> this feels like one of those riddles that i'm so terrible at, where once you hear the solution it's all "duuuuuh that's obvious *now*"
mzo has quit [Ping timeout: 256 seconds]
Beams_ has quit [Remote host closed the connection]
karapetyan has joined #ruby
sinduck has quit [Ping timeout: 245 seconds]
Beams has joined #ruby
sytherax has joined #ruby
spooky_d has left #ruby [#ruby]
karapetyan has quit [Ping timeout: 268 seconds]
QCF has joined #ruby
sytherax has quit [Ping timeout: 276 seconds]
apparition47 has quit [Quit: Bye]
aufi has joined #ruby
grilix_ has joined #ruby
MihaRekar has quit []
TomyWork has quit [Ping timeout: 240 seconds]
kapil___ has quit [Quit: Connection closed for inactivity]
rideh has quit [Ping timeout: 256 seconds]
<cdunklau> dminuoso: that did help. made me realize my bind is wrong, it doesn't concat
rideh has joined #ruby
m1st3rwr0ng has joined #ruby
chouhoulis has joined #ruby
banisterfiend has joined #ruby
iceden has quit [Remote host closed the connection]
aupadhye has quit [Ping timeout: 240 seconds]
biberu has quit [Ping timeout: 260 seconds]
ellcs has quit [Quit: Leaving.]
workmad3 has quit [Ping timeout: 260 seconds]
iceden has joined #ruby
venmx has quit [Ping timeout: 256 seconds]
venmx has joined #ruby
workmad3 has joined #ruby
Burgestrand has quit [Quit: Closing time!]
mzo has joined #ruby
tcopeland has joined #ruby
tcopeland has quit [Client Quit]
<dminuoso> cdunklau: Ah right.
<dminuoso> cdunklau: I dont have much experience with Python, so I just skimmed the code.
<dminuoso> It looked morally right =)
<dminuoso> cdunklau: Once you have established a rich toolset of combinators, they really do take off.
<dminuoso> If they are monadic they are strictly more powerful than recursive descent parsers, but just as easy to use.
<dminuoso> Do take note that efficient implementations are *much* harder if you want any useful diagnostics, the ability to recover from failed parses, and performance.
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nadir has quit [Quit: Connection closed for inactivity]
<cdunklau> dminuoso: so what's the point :)
<dminuoso> cdunklau: They are really comfortable to write
<dminuoso> Even for small things
<dminuoso> Or for networking protocols
troys has joined #ruby
<dminuoso> Or for complex parsing situations
<cdunklau> so are PEGs
<cdunklau> (PEGs are the only parser thingies used, so i don't really know what i'm talking about)
<cdunklau> s/used/i've used/
<dminuoso> cdunklau: parser combinators are a lot cooler because your parsers are first class values
RougeR has quit [Ping timeout: 256 seconds]
QCF has quit [Ping timeout: 240 seconds]
jcarl43 has joined #ruby
synthroid has quit [Remote host closed the connection]
yokel has quit [Ping timeout: 240 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kmurphy4 has quit [Quit: kmurphy4]
QCF has joined #ruby
yokel has joined #ruby
dbugger__ has joined #ruby
dionysus69 has quit [Ping timeout: 264 seconds]
synthroid has joined #ruby
andikr has quit [Remote host closed the connection]
aufi has quit [Ping timeout: 264 seconds]
QCF has quit []
venmx has quit [Ping timeout: 260 seconds]
venmx has joined #ruby
desperek has joined #ruby
thadtheman has quit [Remote host closed the connection]
karuna has joined #ruby
banisterfiend has joined #ruby
kapil___ has joined #ruby
banisterfiend has quit [Client Quit]
yohji has quit [Remote host closed the connection]
WAFFLEMAKER3000 has joined #ruby
sysvalve has quit [Quit: Leaving]
Mike11 has joined #ruby
turt2live has quit [Read error: Connection reset by peer]
velu_aon[m] has quit [Remote host closed the connection]
luna_x[m] has quit [Write error: Connection reset by peer]
KevinMGranger has quit [Remote host closed the connection]
bascht has quit [Read error: Connection reset by peer]
Giphy[m] has quit [Read error: Connection reset by peer]
redlegion[m] has quit [Remote host closed the connection]
intheclouddan has quit [Read error: Connection reset by peer]
jonjits[m] has quit [Write error: Connection reset by peer]
haylon_ has quit [Remote host closed the connection]
iceskins[m] has quit [Remote host closed the connection]
zalipuha[m] has quit [Remote host closed the connection]
Hanma[m] has quit [Remote host closed the connection]
aviraldg has quit [Read error: Connection reset by peer]
alex`` has quit [Quit: WeeChat 2.1]
zenspider has quit [Ping timeout: 260 seconds]
zenspider has joined #ruby
clemens3_ has quit [Ping timeout: 265 seconds]
darkhanb has joined #ruby
cschneid has joined #ruby
venmx has quit [Quit: leaving]
venmx has joined #ruby
elsurudo has quit [Quit: elsurudo]
bauruine has quit [Ping timeout: 256 seconds]
clemens3_ has joined #ruby
kmurphy4 has joined #ruby
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
workmad3 has quit [Ping timeout: 264 seconds]
amar_ has quit [Remote host closed the connection]
aufi has joined #ruby
bauruine has joined #ruby
amar_ has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
kt has quit [Ping timeout: 260 seconds]
conr_ has left #ruby [#ruby]
amar_ has quit [Ping timeout: 245 seconds]
jottr has quit [Ping timeout: 260 seconds]
intheclouddan has joined #ruby
Mike11 has quit [Quit: Leaving.]
megamos has quit [Quit: Leaving]
rabajaj has joined #ruby
akaiiro has joined #ruby
<rabajaj> can anyone help me out with File.join method
<rabajaj> if I dont know the absolute path to the file then can I use File.join
<apeiros> rabajaj: yes
<apeiros> File.join is mostly just arguments.join(PathSeparator)
j0bk has joined #ruby
<rabajaj> assume i have a variable `x` in which i have path `/tmp/exports`. I want to access a file that is created in `/tmp/exports/something_i_don_know/here is the file`
<rabajaj> apeiros ^
<rabajaj> apeiros, if i do this Dir["#{x}/*/*/*.iso"] i get the path i want
<rabajaj> can we convert this into File.join ?
<apeiros> sure
<apeiros> Dir[File.join(x, "*", "*", "*.iso")]
<rabajaj> letme try this :)
raynold has joined #ruby
<rabajaj> apeiros, woah :) thanks
<rabajaj> apeiros++
<apeiros> yw
dionysus69 has joined #ruby
sanscoeur has joined #ruby
orbyt_ has joined #ruby
Beams has quit [Quit: .]
kmurphy4 has quit [Remote host closed the connection]
workmad3 has joined #ruby
beefjoe has joined #ruby
wontruefree has joined #ruby
cadillac_ has quit [Read error: Connection reset by peer]
nfk has joined #ruby
<baweaver_away> G'morning apeiros
<baweaver_away> ...
baweaver_away is now known as baweaver
cadillac_ has joined #ruby
<apeiros> moin baweaver
<baweaver> There we go, that feels better
<baweaver> Quick challenge / tip for kicks - https://twitter.com/keystonelemur/status/1006582160516526080
<baweaver> Now my prefill list for daily tips is empty D:
<apeiros> rot13 with tr?
<baweaver> Time to go raid Set and Struct for fun :D
Cork has quit [Quit: .]
<apeiros> oh wow, it's in the text. lol, I only looked at the code :D
<apeiros> what's a "tip for kicks"?
jottr has joined #ruby
Hanma[m] has joined #ruby
bascht has joined #ruby
jonjits[m] has joined #ruby
aviraldg has joined #ruby
redlegion[m] has joined #ruby
luna_x[m] has joined #ruby
Giphy[m] has joined #ruby
velu_aon[m] has joined #ruby
KevinMGranger has joined #ruby
haylon_ has joined #ruby
turt2live has joined #ruby
karapetyan has joined #ruby
iceskins[m] has joined #ruby
zalipuha[m] has joined #ruby
jamesaxl has quit [Ping timeout: 268 seconds]
Cork has joined #ruby
jottr has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: Textual IRC Client: www.textualapp.com]
<baweaver> colloquialism "for fun"
<baweaver> 'muricah
<baweaver> Not sure if this one is a bug yet or not, but setting default will wipe default proc
ellcs has joined #ruby
<baweaver> (on a Hash)
<baweaver> I half think it's expected, because default value is checked for first.
<baweaver> >> h = Hash.new { |h,k| h[k] = 5 }; [h.default_proc, h.default, h.default = nil, h.default_proc]
<ruby[bot]> baweaver: # => [#<Proc:0x41219940@/tmp/execpad-d40a36ffb44d/source-d40a36ffb44d:2>, nil, nil, nil] (https://eval.in/1019958)
venmx has quit [Ping timeout: 240 seconds]
jamesaxl has joined #ruby
<baweaver> implied vs explicit nil that is
FernandoBasso has joined #ruby
darkhanb has quit [Ping timeout: 256 seconds]
dendazen has quit [Read error: Connection reset by peer]
jottr has joined #ruby
wontruefree has quit [Quit: bye]
orbyt_ has joined #ruby
griffindy has joined #ruby
griffindy has quit [Client Quit]
orbyt_ has quit [Remote host closed the connection]
orbyt_ has joined #ruby
jottr has quit [Ping timeout: 256 seconds]
nfk has quit [Remote host closed the connection]
nfk has joined #ruby
amar_ has joined #ruby
wmoxam has joined #ruby
<apeiros> baweaver: iirc it was considered a bug when it didn't
<apeiros> you can only have one method of default, and setting one will reset the other to nil iirc
leitz has quit [Quit: Nappy time]
ellcs has quit [Ping timeout: 260 seconds]
lxsameer has quit [Read error: Connection reset by peer]
apeiros__ has joined #ruby
lxsameer has joined #ruby
paraxial has quit [Quit: Ping timeout (120 seconds)]
ramfjord has joined #ruby
paraxial has joined #ruby
apeiros has quit [Ping timeout: 264 seconds]
ferr has quit [Remote host closed the connection]
<baweaver> mm, yeah, that's what I was thinking
shenghi has quit [Ping timeout: 264 seconds]
ferr has joined #ruby
sameerynho has joined #ruby
<baweaver> apeiros__: Y'know if methods returning symbol names changed the way annotations are written? Most of the implementations I'm seeing rely on method_added
apeiros__ is now known as apeiros
<apeiros> problem is that you can't just do "some_annotation\ndef foo", you have to "some_annotation def foo"
<apeiros> so chaining multiple becomes ugly quick
<apeiros> (or you use \ trick)
workmad3 has quit [Ping timeout: 276 seconds]
<apeiros> I have only seen rare cases of DSLs which make use of def's returning symbols.
clemens31 has joined #ruby
clemens3 has quit [Ping timeout: 245 seconds]
karapetyan has quit [Remote host closed the connection]
banisterfiend has joined #ruby
ryzokuken has quit [Quit: Ping timeout (120 seconds)]
ryzokuken has joined #ruby
karapetyan has joined #ruby
chouhoul_ has joined #ruby
paraxial has quit [Ping timeout: 264 seconds]
za1b1tsu has quit [Quit: WeeChat 2.1]
chouhoulis has quit [Ping timeout: 248 seconds]
wontruefree has joined #ruby
ramfjord_ has joined #ruby
<baweaver> True.
<jrich523> https://gist.github.com/jrich523/3afa7a06f87da0e61f9e2f7102cfcc53 this feels.... stupid.. it works... but... any..hmm... more ruby'ish ways to do it? seems like having the array definition like that is stupid
<baweaver> Admittedly I tend to do `private def ...` on occasion
<jrich523> also, for line 7, that came up yesterday, but all the suggestions were to new (2.0, everything else was 2.1 or 2.3)
mikecmpbll has joined #ruby
<baweaver> nodes.map
ramfjord has quit [Ping timeout: 264 seconds]
<jrich523> hmm i was considering that, but the result is from an http request, client.data (just pushed in to "nodes")
<baweaver> kvms.concat nodes.map do |n|
<jrich523> so the map might get dicey since its a WAY differnt object?
<baweaver> making an array and doing an each/push is already a map
<jrich523> hmm so im more so confusing map vs map!
<jrich523> let me play with that, thanks :)
bmurt has quit [Quit: Textual IRC Client: www.textualapp.com]
unknown2 has joined #ruby
<unknown2> hello
unknown2 has quit [Client Quit]
kapil___ has quit [Quit: Connection closed for inactivity]
cliluw has quit [Read error: Connection reset by peer]
dbugger__ is now known as Dbugger
shenghi has joined #ruby
cliluw has joined #ruby
samort7 has joined #ruby
mtkd has joined #ruby
<cthulchu> what is ::?
<Eiam> scope
bmurt has joined #ruby
\void has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
<cthulchu> oh cool
<cthulchu> it's weird though
<cthulchu> a little bit weird
<cthulchu> cuz I would expect a . to do it
<Eiam> >>Kernel::puts.object_id; puts.object_id
<ruby[bot]> Eiam: # => ...check link for more (https://eval.in/1020018)
<Eiam> uhh, no
<Eiam> it specifies the module
<cthulchu> and . wouldn't work with modules?
<Eiam> . is not for specifying a module, its for accessing a method on an instance
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
<cthulchu> in a class...
<cthulchu> look
<Eiam> cthulchu: yes, you can write >>Kernel.puts
<cthulchu> the dude uses :: to access a constant within a class
<Eiam> :: resolves scope
<Eiam> here, this describes it.
<Eiam> cthulchu: there is a specific reason that :: works in that case but won't work in other cases, the link covers it.
<cthulchu> thanks, reading
<Eiam> I just think of it as " :: resolves scope, . calls methods".
<Eiam> even tho its possble to use :: to call a method in some cases. not a fan of that use case but its ruby, you do you.
pastorinni has quit [Remote host closed the connection]
oncall-pokemon has joined #ruby
<cthulchu> Eiam, in your link there's is an answer
m1st3rwr0ng has quit [Quit: Bye.]
<cthulchu> the first answer
<cthulchu> not the comment though
pastorinni has joined #ruby
<cthulchu> the first block of the code in it
<cthulchu> oh, wait
<cthulchu> I got it
<cthulchu> omfg
<Eiam> =)
<cthulchu> I just got this problem a few days ago
<cthulchu> I couldn't get the variable
<cthulchu> I had to use some awkward solution
<Eiam> is it because you are using :: ? =)
<cthulchu> no, I could've used ::
<cthulchu> instead I used some weird object method that got me the variable
<cthulchu> crazy
lbracher has joined #ruby
<cthulchu> @selenium_wrapper.instance_variable_get("@driver")
<cthulchu> instead of @selenium_wrapper::driver
<cthulchu> probably would work as fine
chat_ has joined #ruby
<Eiam> uhh
pastorinni has quit [Ping timeout: 240 seconds]
<jrich523> sounds like some confusion between static members on a class, and class instance (object)?
tobiasvl has quit [Ping timeout: 240 seconds]
<Eiam> why in the world would they use instance_variable_Get
<Eiam> so weird
<Eiam> @selenium_wrapper.driver makes so much more sense =0
herbmillerjr has joined #ruby
chat has quit [Ping timeout: 264 seconds]
<lbracher> Hi there! I did a gem update that says ruby version is 1.8, however, $(which ruby) -v gives me ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] . Where is this ruby binary and how can I update it in my Ubuntu distro? Thanks in advance!
<Eiam> calling a method to access a variable thats already on your class just seems wonky and overly verbose
<Eiam> lbracher: whats the gem call you made thats telling you 1.8?
<Eiam> 1.8 has been EoL for a long time
<cthulchu> nope
<cthulchu> @selenium_wrapper.driver is not the ruby way
<lbracher> Eiam, gem update on a project directory
<Eiam> cthulchu: I'd completely beg to differ on that one
<cthulchu> I thied @selenium_wrapper.driver right away
agent_white has joined #ruby
<cthulchu> ment perfect sense to me
samort7 has quit []
<cthulchu> you know what it said?
<cthulchu> there's no such method
<cthulchu> METHOD!
steerio has joined #ruby
<cthulchu> hell
<cthulchu> so I googled and found that weird method of getting ivars
<steerio> hi all, I ran into the "bundler/dep_proxy" loaderror issue that should've been gone back in April
<cthulchu> I'm sure :: would've worked
<lbracher> Eiam, It says, for instance: Updating rack \n Fetching: rack-2.0.5.gem (100%) \n ERROR: Error installing rack: \n There are no versions of rack (= 2.0.5) compatible with your Ruby & RubyGems \n rack requires Ruby version >= 2.2.2. The current ruby version is 1.8.
<cthulchu> even in your example, they claim . doesn't work
<steerio> anyone here knows how it can occur with 2.5.0, latest rubygems, latest bundler?
<cthulchu> Example::Version # => 1.0
<cthulchu> Example.Version # NoMethodError
<Eiam> cthulchu: because they didn't create accessors
<cthulchu> errr
<cthulchu> how do you create accessors?
<Eiam> attr_accessor :driver
<cthulchu> hm
<cthulchu> interesting
<cthulchu> okay, later about that
<cthulchu> time to make mistakes :)
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jrich523> thank goodness for git lol
<Eiam> cthulchu: so the driver variable is being "hidden" as it has no exposed accessors (like getters/setters)
<Eiam> but its still there, but "getting" to it requires the instance_variable_get to "get" it
<cthulchu> would I be able to still access it via ::?
<cthulchu> so this instance_variable_get is a cheat, basically
<cthulchu> if the language was stricter, I wouldn't've accessed the var from outside?
<cthulchu> it's like private when there's no accessors?
<cthulchu> weird cuz I would expect for it to be public by default
<Eiam> instance_variable_get may be how its implemented under the covers, but to me yes, using instance_variable_get is a kind of "cheat". I'm not the authority, and the method does what you want so w/e
<Eiam> if they wanted you to access and use it, they should have added class accessors
<Eiam> if they wanted read only, attr_reader :driver
<cthulchu> why aren't the vars accessible by default?
banisterfiend has joined #ruby
<Eiam> design decision? thats just how classes work by default
<cthulchu> the opposite makes more sense: add protectors if you don't want the var to be accessed
<cthulchu> ok
<cthulchu> it's good to know
<cthulchu> ha! :: omits the accessors too!
<Eiam> there is attr_reader, attr_writer and attr_accessor which define read, write and both respectively
<jrich523> meh, from a security point of view, private by default
<cthulchu> ruby is not an exactly strict language
<cthulchu> not about security
<Eiam> just feel the vibes man
<Eiam> chill dude
<Eiam> thats Ruby to me. =)
<jrich523> lol
<cthulchu> indeed
<lbracher> How can I update ruby installation that gems is using?
<cthulchu> I totally agree. it feels relaxing
<jrich523> the ambiguity drives me nuts
<cthulchu> hehehe
<Eiam> lbracher: are you using bundler?
<cthulchu> embrace it :)
<jrich523> lol it makes it super hard to read
<Eiam> jrich523: I just define my own rules within my code
<Eiam> and just enforce those rules for said code base. sanity
<jrich523> yeah i usually have to work on other people stuff
<Eiam> ages ago, my old boss set those rules and I hated working with his ruby
<Eiam> reading it droves me fucking nuts
<lbracher> Eiam, no. I'll install it and I'll tell you if it works or not. :)
<Eiam> method_missing all over the place
<jrich523> there are too many little rules to remember
cconstantine has joined #ruby
<jrich523> dont need x if you do y but if you do it this way then you also dont need to do Z
<jrich523> for the love of god, slapping some () or {} around things isnt the end of the world, just stick to standards
<jrich523> standards is a bad choice of word.... norms
<eam> normies
aufi has quit [Ping timeout: 255 seconds]
wontruefree has quit [Quit: bye]
<cconstantine> Hello! I’m trying to write a proxy server in ruby. I’d like to be able to accept incoming tls connections, parse out the hostname indiciated in SNI, then proxy the TCP connection. (much like fabio’s tcp-sni mode: https://fabiolb.net/feature/tcp-sni-proxy/ ). Is there a library that would let me do this easily?
ellcs has joined #ruby
<cthulchu> wow
za1b1tsu has joined #ruby
<cthulchu> I have something that looks like a sacrilege.
<cthulchu> require 'require_all'
wontruefree has joined #ruby
<jrich523> lol
<cthulchu> looks scary
<jrich523> i have some really crazy stuff in my current project.. which i guess i'll try to tackle at some point.. but... im way lost on why its that way
wontruefree has quit [Client Quit]
<cthulchu> It's just I was using requires as my main way to study what does what in this codebase. and now this...
<jrich523> in the gem file it points back to the product to include itself.. which i think was so the main bin file could access it as a library? not really sure... mad weird
tty has joined #ruby
millerti has quit [Ping timeout: 260 seconds]
<cthulchu> oh wonderful.
<cthulchu> now I see this: require_rel '../../lib/*.rb'
<cthulchu> awesome
<jrich523> lol
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jrich523> so in this project, in the lib he has a folder (basically the module)
<jrich523> which at its root is just a bunch of requires (single module in multiple files)
<jrich523> which i guess is kinda nice, except for the gemfile part
<cthulchu> I mean, it defeats the purpose of including only what you use
<cthulchu> but again, it's ruby
<jrich523> lol
<cthulchu> so just chill
wontruefree has joined #ruby
<jrich523> another beef i have, is that when you import you dont (cant?) define what it is you get
<jrich523> like python/node you'll do
<jrich523> import x from lib
<jrich523> and you know, x is from that library
<jrich523> i had some product library that exposed "Client" and it took some hair pulling to figure out that was from a require
<Eiam> jrich523: you could define modules, then include the modules inside a class
<Eiam> to try and constrain what you get
<jrich523> sure, but im not the one creating this stuff... im usually given some pile of code, told to figure it out and add a feature
<jrich523> and usually its older code that is no longer owned by anyone, which is why they brought me in...
<jrich523> "figure it out.. have fun... lol"
<jrich523> sums up my life
za1b1tsu has quit [Ping timeout: 265 seconds]
<Eiam> thats how you learn
Kundun has joined #ruby
<Eiam> sorting out other peoples messes
<Eiam> include if that other person is you from 5 days ago
<jrich523> oh for sure, its frustrating, but i like my job
aufi has joined #ruby
<jrich523> its not language limited either... and im very happy to learn ruby.. just... its def one of the more painful langs to pick up
<jrich523> cuz of all the rules/exceptions
<Eiam> thats how I learned rails, and sproutcore
jottr has joined #ruby
<Eiam> eh, it will come together. I remember that too, being frustrated by all the different ways
<jrich523> i just dont see the point
<Eiam> you'll get most the common cases figured out soon enough
<Eiam> freedom of expression? its part of the language
<mikecmpbll> most peoples' experience is that ruby is one of the least painful to pick up.
<Eiam> if you want forced opinions, check out Python
<jrich523> i guess i dont think you should be given that freedom, this isnt an art class :)
jenrzzz has quit [Ping timeout: 260 seconds]
<mikecmpbll> i'm not just randomly asserting that, based on everyone i've ever recruited.
<jrich523> mikecmpbll as an addional lang, or to learn programming/scripting?
<mikecmpbll> mostly graduates who learned in java/c#
<jrich523> those are two way different problems :)
<Eiam> mikecmpbll: I'd say it was the most fun to pick up, certainly =)
<mikecmpbll> jrich523 : as an additional lang.
<Eiam> I do recal frustration at the breadth of how people do things but, no more irritating than I am when I write javascript
<jrich523> i guess its less frustrating than... i'll call it node (modern javascript?)
<Eiam> jrich523: if you really want to be told how to do things, you could try out haskell? =)
<jrich523> i'll likely master ruby way before i get a grasp on the current world of JS
<jrich523> lol
<jrich523> i dont pick it, im told
<jrich523> usually to work on a product, in this case its foreman/puppet so ruby
<jrich523> was doing jenkins work before in GO
<jrich523> did ptyhon with ansible/openstack prior to that
<jrich523> before that was an SRM like product in powershell
<lbracher> Eiam, I got "Could not verify the SSL certificate for https://rubygems.org/quick/Marshal.4.8/pg-0.7.9.2008.01.28.gemspec.rz" while performing a `bundle update`. I tried `sudo gem update --system` to solve it but I got the same error. Any ideas?
<jrich523> so... i dont really get to pick very often
samosaphile has quit [Quit: Page closed]
<Eiam> lbracher: no, I'm not very good at de-tangling that part of ruby, sorry
<lbracher> Eiam, ok! Thanks! ;)
<mikecmpbll> lbracher : do you use rvm?
<jrich523> weird that the ssl cert from rubygems.org would cause an issue?
Nicmavr has joined #ruby
dinfuehr has quit [Ping timeout: 245 seconds]
Nicmavr is now known as Guest59508
<lbracher> mikecmpbll, to be honest, today is my first day with Ruby I know nothing about the ecosystem and I'm a little bit confused. To make a long story short, I'm trying to fix a rails system for a friend and I figured out Apache doesn't load because command PassengerDefaultRuby on apache2.conf file. My friend told me it was working before. Maybe it's just a Gemfile problem and I'm blowing neurons for nothing?
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest59508 has quit [Changing host]
Guest59508 has joined #ruby
Guest59508 is now known as Kestrel-029
<mikecmpbll> sounds like almost nothing to do with ruby itself :)
dinfuehr has joined #ruby
<mikecmpbll> can't really help without the error. presumably it's a passenger spawning error
FernandoBasso has quit [Ping timeout: 256 seconds]
<lbracher> mikecmpbll, I'm totally lost with that error. It says "Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration" when I `sudo /etc/init.d/apache2 start`
<mikecmpbll> i'm not particularly familiar with apache, i use nginx. however, that's the correct name for the directive; maybe passenger isn't installed correctly, or you're using the directive in the wrong context?
<mikecmpbll> check your apache virtualhost config and the docs: https://www.phusionpassenger.com/library/config/apache/reference/#passengerdefaultruby
<cthulchu> initialize methods are, basically, constructors?
<cthulchu> and we can have many initialize methods with different signatures?
<lbracher> mikecmpbll, I'll try it. Thank you! :)
<mikecmpbll> cthulchu : yes, and no.
<cthulchu> or since we're typeless and since we can do and we can do initialize(a=0)
<mikecmpbll> ruby doesn't have the concept of method overloading.
<cthulchu> we can fit all signatures in one
clemens31 has quit [Ping timeout: 240 seconds]
<mikecmpbll> yes.
<cthulchu> awesome!
<cthulchu> fells very relaxing
<cthulchu> lol
<mikecmpbll> ;)
jrabe has left #ruby [#ruby]
BTRE has quit [Quit: Leaving]
jrabe has joined #ruby
AJA4350 has quit [Remote host closed the connection]
lucas__ has quit [Remote host closed the connection]
Puffball has quit [Read error: Connection reset by peer]
raynold has quit []
<Eiam> cthulchu: also a ruby method can end its argument list with a hash
<cthulchu> I don't see when I would need it
<cthulchu> never ever needed it
<Eiam> hah. its used a ton, everywhere
<cthulchu> yeah, why bother thinking and planning your structure if you can change it whenever you want
<cthulchu> ahahahah
<cthulchu> is this the most relaxed language in the universe?
<Eiam> often in lieu of even bothering with naming parameters directly
<Eiam> def method(). pass a hash into it, presto named arguments
<cthulchu> lol
<cthulchu> so method() is a constructor of a method that belongs to the object class?
Puffball has joined #ruby
<Eiam> you mean the actual method and not an example?
za1b1tsu has joined #ruby
<cthulchu> ah
<cthulchu> I thought your example was the actual code
<cthulchu> oh, you defined it
AJA4350 has joined #ruby
<Eiam> nah i was using it as an example to just define a method and later you can sort out what you pass into it
<cthulchu> ok ok
<Eiam> but it works like you said too if you think of it as Method the thing and not method the generic example =0
beefjoe has quit [Remote host closed the connection]
clemens31 has joined #ruby
<cthulchu> yes
<cthulchu> okay, good to know
orbyt_ has joined #ruby
za1b1tsu has quit [Ping timeout: 248 seconds]
dbugger__ has joined #ruby
lucas_ has joined #ruby
amelliaa has joined #ruby
Dbugger has quit [Ping timeout: 265 seconds]
chouhoul_ has quit [Remote host closed the connection]
paraxial has joined #ruby
<cthulchu> and there's no difference between .new and .new()?
ellcs has quit [Ping timeout: 268 seconds]
izaac has quit [Quit: leaving]
lucas_ has quit [Remote host closed the connection]
<jrich523> () are optional :)
<jrich523> as is {}
<jrich523> and a ton of other things lol
workmad3 has joined #ruby
<cthulchu> lol
<jrich523> so .new value and .new(value) are the same thing
jenrzzz has joined #ruby
<jrich523> bout 50 ways to enter in named params too lol
ellcs has joined #ruby
<cthulchu> doesn't it cause issues when minify?
<cthulchu> anyhow, gonna just use it :)
<jrich523> there is a minify? that sounds really really scary
<cthulchu> ahahahahah
<jrich523> any AST for ruby?
<jrich523> that would make that more reasonable i guess?
lucas_ has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
workmad3 has quit [Ping timeout: 240 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jrich523> lol im trying to follow rubocop's rules.. just gave me crap about a word array, googled it.. syntax shown was %w().. use that... and now rubocop is like hey you should do %w[]...
<eam> rubocop is often wrong
<jrich523> its way more right than i am :)
<eam> not me! :D
<jrich523> how do i inject you in to my VS Code? :)
ciscam has quit [Ping timeout: 265 seconds]
wontruefree has quit [Quit: bye]
<jrich523> they did add a shared/remote view thing.. have yet to try it...
<jrich523> 'live share' thats what it is
ciscam has joined #ruby
chouhoulis has joined #ruby
<cthulchu> oh so the variables actually have types
<cthulchu> they're just implicit
<cthulchu> and quite hard types too
<cthulchu> a variable can't mutate its type?
<cthulchu> so I can't do a = nil and then a = "pew-pew"
wald0 has joined #ruby
<cthulchu> weird
<cthulchu> I'd expect it
orbyt_ has joined #ruby
quobo has joined #ruby
cconstantine has quit [Ping timeout: 256 seconds]
cconstantine has joined #ruby
wontruefree has joined #ruby
<mikecmpbll> rubocop isn't "right", OR "wrong". it's does what you tell it.
<mikecmpbll> cthulchu : yes, you can redefine variables.
icarus has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<eam> mikecmpbll: the defaults :D
<mikecmpbll> rubocop without defaults would be a pain to use.
<jrich523> it wouldnt be used :)
<mikecmpbll> doesn't mean you have to submit to defaults like some syntax-submissive.
<jrich523> well in my case, i assume its better than my garbage, and in most cases it is
<jrich523> however, this line it had me craft is driving me nutty and im likely to change it back to my crappy way
<jrich523> kvms = kvms.select { |h| options[:site].casecmp(h['site']).zero? } if options[:site]
chouhoulis has quit [Remote host closed the connection]
nicht has joined #ruby
<jrich523> after like 4 revisions of its suggestions, i ended up with that.. and i dont like it one bit lol
<eam> syntax submissive I like it
chouhoulis has joined #ruby
<eam> just saying the defaults are silly and overly pedantic with bad opinions. of course they can be changed
<eam> but we can, and should, still criticize the choices of defaults ;)
<eam> if they were less opinionated we might be able to establish a widely agreed upon common subset!
<jrich523> isnt that the problem with ruby?
<mikecmpbll> sure, doesn't detract from the fact that rubocop is brilliant OSS.
<mikecmpbll> you can't have a styleguide without being opinionated.
<mikecmpbll> just change your settings.
<eam> you can
<jrich523> i mean, when yuou have a million ways to do something, no one will ever agree
<mikecmpbll> no, you cannot.
<eam> of course you can, don't be silly
<mikecmpbll> are you just going to repeat yourself or explain how you can decide what's the right way without being opinionated?
<eam> rubocop could omit a warn about %w characters, or allow a larger set, or ...
<jrich523> you are both correct :)
<mikecmpbll> ___you can set rubocop not to warn about that___
<eam> yes, but we are discussing the defaults, did you forgeT?
<eam> I think you might be getting lost here
<mikecmpbll> i'm not lost, i've already stated why there are defaults.
<mikecmpbll> [21:19:09] <mikecmpbll>rubocop without defaults would be a pain to use.
<eam> the defaults are poor, are too opinionated. "too" opinionated is not the same as "not having opinions at all"
<mikecmpbll> installing rubocop and have no immediate effect would be fucking stupid.
<eam> you are swinging between absolutes
<eam> no one is suggesting those things
<eam> calm down
<mikecmpbll> because the middleground between those absolutes is called "opinion"
<mikecmpbll> you disagree with opinion
<eam> and the criticism is that there is too much opinion
<eam> here check this out
<eam> we live in a beautiful world full of color
<eam> so
<eam> try to see past the two black and white tones you're currently considering
<eam> it is possible for something to be "less opinionated" without having no opinion whatsoever
<mikecmpbll> how can you grade an amount of opinion?
<mikecmpbll> either you make a decision about something, i.e. should we have spaces before {} or not?
<mikecmpbll> or you choose not to have an opinion on it
<mikecmpbll> you can't have half an opinion
<eam> I literally just did
<eam> and I even gave you a specific example
<jrich523> lol
kmurphy4 has joined #ruby
<jrich523> you're both right (or wrong)
<mikecmpbll> ah, so you think they should make fewer decisions? so they should have a default about spaces before braces, but not about %w[] vs %w()?
<mikecmpbll> i understand you now
<mikecmpbll> i really don't see what additional value that provides
cconstantine has quit [Quit: cconstantine]
<mikecmpbll> it just means more people don't realise there's a cop for %w() vs %w[]
<eam> 20:23 < eam> if they were less opinionated we might be able to establish a widely agreed upon common subset!
<mikecmpbll> and fewer projects have a comprehensive style guide.
<mikecmpbll> i don't understand how fewer opinions can result in more agreement?
<jrich523> fewer differing opinions
<mikecmpbll> so more indecision?
cconstantine has joined #ruby
<jrich523> hmm more decision?
<eam> have you ever used perltidy? The tool rubocop was patterened after?
<mikecmpbll> more decision is more opinion.
<jrich523> room of 10 people... "everyone pick the best color" 8 people pick green
<jrich523> screw the other two
<jrich523> its green
<mikecmpbll> eam : yes
<jrich523> we decided, two other people have a differing opinion, but who cares, its a small % of the group
<eam> that's an example of a more reasonable set of defaults
<mikecmpbll> eam : how so?
<jrich523> which is what this set of defaults SHOULD be
<jrich523> i have no idea if they are, cuz im new to ruby :)
kmurphy4 has quit [Remote host closed the connection]
<eam> it has a *ton* of rules which aren't on at default levels
<eam> rubocop is (afaik) missing the concept of severity/opinion levels entirely
<eam> perltidy at the highest level is kinda dumb, most folks don't agree with it
<eam> but almost everyone agrees with the lower level stuff
dionysus69 has quit [Ping timeout: 260 seconds]
cconstantine has quit [Client Quit]
<mikecmpbll> what do you mean at the highest level?
BTRE has joined #ruby
cconstantine has joined #ruby
banisterfiend has joined #ruby
<jrich523> the more obscure sugestions im guessing
<jrich523> like only 10% of the rules are agreed upon as "must"
<jrich523> but the default rule set has 15% of them
<jrich523> 5% that eam thinks (and many others?) a bit much for the default set
reber has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 240 seconds]
cconstantine has quit [Client Quit]
<mikecmpbll> can debate ad-infinitum about defaults, it's pretty fucking inconsequential—just configure it how you want.
nicht has quit [Ping timeout: 245 seconds]
<jrich523> its very consequential for people me... i use it as a guide to "good ruby"
<mikecmpbll> then follow it?
<jrich523> but, not something that will be chaned here :)
<jrich523> oh i do
<jrich523> and i'll learn better at some point
<mikecmpbll> either it's a good guide and you follow it, or it's not and you don't.
<jrich523> but its a good starting point
<mikecmpbll> pick one.
<mikecmpbll> they're both as easy as the other.
<jrich523> both? use or not use? clearly its easier to use :)
<jrich523> otherwise i have to paste my lines here and be like "how do i make this pile of crap more ruby like"
<jrich523> and ya'll will get sick of that real quick :)
jenrzzz has quit [Ping timeout: 264 seconds]
cconstantine has joined #ruby
<eam> mikecmpbll: sorry, meeting - I meant perlcritic btw, not perltidy
<eam> it has a concept of severity, ranging from 1 to 5
jottr has joined #ruby
<eam> severity 5 is stuff that is almost certainly an error, or will be actively dangerous
<eam> as you move towards 1 you go more towards subjective opinion
fmcgeough has quit [Quit: fmcgeough]
<mikecmpbll> sounds like a worthless abstraction. the project maintainer can decide what's right or wrong for that project, what's the need for a ranking once you've chosen your path?
<mikecmpbll> merge request comes in, it has five level 1 failures, they're not severe so do you merge it?
<eam> it's pretty important, because some things are almost certainly errors that a linter should catch (eg, assignment in what appears to be a test)
<eam> the default is level 5
<eam> the default is almost certainly indicative of a real problem, a real error
<mikecmpbll> why would anything be merged with issues though? what's the point of the grading?
<eam> then there are increasingly pedantic and opinionated sets of criticisms which you can use if you like
cconstantine has quit [Client Quit]
<eam> because the authors recognize the gradient of subjective opinion
<eam> iirc we ran most of our projects on level 3 or so
<eam> with a set of additional critics
<eam> 4/5 were too opinionated
<mikecmpbll> so ultimately the project maintainer chooses a level; practically no different from configuring rubocop
pastorinni has joined #ruby
<eam> rubocop, by default, makes it hard to distinguish between important syntax problems and silly ones
<eam> again, we are discussing useful defaults
<mikecmpbll> no we're not, because you said the maintainer chooses a level
<mikecmpbll> that's not a default, that's a choice.
ur5us has joined #ruby
<eam> no, I did not say that
<eam> and that isn't how it works
<eam> the default is the lowest level
<cthulchu> do I have a console here?
<mikecmpbll> [21:45:46] <eam>then there are increasingly pedantic and opinionated sets of criticisms which __you can use if you like__
<eam> are you struggling to understand what a default is? is that the issue here?
<mikecmpbll> no
<eam> then I'm not sure why we're having trouble communicating
<mikecmpbll> me neither.
redlegion[m] has quit [Remote host closed the connection]
haylon_ has quit [Remote host closed the connection]
jonjits[m] has quit [Remote host closed the connection]
Hanma[m] has quit [Write error: Connection reset by peer]
iceskins[m] has quit [Remote host closed the connection]
Giphy[m] has quit [Read error: Connection reset by peer]
luna_x[m] has quit [Remote host closed the connection]
<eam> that's it!
<eam> I wish rubocop had more sensible defaults
intheclouddan has quit [Read error: Connection reset by peer]
KevinMGranger has quit [Write error: Connection reset by peer]
<cthulchu> >> puts test
<cthulchu> n> puts test
velu_aon[m] has quit [Write error: Connection reset by peer]
zalipuha[m] has quit [Remote host closed the connection]
aviraldg has quit [Write error: Connection reset by peer]
<ruby[bot]> cthulchu: # => wrong number of arguments (given 0, expected 2..3) (ArgumentError) ...check link for more (https://eval.in/1020120)
jcarl43 has quit [Max SendQ exceeded]
<eam> the ranking of severity is also useful, I think, because it indicates to a newbie whether the style is a pure style issue or a possible serious mistake
turt2live has quit [Write error: Connection reset by peer]
bascht has quit [Remote host closed the connection]
jcarl43 has joined #ruby
lytol has quit [Remote host closed the connection]
moei has quit [Quit: Leaving...]
lytol has joined #ruby
mtkd has quit []
tekk has quit [Ping timeout: 264 seconds]
ciscam has quit [Ping timeout: 240 seconds]
<mikecmpbll> the "lint" cops in rubocop are for syntax and code errors, you can easily just run those on their own
headius has quit [Ping timeout: 240 seconds]
synthroid has quit []
ciscam has joined #ruby
headius has joined #ruby
braindead_ has quit [Quit: Page closed]
<cthulchu> wow
<cthulchu> looks like << is A LOT more performant than +
jenrzzz has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
karuna has quit [Quit: Connection closed for inactivity]
tekk has joined #ruby
jcalla has quit [Quit: Leaving]
noron99 has quit [Quit: Leaving]
cconstantine has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ramfjord_ has quit [Ping timeout: 260 seconds]
sameerynho has quit [Ping timeout: 264 seconds]
grilix_ has quit [Ping timeout: 264 seconds]
intheclouddan has joined #ruby
aufi has quit [Quit: Leaving]
banisterfiend has joined #ruby
chat has joined #ruby
subroot has quit [Read error: Connection reset by peer]
karapetyan has quit [Remote host closed the connection]
chat_ has quit [Ping timeout: 248 seconds]
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Changing host]
jenrzzz has joined #ruby
ldnunes has quit [Quit: Leaving]
dbugger__ has quit [Ping timeout: 264 seconds]
ramfjord has joined #ruby
oncall-pokemon has quit [Quit: Connection closed for inactivity]
Rapture has quit [Quit: Textual IRC Client: www.textualapp.com]
amelliaa has quit [Quit: -]
za1b1tsu has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
za1b1tsu has quit [Ping timeout: 260 seconds]
pastorinni has quit [Remote host closed the connection]
rabajaj has quit [Quit: Leaving]
nfk has quit [Remote host closed the connection]
jottr has quit [Ping timeout: 264 seconds]
<jrich523> hey guys... so im trying to filter my array of hashes..
orbyt_ has joined #ruby
<jrich523> and im getting an error about nil, but im certain this field has a value in all instnaces (i printed it out without the filter)
<jrich523> kvms = kvms.select { |h| options[:site].casecmp(h['site']).zero? } unless options[:site].nil? thats the dirty bit of code i came up with (mostly rubocopy)
<jrich523> but its basically saying that the h['site'] is nil, which makes me feel like im doing something wrong, cuz it shouldnt have any nil values
<baweaver> "shouldn't" is a very dangerous word
<jrich523> well, im as sure as i can be
<baweaver> Always verify
<jrich523> i ran an arr.each with puts
<jrich523> no empty "site" values
<jrich523> so, to that end, im sure
<baweaver> If your interpreter said there's a nil...
<jrich523> i dont know ruby enough to know if there is some black magic im missing :)
<baweaver> That's the thing, there's really not that much magic.
<apeiros> you could also have misread the exception
<jrich523> true
<jrich523> i wrote it both ways (H to opions, options to h)
<jrich523> to identify that its really angry about the h['site'] being nil
<apeiros> anyway, you can try to reduce kvm's values to a small set which still causes the error
<jrich523> cant find a method, vs cant compare to nil
<apeiros> and when you have that, paste it
<jrich523> im not sure i follow you?
<apeiros> how many items are in kvms?
<jrich523> under 100
<apeiros> bisect it
<apeiros> run it for 50, see if it crashes. if not, run it for the other 50
<apeiros> then in the crashing half, run it for 25, etc.
<jrich523> basically, tease out which record is causing the issue?
<apeiros> alternatively:
<baweaver> you sure about that being a string key?
<baweaver> options[:site] and h['site']
<apeiros> have a begin/rescue with binding.pry inside your select
weaksauce has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<baweaver> If it says no method for nil, it means the left side is nil. Can't compare to nil means something on the right side of casecmp.
<baweaver> short version: there's a nil.
<jrich523> options[:site] is the param passed in (optparser) so --site abc
workmad3 has joined #ruby
<jrich523> ok, i guess mostly i wanted to make sure that in some weird way my H wasnt something else or wrong
fmcgeough has joined #ruby
<jrich523> i'll start to rip apart the data
<apeiros> btw., `unless options[:site].nil?` --> `if options[:site]`
<jrich523> yeah should have changed that before i posted it..
jottr has joined #ruby
<jrich523> im doing something horribly wrong
<cthulchu> will it tolerate if I pass arguments in a method/function that don't expect arguments?
<cthulchu> is it that good?
<cthulchu> to idnore them
<jrich523> oh come on now, thats something you should try
<cthulchu> you're corrupting me
<jrich523> dont forget to report back, im curious :)
<cthulchu> :(
<cthulchu> can I do it here with the >>?
<cthulchu> I'm not good enough with my ruby instance
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jrich523> probably
workmad3 has quit [Ping timeout: 255 seconds]
<jrich523> so... i tried this...
<jrich523> kvms.each_index {|x| puts "#{x} -#{kvms[x]['site']}-" }
<cthulchu> >> def a(){} a(1,2,3)
<ruby[bot]> cthulchu: # => /tmp/execpad-487594caa717/source-487594caa717:2: syntax error, unexpected tIDENTIFIER, expecting key ...check link for more (https://eval.in/1020158)
<jrich523> and i get -- (all nil, wtf?)
<jrich523> that answers that one :)
<baweaver> cthulchu: Try it locally first.
<cthulchu> I kinda can't
<jrich523> i use the site in another puts ok, (let me trim it down)
<baweaver> Why?
<cthulchu> I don't feel familiar enough with it
<baweaver> Just use irb.
<cthulchu> but what I did here, did I do it right?
<jrich523> kvms.each do |k| puts ' %<site>s ' % k end
<jrich523> that will use my site ok
<cthulchu> how do we do >> here?
Zaab1t has quit [Quit: Zaab1t]
<cthulchu> holy crap
<cthulchu> how does irb work?
<jrich523> what do you mean?
<jrich523> lol
<jrich523> quit
<cthulchu> how do I get the output though
<jrich523> it should echo by default
<jrich523> which happens to be super annoying lol
<cthulchu> omg
<jrich523> start simple: 1+ 2
<jrich523> it will echo the result
<cthulchu> this is weird
<jrich523> a = 1 + 2
zenspider has quit [Changing host]
zenspider has joined #ruby
<jrich523> still echo's (sort of annoying, you can disable it)
<jrich523> oh
<cthulchu> it doesn't work
pskosinski has quit [Ping timeout: 240 seconds]
<jrich523> see the ? on line 2
<cthulchu> yes
<jrich523> thats a sub command i think
<jrich523> sorta like a missing }
<cthulchu> okay, I'm done with it
kmurphy4 has joined #ruby
<cthulchu> I don't have missing }
<jrich523> also you rammed too much on a line
gravitation has joined #ruby
gravitation has quit [Read error: Connection reset by peer]
<jrich523> you have a missing ;
<jrich523> or a new line :)
<cthulchu> oh
<jrich523> just guessing anyways
<cthulchu> that makes sense
<jrich523> you joined up the def and use
<jrich523> so to use it here, it might work if you toss a ; between the def/call
karapetyan has joined #ruby
gravitation has joined #ruby
gravitation has quit [Read error: Connection reset by peer]
nfk has joined #ruby
<jrich523> weird
Mia has quit [Read error: Connection reset by peer]
<cthulchu> baweaver, how do you use irb?
<cthulchu> feels like vim
gravitation has joined #ruby
<cthulchu> kek
gravitation has quit [Read error: Connection reset by peer]
<jrich523> mine is a tad different (more obvious maybe?)
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
<apeiros> cthulchu: def a(){} isn't really something
<baweaver> I'd almost suggest reading a Ruby book by this point.
<cthulchu> if it's not something, I expect a syntax error
<cthulchu> ah, it's like literally nothing
gravitation has joined #ruby
<apeiros> it's in some kind of continuation mode where it expects more input to complete an expression
<cthulchu> so the output is empty
<cthulchu> lol
<cthulchu> okay
<apeiros> type "end" and you get your syntax error ;-)
<cthulchu> no
<cthulchu> I don't need end
<cthulchu> I have }
WAFFLEMAKER3000 has quit [Ping timeout: 256 seconds]
<cthulchu> isn't it the same?
TinkerT has quit [Quit: ZNC 1.8.x-nightly-20180512-bc7a2176 - https://znc.in]
<baweaver> No.
<cthulchu> what?
agent_white has quit [Remote host closed the connection]
<apeiros> with blocks, you can use {} or do/end
<apeiros> but even there it's not the same.
<cthulchu> omg
<apeiros> but you can't with method defs.
<jrich523> lol love me some ruby
<apeiros> there's no `do` in a method def.
<cthulchu> aaaaah
agent_white has joined #ruby
<cthulchu> so I can't do it with deeefs
<cthulchu> now it makes sense
<cthulchu> ha!
Azure has joined #ruby
<cthulchu> okay, so it's not possible to do what I want in one line
<apeiros> cthulchu: btw., change the prompt to show nesting level
<cthulchu> not gonna do it then
<cthulchu> it shows me the nesting level
<apeiros> jrich523 apparently has set theirs
TinkerT has joined #ruby
<cthulchu> using spaces
<jrich523> i did not, was default
<cthulchu> yep
<jrich523> only thing i screwed with was the echo
<apeiros> jrich523: well, your last number is the nesting level
<apeiros> :1>
<jrich523> yup
<jrich523> figured that out the hardway already :)
<jrich523> super helpful tho
<apeiros> shows that you're 1 level nested and hence your expression is not completed
<jrich523> however, back to the topic of {} / do/end
<apeiros> anyway, IMO use pry anyway.
<cthulchu> okay, dolks, could you please test it quickly for me?
<jrich523> shouldnt mine be ok?
<cthulchu> I have real issues with irb
<cthulchu> *folks
<apeiros> jrich523: in your jpg?
<jrich523> check out pry
<jrich523> yeah, the def a { puts "ran" }
<apeiros> 00:03 apeiros: there's no `do` in a method def.
<jrich523> why is it continued?
<cthulchu> cuz you can't use {} with def
<jrich523> but the {} vs do/end
<cthulchu> we explained it
schleppel has quit [Quit: Konversation terminated!]
<cthulchu> you don't have do in def
<cthulchu> there's no {
TinkerT has quit [Client Quit]
<jrich523> so its not either, its only do/end?
<apeiros> jrich523: I have no idea what irb sees to be continued
<cthulchu> indeed
<cthulchu> it's only def/end when it's def
<cthulchu> you can use {} when it's do/end
<cthulchu> apparently
<cthulchu> from what I understood
TinkerT has joined #ruby
<apeiros> cthulchu: yes, and do/end is only with blocks :)
<cthulchu> I wonder if I still need new lines when doing def/end
<cthulchu> I consider def/end a block
<jrich523> irb wanted it... got grumpy at me
<apeiros> >> def foo(x) x+2 end; foo(1) # no newline needed, not even ;
<ruby[bot]> apeiros: # => 3 (https://eval.in/1020161)
<cthulchu> oh cool
<cthulchu> not even ;?!
<cthulchu> how so
<cthulchu> errr
<apeiros> in a couple of cases when it's unambiguous
amar_ has quit [Remote host closed the connection]
moei has joined #ruby
<cthulchu> >> def a() true end; a(1)
<ruby[bot]> cthulchu: # => wrong number of arguments (given 1, expected 0) (ArgumentError) ...check link for more (https://eval.in/1020162)
<cthulchu> impossible!
<cthulchu> signatures are real!
<cthulchu> woohooo!
<cthulchu> you can pass less, but don't you dare to pass more!!!
<cthulchu> arrrrr
<jrich523> damn it... i think i know what my issue was :-/
bauruine has quit [Ping timeout: 245 seconds]
<jrich523> btw, pry is suppose to be a lot better than irb
<cthulchu> JS allows it!
<cthulchu> ha!
<jrich523> which i would be using, except its not very friendly with bundler
<apeiros> huh?
<apeiros> in what way is pry not bundler-friendly?
<jrich523> let me grab the error
<jrich523> i have a gem i have to work in, so to work in it i've had to do: bundle exec ruby /bin/blah
<jrich523> so i replace that with irb to get all the local gem dependencies
<cthulchu> Ruby is not as hippy and goofy as it seems. It pretends!
<jrich523> bundle exec ruby irb
<jrich523> which will let me require whatever is in this gem
<jrich523> pry gave an error, let me try it again
<apeiros> you mean `bundle exec irb`, yes?
<jrich523> oh, it cant find it, but if i use just pry on the cmdline it works
amar has joined #ruby
amar has quit [Remote host closed the connection]
<jrich523> im windows
<jrich523> :-/
jottr has quit [Ping timeout: 245 seconds]
<jrich523> so yeah, same thing.. sorta...
<apeiros> did you do `bundle exec ruby pry`? if so, that's wrong.
<jrich523> bundler/rubygems_integration.rb:458:in `block in replace_bin_path': can't find executable pry for gem pry. pry is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
<jrich523> a "better" error without the `ruby`
<apeiros> tells you straight what I forgot to do
<apeiros> you apparently didn't list pry in your gemfile.
<jrich523> well, i wouldnt actually want it in there
<apeiros> errrr
<jrich523> i mean, yes i can screw with it to get it working
<apeiros> what's not in the gemfile can't be used with bundler
<apeiros> that's… like… the point of bundler.
<jrich523> irb can just fine it seems
<jrich523> but irb is an executable im guessing? vs a gem?
<apeiros> because irb isn't a gem.
<jrich523> i figured thats what hte issue was
<jrich523> just didnt really bother to find a fix
<jrich523> since it didnt seem to offer THAT much
<apeiros> if you develop a gem, what you do is you add pry as a development dependency
<apeiros> and in your gemfile, you reference the gemspec
TinkerT has quit [Quit: ZNC 1.8.x-nightly-20180512-bc7a2176 - https://znc.in]
pskosinski has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TinkerT has joined #ruby
weaksauce has joined #ruby
<jrich523> yeah i had seen the dev dependencies.. but.. the only reason i was trying pry was to get better/clean inspect output.. so... i just sucked it up and read the horrible garbage it spewed out lol
<apeiros> though, since all that matters to a gem when publishing is the gemspec, it's fine to just put it into the gemfile.
bauruine has joined #ruby
<jrich523> ugh, im an idiot
banisterfiend has joined #ruby
<jrich523> it wasnt working because i had switched from strings to symbols for hash keys
<jrich523> so of course, ['site'] wont work
EvilJStoker has quit [Remote host closed the connection]
karapetyan has quit [Remote host closed the connection]
fmcgeough has quit [Quit: fmcgeough]
fmcgeough has joined #ruby
kt has joined #ruby
fmcgeough has quit [Client Quit]
EvilJStoker has joined #ruby
cschneid has quit [Remote host closed the connection]
samort7 has joined #ruby
pankaj has joined #ruby
<pankaj> I am using linux and I have ruby and ruby docs installed on my system. But sometimes I have to find about the functionality about a function. How to find that using docs and docs?
chouhoulis has quit [Remote host closed the connection]
weaksauce has quit [Read error: Connection reset by peer]
chouhoulis has joined #ruby
WAFFLEMAKER3000 has joined #ruby
<zenspider> pankaj: try `ri Array.join` in your terminal
chouhoul_ has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
chouhou__ has joined #ruby
ramfjord has joined #ruby
chouho___ has joined #ruby
WAFFLEMAKER3000 has quit [Ping timeout: 240 seconds]
chouhoulis has quit [Ping timeout: 240 seconds]
chouhoulis has joined #ruby
shinnya has joined #ruby
wontruefree has quit [Quit: bye]
desperek has quit [Quit: xoxo]
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
chouh____ has joined #ruby
chouhoul_ has quit [Ping timeout: 264 seconds]
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 240 seconds]
chouho___ has quit [Ping timeout: 240 seconds]
ramfjord has quit [Ping timeout: 260 seconds]
chouhou__ has joined #ruby
chouho___ has joined #ruby
ramfjord has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
chris349 has joined #ruby
<chris349> I try to do a bundle install as non-root user, because when you run as root it gives you warning to NOT run as root
chouh____ has quit [Ping timeout: 260 seconds]
chouh____ has joined #ruby
orbyt_ has joined #ruby
<jrich523> but when you dont run as root it fails :)
chouhoul_ has quit [Ping timeout: 255 seconds]
<chris349> But then it pops up a prompt asking for the "password" (not clear which "password" is needed). I type my system user password, but then it says: Gem::FilePermissionError: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.1.2/wrappers directory
<chris349> But if I use sudo I can use the command it gives to install that one particular gem
<chris349> But then bundle install gets stuck and I need to run a sudo command to manually install the next gem
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 255 seconds]
<chris349> So how can I configure the bundle install sudo/password prompt to work correctly and install the gem, instead of failing
mikecmpbll has quit [Quit: inabit. zz.]
<darix> chris349: gem install --user-install maybe?
<darix> you dont need to install into the system path
chouhou__ has joined #ruby
chouho___ has quit [Ping timeout: 264 seconds]
ramfjord has quit [Ping timeout: 264 seconds]
ellcs has quit [Ping timeout: 268 seconds]
chouho___ has joined #ruby
chouhoulis has quit [Ping timeout: 264 seconds]
<chris349> What is the difference between --user-install and --path vendor/bundle? Which is better?
<chris349> And if it warns to me run as root why does it fail as non-root? Shouldnt it just work?
<darix> chris349: for a rails app the 2nd is probably better
chouhoulis has joined #ruby
chouh____ has quit [Ping timeout: 256 seconds]
sanscoeur has quit [Ping timeout: 245 seconds]
chouh____ has joined #ruby
chouhoul_ has quit [Ping timeout: 256 seconds]
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 264 seconds]
chouhou__ has joined #ruby
chouho___ has quit [Ping timeout: 264 seconds]
chouho___ has joined #ruby
chouhoulis has quit [Ping timeout: 255 seconds]
chouh____ has quit [Ping timeout: 245 seconds]
chouhoulis has joined #ruby
gravitation has quit [Quit: gravitation]
chouh____ has joined #ruby
chouhoul_ has quit [Ping timeout: 245 seconds]
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 245 seconds]
chouhou__ has joined #ruby
chouho___ has quit [Ping timeout: 240 seconds]
chouho___ has joined #ruby
ramfjord has joined #ruby
chouhoulis has quit [Ping timeout: 256 seconds]
chouhoulis has joined #ruby
chouh____ has quit [Ping timeout: 276 seconds]
chouh____ has joined #ruby
chouhoul_ has quit [Ping timeout: 260 seconds]
za1b1tsu has joined #ruby
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 245 seconds]
chouhou__ has joined #ruby
chouho___ has quit [Ping timeout: 260 seconds]
chouho___ has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
ellcs has joined #ruby
ramfjord has quit [Ping timeout: 276 seconds]
jenrzzz has quit [Ping timeout: 265 seconds]
chouhoulis has joined #ruby
jenrzzz has joined #ruby
za1b1tsu has quit [Ping timeout: 264 seconds]
chouh____ has quit [Ping timeout: 276 seconds]
chouh____ has joined #ruby
intheclouddan has quit [Remote host closed the connection]
chouhoul_ has quit [Ping timeout: 259 seconds]
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 264 seconds]
RougeR has joined #ruby
RougeR has joined #ruby
RougeR has quit [Changing host]
chouhou__ has joined #ruby
chouho___ has quit [Ping timeout: 256 seconds]
chouho___ has joined #ruby
chouhoulis has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
cschneid has joined #ruby
chouh____ has quit [Ping timeout: 245 seconds]
chouhoul_ has quit [Ping timeout: 245 seconds]
chouh____ has joined #ruby
ellcs has quit [Ping timeout: 256 seconds]
chouhoul_ has joined #ruby
gigetoo has quit [Ping timeout: 240 seconds]
chouhou__ has quit [Ping timeout: 260 seconds]
chouhou__ has joined #ruby
chou_____ has joined #ruby
chouho___ has quit [Ping timeout: 276 seconds]
cschneid has quit [Ping timeout: 256 seconds]
chouhoulis has quit [Ping timeout: 255 seconds]
chouhoulis has joined #ruby
chouh____ has quit [Ping timeout: 256 seconds]
chouho___ has joined #ruby
chouhoul_ has quit [Ping timeout: 255 seconds]
karapetyan has joined #ruby
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 256 seconds]
chouhou__ has joined #ruby
chou_____ has quit [Ping timeout: 255 seconds]
chouh____ has joined #ruby
Puffball has quit [Quit: Puffball]
chouhoulis has quit [Ping timeout: 255 seconds]
chouhoulis has joined #ruby
chouho___ has quit [Ping timeout: 245 seconds]
bambanx has joined #ruby
karapetyan has quit [Ping timeout: 240 seconds]
tdy has joined #ruby
bambanx has quit [Remote host closed the connection]
kt has quit [Ping timeout: 256 seconds]
Kensei has joined #ruby
chouho___ has joined #ruby
<cthulchu> folks, I don't need to have classes. I can have a file that only has one line like rules = [{type:"dl",test:"signup",step:"success submission"}] and now when I require it, I have instant access to rules
<cthulchu> right?
chouhoul_ has quit [Ping timeout: 255 seconds]
chouhoul_ has joined #ruby
<Kensei> the default regexp delimiter is '/', as in a lot of other languages. i.e., /foo/.class => Regexp. this can be overridden with %r (e.g., %r!foo!.class => Regexp)
chouhou__ has quit [Ping timeout: 255 seconds]
kt has joined #ruby
chouhou__ has joined #ruby
chouh____ has quit [Ping timeout: 256 seconds]
<Kensei> but /foo/.to_s => '(?-mix:foo)'. is there any way to stringify /foo/ back to "/foo/" ?
gigetoo has joined #ruby
<cthulchu> errr
<havenwood> cthulchu: nope
<cthulchu> why do you tostring a regex?
chouh____ has joined #ruby
<cthulchu> havenwood, why?
chouhoulis has quit [Ping timeout: 256 seconds]
<Kensei> because i need to express it into workable JSON to be passed to mongo
chouho___ has quit [Ping timeout: 240 seconds]
intheclouddan has joined #ruby
<havenwood> cthulchu: the local variable wouldn't be available from the requiring binding
chouhoulis has joined #ruby
<havenwood> cthulchu: try it
<cthulchu> weird
<cthulchu> how do I make it accessible?
jcarl43 has quit [Quit: WeeChat 2.1]
<cthulchu> how do I make it global, I guess
<Kensei> i need to turn {'expr' => /dev/} => '{"expr":/dev/}'
<cthulchu> cuz I don't care, I need a file with json to be imported
chouho___ has joined #ruby
<cthulchu> I figured having a file with json in a variable will do the trick
chouhoul_ has quit [Ping timeout: 256 seconds]
<havenwood> Kensei: /foo/.source #=> "foo"
chouhou__ has quit [Ping timeout: 245 seconds]
chouhoul_ has joined #ruby
<havenwood> Kensei: Where's the input coming from? Is it trusted?
<Kensei> havenwood: that's not a regexp, it's a string. i need the / delimiters added.
chouhou__ has joined #ruby
<havenwood> Kensei: I just realized what you were wanting when you added the JSON example.
chouh____ has quit [Ping timeout: 240 seconds]
<havenwood> Kensei: Is it trusted input?
<havenwood> Kensei: require 'json/add/regexp'
<Kensei> it will be sanitised.
<havenwood> >> require 'json/add/regexp'; JSON.load({'expr' => /dev/}.to_json)
<ruby[bot]> havenwood: # => {"expr"=>/dev/} (https://eval.in/1020170)
chouh____ has joined #ruby
<havenwood> Kensei: ^
<havenwood> Kensei: It's a little-known feature of JSON in Ruby, but it requires using JSON::load instead of ::parse.
chouhoulis has quit [Ping timeout: 256 seconds]
<Kensei> but that's a hash, not JSON. the output needs to be {"expr":/dev/}
chouhoulis has joined #ruby
chouho___ has quit [Ping timeout: 260 seconds]
<havenwood> Kensei: What is it? Just a String format?
<Kensei> it's weird that // is the default make-an-re operator, but there's no way to get back to it.
<Kensei> yes.
<havenwood> >> {'expr' => /dev/}.inspect # Kensei
<ruby[bot]> havenwood: # => "{\"expr\"=>/dev/}" (https://eval.in/1020171)
chouho___ has joined #ruby
chouhoul_ has quit [Ping timeout: 256 seconds]
<Kensei> still got '=>' not ':'
<havenwood> Kensei: that'd turn the String into a Symbol - I guess say more about what this is?
<Kensei> no, because it's ':' inside a string.
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 256 seconds]
<havenwood> ok
<Kensei> convert hash {'expr'=>/dev/} to string '{"expr":/dev/}'
<havenwood> >> {'expr' => /dev/}.inspect.gsub('=>', ':') # Kensei
<ruby[bot]> havenwood: # => "{\"expr\":/dev/}" (https://eval.in/1020172)
<havenwood> Kensei: Why?
chouh____ has quit [Ping timeout: 245 seconds]
nicht has joined #ruby
<havenwood> It's some kinda pseudo-JSON? Whatcha doing with it?
chouhou__ has joined #ruby
cconstantine has quit [Quit: cconstantine]
chouhoulis has quit [Ping timeout: 240 seconds]
chouh____ has joined #ruby
DroidBurgundy has joined #ruby
<Kensei> no, it's valid JSON. in jscript in the mongo shell, for example: db.coll.find({"expr":/dev/})
<havenwood> Kensei: It's near impossible to give you a proper solution with what you've specified. I mean the above matches your required output. Can all Hash rockets simply be turned into colons?
chouhoulis has joined #ruby
<Kensei> in ruby the selector is {'expr'=>/dev/}. i need to turn the ruby structure into something that can be used in jscript
chouho___ has quit [Ping timeout: 255 seconds]
<Kensei> >> {'expr'=>/dev/}.to_json
<ruby[bot]> Kensei: # => undefined method `to_json' for {"expr"=>/dev/}:Hash ...check link for more (https://eval.in/1020173)
chouho___ has joined #ruby
chouhoul_ has quit [Ping timeout: 240 seconds]
<Kensei> (never used that before, followed your example)
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 245 seconds]
workmad3 has joined #ruby
<Kensei> so there's nothing in ruby that turns a Regexp instance back into something using the default delimiters.
chouhou__ has joined #ruby
chouh____ has quit [Ping timeout: 260 seconds]
<Kensei> thing is, the selector might be a deep structure, and i would rather not have to walk it to make the conversions.
<cthulchu> how do we require a json file and cast it into an object?
chouh____ has joined #ruby
<havenwood> cthulchu: Read the file and JSON.parse it.
chouhoulis has quit [Ping timeout: 245 seconds]
<havenwood> cthulchu: Read the JSON docs.
<cthulchu> wow
<cthulchu> just like in js
<cthulchu> can I require it instead?
<Kensei> okey, next question. is there a way to marshal a complete context such that it can be resumed after a Marshal.load ?
<cthulchu> I really don't like explicit FS
<cthulchu> stuff
<havenwood> Kensei: You can create your own JSON serializer for Regexp, since Ruby supports that, but Regexp literals aren't valid JSON.
chouhoulis has joined #ruby
<Kensei> JSON.parse(File.read('foo.json'))
<cthulchu> wow
<cthulchu> really
<cthulchu> no way
<cthulchu> can't be that easy
chouho___ has quit [Ping timeout: 255 seconds]
<cthulchu> is that path relative?
<Kensei> i do it all the time
<cthulchu> so it is?
<cthulchu> and does it have to be valid json?
chouho___ has joined #ruby
<cthulchu> ^joke^
<cthulchu> hehe
chouhoul_ has quit [Ping timeout: 256 seconds]
<Kensei> cthulchu: well, you can wrap it in a rescue block..
<cthulchu> wow
<cthulchu> no need, but wow
workmad3 has quit [Ping timeout: 245 seconds]
chouhoul_ has joined #ruby
chouhou__ has quit [Ping timeout: 245 seconds]
chouhou__ has joined #ruby
chouh____ has quit [Ping timeout: 256 seconds]
wontruefree has joined #ruby
chouh____ has joined #ruby
gigetoo has quit [Ping timeout: 255 seconds]
chouhoulis has quit [Ping timeout: 260 seconds]
chouhoulis has joined #ruby
chouho___ has quit [Ping timeout: 260 seconds]
chouho___ has joined #ruby
<Kensei> havenwood: so javascript considers {"expr":/dev/} valid, but it's not valid JSON?
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]