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
<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]
<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)
<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.
<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 ^.^
<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
<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.
<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
<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(',')
<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
<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
<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`
<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]
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)]
<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
<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?
<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 +
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
<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
<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.
<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…]