<galaxie>
mroutis: Is this supposed to do what I thought it was? It shouldn't exit unless there is at least one error: rubocop -P -E --fail-level E --format emacs FILE -c CONFIG_FILE
<havenwood>
?guys this_dude
<ruby[bot]>
this_dude: Though inclusion was probably intended, not everyone relates to being "one of the guys". Maybe consider using "folks", "all", "y'all", or "everyone" instead?
<this_dude>
i feel like y'all shouldve been philosophy majors
<havenwood>
this_dude: I was a philosophy major.
<this_dude>
i forgot havenwoods name is sarah
<blood>
Currently with xml_fragment, it will call the remove_tag method which calls the REXML code as you see in gist. This only removes the element matched but will leave the parent empty
<this_dude>
MAKES SENSE
<havenwood>
this_dude: my name is shannon
<this_dude>
yeah that...i apologize
<blood>
I tried to review the ruby docs but couldn't find anything on how to remove a parent element
<galaxie>
mroutis: Also, it's still sorting by line number, not severity
<this_dude>
ooo heres something idk
<this_dude>
how do you return a sum in ruby in terms of binary
<mroutis>
galaxie, can't tell, sorry :/
<al2o3-cr>
this_dude: how'd you mean?
<galaxie>
mroutis: Any experience with Syntastic/Vim?
goez has joined #ruby
chouhoulis has quit [Read error: Connection reset by peer]
cagomez_ has quit [Ping timeout: 248 seconds]
<this_dude>
like
<this_dude>
i want to add two integers and return their sum in binary
<this_dude>
for example
<mroutis>
no, galaxie, I use vim but not syntastic
<this_dude>
sum = a + b
<this_dude>
but..
<this_dude>
i want sum in binary
<mroutis>
you could try debugging by running rubocop outside of vim, without syntastic
<havenwood>
this_dude: my little code dojo in Topanga was the original code wars dojo ;-)
<galaxie>
mroutis: What do you use, then?
<this_dude>
.to_s(2)
<this_dude>
whats that do
<this_dude>
isnt .to_s converstion of an array to a string
<this_dude>
conversion*
<havenwood>
this_dude: It's explicit conversion from anything to a String.
<havenwood>
this_dude: (Not Array.)
<this_dude>
oh
<this_dude>
well
<havenwood>
[].to_s #=> "[]"
<this_dude>
how does that return binary
<mroutis>
when I'm about to open a PR, I run rubocop to tests for style issues, galaxie
<blood>
mroutis: if you need more information let me know =) Thanks!
<this_dude>
is the 2 a definition of the string in terms of base 2?
Creatornator has joined #ruby
<al2o3-cr>
this_dude: representation
<mroutis>
yep, blood, sorry, actually, I didn't understood what you were trying to achieve; you have two operations, right? extracting the content from the XML and modifying the XML, right?
<blood>
So when using REXML, it will remove the matched element from xml properly but it doesn't handle the parent (assuming the parent isn't root)
<havenwood>
this_dude: "10".to_i(2) #=> 2
<blood>
I'm trying to match an element based on a value and have it remove all elements including children up to root
<havenwood>
this_dude: Or strict conversion: Integer("10", 2) #=> 2
<this_dude>
wait
<this_dude>
so i can take an integer string value and turn it into an integer in terms of other bases
jdawgaz has quit [Ping timeout: 256 seconds]
<this_dude>
so i can go back and forth
<this_dude>
thats SO COOL
<mroutis>
mhm, blood, why don't you find the parent before deleting the element and call `delete_all(parent_path)`
<mroutis>
I'm just trying to figure out what's going on, sorry if I can't help that much
<this_dude>
how do i go to the next question on this thing havenwood
<blood>
Because I only want to delete an element if a child element contains a value I specify. So when a child element is matched, I want to delete it as well as any parents it has up to root
<blood>
If I can do that then sure let me know =)
<havenwood>
this_dude: I don't know the question. Are you allowed direct assistance?
<blood>
I assume I should just check children on each element as I traverse then delete if it contains my criteria
<mroutis>
I think that could work, blood ^
<this_dude>
i meant after i finish one correctly
<this_dude>
theres no next button haha
<al2o3-cr>
this_dude: quick little test for you, you up for it?
<this_dude>
sure!
<this_dude>
always
<blood>
If this were java, i would be done already but just starting to work with ruby =)
<al2o3-cr>
this_dude: convert "#ff0000" into rgb constituent parts
<this_dude>
whats that
<this_dude>
rgb constituent parts
<mroutis>
I've never used REXML, always Nokogiri <3
goez has quit [Ping timeout: 240 seconds]
<al2o3-cr>
this_dude: so return an array with 3 integers
<this_dude>
isnt #ff0000 a color code lol
<al2o3-cr>
this_dude: yep
<this_dude>
nice
cthulchu_ has quit [Ping timeout: 256 seconds]
<this_dude>
anyways ok i got this
<this_dude>
gimme a sec
<blood>
mroutis: better? I'm only using REXML since it was used for this puppet module
<al2o3-cr>
this_dude: ok
<this_dude>
can i assume thats in hexidecimal since its a color code
<al2o3-cr>
it is
<this_dude>
kk
<mroutis>
can't compare, since I haven't use REXML :p
<this_dude>
>> "ff0000".to_i(16).to_a
<ruby[bot]>
this_dude: # => undefined method `to_a' for 16711680:Fixnum ...check link for more (https://eval.in/1046167)
<this_dude>
can you execute an if statement outside of a while loop?
<havenwood>
>> 'so what' if 'you can?'
<ruby[bot]>
havenwood: # => /tmp/execpad-8a9b5ab462ab/source-8a9b5ab462ab:2: warning: string literal in condition ...check link for more (https://eval.in/1046173)
<havenwood>
#=> "so what"
<this_dude>
huh
<havenwood>
this_dude: Try in irb. Or you might want to just switch to pry right away.
<Radar>
It is a good idea to write automated tests like this to test your code. You will know the input and expected outputs and you can write tests to assert that your code does exactly what it should before you submit it.
<Radar>
These tests then allow you to refactor your code after you've finished making them all pass.
<Radar>
bbl
<this_dude>
thats a little confusing...i just write the code into notepad and execute it in my command line and see if it gives the expected result after putting in a number
<this_dude>
this is where im at now...trying to take into account the other constraints about there not being allowed a space at the beginning or end of the strign result
<this_dude>
and that you can have a double space in the string result either
arescorpio has quit [Quit: Leaving.]
<this_dude>
and that you CANT have a double space in the string result either**
thy0 has quit [Quit: TTFN]
tdy has joined #ruby
[reed] has quit [Ping timeout: 268 seconds]
<this_dude>
oh wait i found an easier way to take care of the double space thing
<Radar>
this_dude: This is using a test framework called minitest
<Radar>
There are 3 tests here, that test the `is_square` function with the numbers 1, 4, and 5.
tag has quit [Quit: Connection closed for inactivity]
<Radar>
This is saying for 1 + 4, the `is_square` method should return `true` (assert). But for 5, it should return false (refute)
<Radar>
You can run this test file by saving it to a file and running `ruby thatfile.rb`
<Radar>
This will show you 3 green dots and "3 runs, 3 assertions, 0 failures", which means that it ran 3 tests, and asserted (or refuted) 3 times, and there were 0 failures.
<this_dude>
but thats for a problem i already finished
<Radar>
Ok, so adapt it to the next problem then.
<this_dude>
oh codewars is doing the same thing for me
<Radar>
I don't see a single message from you about that.
<this_dude>
so
<al2o3-cr>
Radar: i've seen it
<Radar>
enter is not a space bar.
<this_dude>
can i ss the problem?
<this_dude>
srry
shakes has quit [Quit: Leaving]
<Radar>
Sure.
<blood>
https://dpaste.de/YnGt So I'm currently traversing nodes to find a specific match and delete the parent node if found. The issue is, I'm trying to traverse children within children until a match is found or there is no more children. I can't seem to find out how to do this with REXML. Any ideas?
<this_dude>
ok heres a ss of the problem and expected input and output
<this_dude>
i need to be able to scan the string to see exactly how many "WUB"s there are and no matter how many it is only replace it with a single " "
<this_dude>
its raining and im outside gotta relocate brb
fluxAeon has joined #ruby
AJA4350 has quit [Quit: AJA4350]
<Radar>
this_dude: Ok, can you work out how to replace all the WUBs with a single space?
<Radar>
this_dude: So if I had "AWUBWUBB" That would give me "A<space><space>B"
this_dude has quit [Ping timeout: 252 seconds]
mroutis has joined #ruby
lupine has quit [Ping timeout: 255 seconds]
lupine has joined #ruby
thejs has joined #ruby
maryo_ has joined #ruby
JamJam_kid has joined #ruby
cadillac_ has quit [Quit: I quit]
cadillac_ has joined #ruby
braincrash has quit [Quit: bye bye]
bambanx has quit [Quit: Leaving]
<blood>
Is there a better way to handle this https://dpaste.de/Y1J2 ? This runs pretty slow
<blood>
But it does work...
<blood>
mroutis: I got a method to work but REXML runs extremely slow
<blood>
I'll need to convert what I have to nokogiri
this_dude has joined #ruby
braincrash has joined #ruby
<this_dude>
back
maryo_ has quit [Ping timeout: 240 seconds]
<al2o3-cr>
this_dude: wb
mojtaba has joined #ruby
<this_dude>
ty
<this_dude>
so back to what i was asking before
<this_dude>
this command line --> res = song.split("WUB"||"WUBWUB").join(" ")
<this_dude>
is obviously incorrectly written
<this_dude>
but i need to be able to remove "WUB" no matter how many times its repeated
<this_dude>
i.e. "WUBWUBWUB" or "WUBWUBWUBWUB"
<this_dude>
and still replace it with just a single space
<ArahaelPi>
this_dude: That reminds me of the story: "Beyond lies the Wub".
<this_dude>
lul
<blood>
What version of nokogiri supports ruby 2.1.9?
<this_dude>
any idea how to do that?
<this_dude>
anyone lol
<al2o3-cr>
this_dude: i have an idea
<this_dude>
inb4 its a sarcastic idea :/
<Radar>
[12:36:43] <Radar>this_dude: Ok, can you work out how to replace all the WUBs with a single space?
<Radar>
[12:37:19] <Radar>this_dude: So if I had "AWUBWUBB" That would give me "A<space><space>B"
<this_dude>
oh i went afk for that..let me load the log hold on
<this_dude>
oh so for that one
<this_dude>
i could just use song.split("WUBWUB").join(" ")
<this_dude>
but in the case of one of the minitests on the site it has "WUBWUBWUB"..its super inefficient to write the same line of code for every increased instance of the use of the word "WUB
<this_dude>
and the problem states that it can be any random number of times that "WUB" is used
<this_dude>
or for [12:37:19] <Radar>this_dude: So if I had "AWUBWUBB" That would give me "A<space><space>B"
<this_dude>
it would be song.split("WUB").join(" ") to give "A<space><space>B"
<Radar>
>> AWUBWUBBsplit("WUB").join(" ")
<ruby[bot]>
Radar: # => undefined method `AWUBWUBBsplit' for main:Object (NoMethodError) ...check link for more (https://eval.in/1046224)
<this_dude>
so now i need it to only return a single space instead
orbyt_ has joined #ruby
<this_dude>
even if its WUB x3,4,5,etc
<Radar>
this_dude: Then there's probably a method you don't know yet: squeeze. That'll remove the spaces. You should probably read the docs around that method before using it.
<Caerus>
I am far for being an expert at ruby, but one thing that was very clear early on, whenever you find yourself looking at very complicated code, take a step back and shift through the methods of the class you´re working with.
<this_dude>
is there like...a list of methods lol
<Caerus>
chances are, there´s a more idiomatic way
<this_dude>
cause i had no idea those were a thing
<Caerus>
this_dude, absolutely and you should use it, a lot.
<this_dude>
wow
<Caerus>
for instance, related to the .strip, it belongs to String class
<this_dude>
literally one line of code did everything i was trying to do
<this_dude>
pseudo c?
<this_dude>
wdym haha
<Radar>
Yes. Your code looks like C.
<this_dude>
remember
<this_dude>
for my exam i need to know how to do it without .sort and all that
<Radar>
I still think that is a load of baloney.
<this_dude>
cause that wasnt in the material given to study
<this_dude>
well :/
<Radar>
"Drive a car with your feet because lulzzzz"
<this_dude>
thats the expectation
<this_dude>
wait what XD
<Radar>
with _only_ your feet
<this_dude>
oh lmfao...like the flinstones?
<Radar>
One foot on the steering wheel and the other on the pedals. Go on, try it.
<this_dude>
i mean trust me i get you...its because i guess new coders arent expected to learn all of the possible methods in 10 days
<this_dude>
idk something like that
<this_dude>
and because we need to know how to do it the long way?
<this_dude>
to understand what the easy way is doing
<Radar>
Do you though? Really?
<this_dude>
do i what..need to know the long way?
<Radar>
Yes.
<Radar>
P.S. your code isn't checking for nils.
<this_dude>
well thats how the educational system is lol....in math class they always teach the long way first and make you do homework doing it the long way...then the next day they go "ok npow this is the easy way to do what you just learned" XD
<this_dude>
i studied and memorized all of the "prep resources" they provided
<this_dude>
it nowhere near prepared me for the exam
<this_dude>
so now im scrambling to memorize outside knowledge enough to pass
<this_dude>
because i only have one more try to pass
duderonomy has joined #ruby
<blood>
12 week course, i would never trust anyone that tried this
<blood>
this is like bootcamp
<this_dude>
it is
<blood>
you cram a ton of information then lose it all
<this_dude>
its a coding bootcamp im applying for
<blood>
do it right and pick up a book
<this_dude>
if i pass the exams, free tuition AND they help set me up with a job right out of the program
<blood>
and why can you not pick up a book first then attempt this bootcamp?
<this_dude>
because i didnt know what i was gonna have to learn until i applied...and now that i did apply the countdown has begun so its kinda too late for that :>
<this_dude>
and i only have a couple days left
<this_dude>
im been studying day in and day out
<blood>
ok your choice =)
apeiros has quit [Remote host closed the connection]
<this_dude>
woah this is how they did it at a higher level...can anyone explain this?
<this_dude>
'(%d%d%d) %d%d%d-%d%d%d%d' % array
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
snickers has joined #ruby
<blood>
Using Nokogiri, the following doesn't find a match even though my xpath query is correct @document.xpath("/weblogic-web-app/session-descriptor/cookie-name").each do |el| el.content=value["value"] end
<blood>
using an old version 1.7.2 since I'm forced to use Ruby 2.1.9 atm
DTZUZO has quit [Ping timeout: 260 seconds]
<blood>
interesting, using css worked
<blood>
@document.css("/weblogic-web-app/session-descriptor/cookie-name").each but xpath does not
dionysus69 has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
herbmillerjr has joined #ruby
za1b1tsu has joined #ruby
nowhere_man has joined #ruby
DTZUZO has joined #ruby
madhatter has joined #ruby
clemens3 has joined #ruby
TomyWork has joined #ruby
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has joined #ruby
ogres has quit [Quit: Connection closed for inactivity]
quazimodo has quit [Ping timeout: 240 seconds]
yohji has joined #ruby
quazimodo has joined #ruby
postmodern has quit [Quit: Leaving]
mikecmpbll has joined #ruby
tty has quit [Quit: tty]
<this_dude>
im burnt..ill pick this up where i left off tomorrow
snickers has joined #ruby
this_dude has quit [Ping timeout: 252 seconds]
Burgestrand has joined #ruby
sysvalve has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
alex`` has joined #ruby
MuffinPimp has quit [Quit: Goodbye.]
mikecmpbll has joined #ruby
arup_r has joined #ruby
MuffinPimp has joined #ruby
cabotto has joined #ruby
cabotto has quit [Client Quit]
arekushi has quit [Quit: Gateway shutdown]
Puffball has quit [Remote host closed the connection]
DTZUZO has quit [Remote host closed the connection]
DTZUZO has joined #ruby
jottr has joined #ruby
unCork has joined #ruby
Cork has quit [Ping timeout: 240 seconds]
arup_r has quit []
unCork is now known as Cork
heinrich5991 has quit [Ping timeout: 268 seconds]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
heinrich5991 has joined #ruby
aufi has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mojtaba has joined #ruby
Freshnuts has quit [Quit: Leaving]
p4p0l0 has joined #ruby
snickers has joined #ruby
snickers has quit [Client Quit]
snickers has joined #ruby
k0mpa has quit [Ping timeout: 250 seconds]
ansraliant has quit [Quit: Konversation terminated!]
dhollin3 has joined #ruby
sylario has joined #ruby
dhollinger has quit [Ping timeout: 256 seconds]
gix has joined #ruby
rootsudo has quit [Ping timeout: 244 seconds]
vondruch has quit [Ping timeout: 255 seconds]
Mike11 has joined #ruby
vondruch has joined #ruby
ferhaty has joined #ruby
alfiemax has joined #ruby
aufi has quit [Ping timeout: 265 seconds]
c0ncealed2 has quit [Remote host closed the connection]
c0ncealed2 has joined #ruby
alfiemax has quit [Remote host closed the connection]
Emmanuel_Chanel has quit [Ping timeout: 260 seconds]
psychicist__ has joined #ruby
aufi has joined #ruby
sameerynho has joined #ruby
za1b1tsu has quit [Ping timeout: 256 seconds]
apeiros has joined #ruby
aufi has quit [Ping timeout: 244 seconds]
linucks has joined #ruby
za1b1tsu has joined #ruby
sameerynho has quit [Ping timeout: 244 seconds]
za1b1tsu has quit [Read error: Connection reset by peer]
za1b1tsu has joined #ruby
jameser has quit [Ping timeout: 244 seconds]
desperek has joined #ruby
Burgestrand has quit [Quit: Closing time!]
vondruch has quit [Quit: vondruch]
doubledup has joined #ruby
za1b1tsu has quit [Read error: Connection reset by peer]
eb0t_ is now known as eb0t
za1b1tsu has joined #ruby
def_jam is now known as eblip
Mike111 has joined #ruby
Mike111 has quit [Max SendQ exceeded]
Mike11 has quit [Ping timeout: 240 seconds]
Mike11 has joined #ruby
Mike11 has quit [Max SendQ exceeded]
howdoi has joined #ruby
doubledup has quit [Remote host closed the connection]
MyMind has quit [Read error: Connection reset by peer]
MyMind has joined #ruby
GodFather has joined #ruby
za1b1tsu has joined #ruby
fmcgeough has joined #ruby
TJ- has joined #ruby
snickers has quit [Ping timeout: 256 seconds]
User458764 has joined #ruby
snuz has quit [Ping timeout: 265 seconds]
Inline has joined #ruby
vondruch has quit [Quit: vondruch]
alex`` has quit [Ping timeout: 244 seconds]
bmurt has joined #ruby
DarthGandalf has quit [Quit: Bye]
DarthGandalf has joined #ruby
GodFather has quit [Ping timeout: 265 seconds]
alex`` has joined #ruby
za1b1tsu has quit [Ping timeout: 276 seconds]
twe4ked has quit [Ping timeout: 265 seconds]
twe4ked has joined #ruby
za1b1tsu has joined #ruby
m27frogy has quit [Ping timeout: 268 seconds]
m27frogy has joined #ruby
gheegh has joined #ruby
za1b1tsu has quit [Ping timeout: 240 seconds]
zerowaitstate has joined #ruby
<zerowaitstate>
how do you write an rspec mock that always returns a specific value for a specific input, regardless of the number of times it is called?
Burgestrand has quit [Quit: Closing time!]
p4p0l0 has quit [Ping timeout: 260 seconds]
<balo>
zerowaitstate: what do you mean? double('MyClass', foo: :bar) ?
Burgestrand has joined #ruby
vondruch has joined #ruby
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
ciro has quit [Ping timeout: 256 seconds]
rippa has joined #ruby
chouhoulis has joined #ruby
sameerynho has quit [Ping timeout: 240 seconds]
<zerowaitstate>
balo: I mean I have a factory method on a base class that accesses a database, and I need it to always return the same object for the same parameters (since the test runs without a database)
<balo>
in general i don't like the "allow_any_instance_of" but sometimes it's useful. and maybe you can just use allow(my_object).to receive....
<balo>
depending on how that factory method is implemented and how do you access it
<balo>
or it can be that i still don't get the issue :)
agent_white has joined #ruby
<zerowaitstate>
that may be all that is necessary. I'm still new to RSpec and the DSL is confusing me a bit
snickers has joined #ruby
snickers has quit [Client Quit]
<zerowaitstate>
actually the problem I have with receive.and_return is that it always returns a given sequence. So, if you pass an array in to #and_return, the same sequence of objects is always returns, regardless of the arguments supplied to the method
akaiiro has joined #ruby
<zerowaitstate>
that makes the test brittle, because I have to know in what order each call to the factory method happens in the code.
dhollin3 is now known as dhollinger
<zerowaitstate>
it would be super helpful to be able to create a simple hash of inputs to results and pass that to #and_return, but that doesn't appear to be an option
dionysus69 has quit [Ping timeout: 240 seconds]
moei has joined #ruby
Burgestrand has quit [Quit: Closing time!]
clemens3 has quit [Ping timeout: 244 seconds]
p4p0l0 has joined #ruby
<gray_-_wolf>
was on tracker or ml ever discussed option of adding precompiled (preparsed) ruby files into mri? Something like python's `.pyc` files? I didn't find anything so I'm trying to here
drale2k_ has joined #ruby
Burgestrand has joined #ruby
<darix>
gray_-_wolf: the new jit added for 2.6 will bring you something similar
chouhoulis has quit [Remote host closed the connection]
za1b1tsu has joined #ruby
<gray_-_wolf>
hm? I thought that JIT is about optimizations, not reducing parsing time. I'm looking at `ruby --help` of current trunk and I'm not seeing anything related to this...
chouhoulis has joined #ruby
<gray_-_wolf>
where could I find more on this?
<balo>
zerowaitstate: hmm, i think now i understand the issue. you rely on the consecutive return values... i've never used it, never needed it. How would you refactor your code to make it more easy to test?
<darix>
gray_-_wolf: it will store the compiled version of your ruby files if it is jit worthy
<darix>
gray_-_wolf: are you sure the parse time is your problem?
<balo>
in general, rarely a good idea to have such complicated mocking
felix_vs has joined #ruby
<gray_-_wolf>
darix: well... not whole problem but part of. I have few very simple scripts which do some basic stuff but pull lot of things in.. based on my profiling the parsing is about 20% of the script run; I know python solves this via .pyc files so was looking if something like that is available for ruby
za1b1tsu has quit [Ping timeout: 265 seconds]
chouhoulis has quit [Ping timeout: 240 seconds]
<darix>
gray_-_wolf: not sure we have something like that.
chouhoulis has joined #ruby
<ineb>
zerowaitstate: balo: do i understand something wrong? cant you do expect(mock).to receive(:foo).with(bar).and_return(baz)
<gray_-_wolf>
hm maybe I'll try to write it, could be interesting exercise
<balo>
ineb: you can, the problem is - if i understand it correctly that he the code relies on consecutive return values of the mock. and he feels it wrong to depend on the order and wanted to match the arguments with the return values. like passing it as a hash somehow but for the same method as input output list. https://github.com/rspec/rspec-mocks#consecutive-return-values
p4p0l0 has quit [Remote host closed the connection]
ferhaty has quit [Quit: ferhaty]
<ineb>
zerowaitstate: balo: i think balo already answered the question. if return values based on specific input is required, it needs to ne listed explicitly and not as return sequence
<ineb>
for every possible input, a return value needs to be declared
<balo>
ah, yeah, that can work actually. expect(MyClass).to receive(:my_builder).with(:myarg_1).and_return(my_arg_object_1)
<balo>
and one line for every arg-return pair?
<ineb>
the mock for that can be build with a helper function which provides the desired functionality from zerowaitstate to build the mock from a hash
<balo>
yeah. anyway, for me this test case sounds a bit complicated
<ineb>
it is. but can be used to mock subsequent db calls for every test needed
<ineb>
if you dont want integration tests against a real db
<ineb>
i have used it aswell for mocking http calls
gray_-_wolf has quit [Quit: WeeChat 2.2]
TJ- has quit [Ping timeout: 245 seconds]
ciro has joined #ruby
Emmanuel_Chanel has joined #ruby
Burgestrand has quit [Quit: Closing time!]
clemens3 has joined #ruby
apeiros has quit []
vondruch has quit [K-Lined]
AJA4350 has quit [Quit: AJA4350]
apeiros_ has joined #ruby
AJA4350 has joined #ruby
SeepingN has joined #ruby
akaiiro has quit [Remote host closed the connection]
apeiros_ has quit [Remote host closed the connection]
mroutis has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
mroutis has quit [Remote host closed the connection]
polishdub has joined #ruby
mroutis has joined #ruby
User458764 has joined #ruby
jottr has quit [Ping timeout: 256 seconds]
alex`` has quit [Quit: WeeChat 2.2]
impermanence has joined #ruby
cagomez has joined #ruby
apeiros_ has joined #ruby
gregf_ has quit [Ping timeout: 252 seconds]
hfp_work has quit [Ping timeout: 240 seconds]
apeiros_ has quit [Ping timeout: 240 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
agent_white has quit [Quit: brb]
Rapture has joined #ruby
agent_white has joined #ruby
hfp_work has joined #ruby
apeiros_ has joined #ruby
AJA4351 has joined #ruby
maryo has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
jcarl43 has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
jottr has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4350 has joined #ruby
orbyt_ has joined #ruby
jottr has quit [Ping timeout: 248 seconds]
TomyWork has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 244 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
yohji has quit [Remote host closed the connection]
snuz has joined #ruby
orbyt_ has quit [Client Quit]
JamJam_kid has joined #ruby
alfiemax has joined #ruby
snuz has quit [Quit: WeeChat 2.2]
maryo has quit [Quit: Leaving]
chouhoulis has quit [Remote host closed the connection]
alfiemax has quit [Remote host closed the connection]
<havenwood>
samort14: There are two types of gems that ship with Ruby, bundled gems and default gems.
felix_vs has quit [Quit: Leaving]
<havenwood>
samort14: (The "bundled" name has nothing to do with Bundler.)
<havenwood>
samort14: Bundled gems are not maintained by Ruby core and can be uninstalled with the `gem uninstall` command.
<havenwood>
samort14: Default gems are maintained by Ruby core and cannot be uninstalled.
<havenwood>
samort14: Recent versions of Ruby have seen large increases in the number of gems default gems that are extracted and gemified from the standard library.
<havenwood>
samort14: The bundled gems are did_you_mean, minitest, net-telnet, power_assert, rake, test-unit and xml-rpc.
<havenwood>
samort14: So if you wanted to, you could delete them all after you install Ruby: gem uninstall did_you_mean minitest net-telnet power_assert rake test-unit xml-rpc
<havenwood>
samort14: In Ruby 2.4, there were just a similar number of default gems. The amount nearly tripled in Ruby 2.5 as the efforts to gemify the standard library gained steam.
<samort14>
havenwood: ah wow, really interesting! I feel like I have been looking for a straightforward explanation on this stuff for a while but couldn't find it anywhere
<mroutis>
havenwood: today I learned ^; that's interesting
<havenwood>
(Only the first eight of which were default gems in Ruby 2.4.)
felix_vs has joined #ruby
<havenwood>
More of the standard library is also being gemified and removed from Ruby - which has resulted in gems like curses and tk.
tdy has quit [Ping timeout: 256 seconds]
<samort14>
Ah! This makes so much sense! I was getting an error: `Unable to activate xml-to-json-1.0.2, because json-2.1.0 conflicts with json` because I was requiring 'xml/to/json' and didn't realize 'json' was a default gem
Dbugger has quit [Ping timeout: 276 seconds]
mikecmpbll has joined #ruby
darkhanb has joined #ruby
<samort14>
So in my situation, since 'json' is a default gem, it cannot be uninstalled, so there must be a way for me to be able to use 'xml/to/json' without it conflicting, right? Like changing its namespace?
<havenwood>
samort14: You can upgrade default gems without updating Ruby.
<havenwood>
That's one of the nice things about gemifying the stdlib. You can just update a gem like bigdecimal if it has a CVE, rather than having to update Ruby itself to get the fix.
<havenwood>
But yeah, you can't remove them.
<samort14>
When you say 'update', what do you mean by that?
<havenwood>
samort14: gem update json
<havenwood>
samort14: You can have multiple versions of the JSON gem installed.
<samort14>
Ooooh! It requires an older version of json!
<samort14>
Wow! You have a good eye!
bmurt has joined #ruby
<havenwood>
samort14: JSON 1.8 used to not work with Ruby 2.4 or newer, but iir version 1.8.4 or later does work. Try: gem install json -v '~> 1'
tty has joined #ruby
<samort14>
Ok, quick question - If I want to share the program that I am writing with other people, how do I communicate with them what version of each gem they should be installing? Should I use a Gemfile instead of "gem install"ing things manually?
<havenwood>
samort14: You can just manually `to_hash.to_json` or implement just what you need. It should only be a few lines.
<havenwood>
samort14: If you're sharing your code as a gem, you specify the dependencies in the gemspec. If you're sharing your code as an app, you specify the exact versions of the dependencies in the Gemfile.lock, which is programatically created from the deps you specify in the Gemfile.
felix_vs has quit [Quit: Leaving]
<havenwood>
samort14: It's common with a gem to have a Gemfile, but it'll often just have the line `gemspec`, which means defer to the gemspec file when bundling.
<havenwood>
samort14: With gems, we add the Gemfile.lock to the .gitignore.
tdy has joined #ruby
<havenwood>
With apps, you ship the Gemfile.lock so every dev is using the exact same gems and versions when running the app.
<samort14>
havenwood: Ah, wow, this is all super useful information! Thank you guys so much!
<havenwood>
this_dude: In current Ruby you can write it with an Enumerable like: Enumerator.new { |yielder| n = 942; loop { yielder << n; n = n.digits.sum } }.find { |n| n.digits.one? } #=> 6
* this_dude
is very confused and mindblown
<this_dude>
currently processing that..
<havenwood>
this_dude: In Ruby you can make your own Enumerator collections.
<havenwood>
this_dude: That's pretty little code considering it implements function composition and a new way to generate an Enumerator!
<this_dude>
omg so...i work at a steakhouse and im off the clock here studying..this lady just came..TO A STEAKHOUSE...and asked if we have a vegetarian menu
<this_dude>
we dont lmao.
<havenwood>
this_dude: None of the cows were vegetarians?
<this_dude>
XD
<this_dude>
I'll tell her that
<this_dude>
"Ma'am all of our cows were vegetarians is that what you meant?"
<this_dude>
i feel like if i read that ill just end up more confused than before so ill stick to my basics xD
<havenwood>
this_dude: Yeah, no need to look into implementation details unless you're just curious and have lots of time.
<this_dude>
maybe later
<maryo>
While starting the dashing service one of the job is giving out an exception (https://dpaste.de/Z8h7) here is the entire job code (https://dpaste.de/gFqf) some pointers would be appreciated
solidsnack has quit [Ping timeout: 245 seconds]
spiette has quit [Remote host closed the connection]
<this_dude>
oh geeze this problem lol "Check to see if a string has the same amount of 'x's and 'o's. The method must return a boolean and be case insensitive. The string can contain any char."
mroutis has joined #ruby
PettanShoutaKun has quit [Ping timeout: 252 seconds]
spiette has joined #ruby
solidsnack has joined #ruby
<this_dude>
so apparently its not .scan..what would the method for a string be to see if any of the characters match a designated value?
<baweaver>
maryo: What does the first line of the error say?
<baweaver>
`include?`
<maryo>
baweaver, first line of the error? it says "scheduler caught exception:
<maryo>
"
<baweaver>
Now the second line
<this_dude>
ty
mojtaba has joined #ruby
snuz has quit [Quit: WeeChat 2.2]
<maryo>
baweaver, here it is undefined method `[]' for nil:NilClass
<baweaver>
>> nil['nope']
<ruby[bot]>
baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<baweaver>
Does that error look familiar?
<baweaver>
( havenwood - Oh I know )
<maryo>
baweaver, yep but I am wondering from where I am getting that nil value
<baweaver>
Keep tracing it backwards until you find where bad info got into the pipeline
jcalla has quit [Quit: Leaving]
<maryo>
baweaver, Is it possible to get the value of result for debugging purpose ? like p result ? by adding it to line 155
tdy has quit [Ping timeout: 245 seconds]
<baweaver>
You could certainly try it.
<baweaver>
?pry
<ruby[bot]>
Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
<ruby[bot]>
apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<this_dude>
already found it
<this_dude>
ty though
<apeiros>
meh, we really need something more reliable than eval.in :(
<this_dude>
its (a..b).to_a.sum
<apeiros>
that's less efficient
<this_dude>
>> (10..20).to_a.sum
<ruby[bot]>
this_dude: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<apeiros>
you can just drop the .to_a
<this_dude>
gave me an error when i did
<apeiros>
which ruby version?
<this_dude>
idk im on codewars.com
<apeiros>
also what error exactly?
<this_dude>
oh wait not its not giving me that error wtf dude lol
<this_dude>
now*
<this_dude>
nvm
<apeiros>
also, sum of a range can be calculated directly ;-)
* apeiros
wonders whether Range#sum special cases that
<this_dude>
the range isnt given
<this_dude>
only two integers
<this_dude>
i have to make the range inside my method
<this_dude>
"Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b."
<apeiros>
hm, now I wonder whether the direct calculation also works for negative numbers…
<this_dude>
i have a problem though
<this_dude>
my code is working for all except one minitest
<this_dude>
i created an if statement for if the second integer is the smaller one
<this_dude>
it should take that into account idk whats going wrong
<havenwood>
this_dude: (42..1).size #=> 0
<this_dude>
wut
<apeiros>
looks to me like your code is correct
<this_dude>
my code should be creating a range from -1 to 5
<this_dude>
then wtf lol
<apeiros>
you could simplify it since (n..n).sum == n
<this_dude>
oh i ran it agin
<this_dude>
again* and now it worked
<this_dude>
wtf XD
<this_dude>
glitch?
<this_dude>
oh you right
<havenwood>
>> (42..42).sum
<this_dude>
wait thats it
<apeiros>
i.e. `a,b = b,a if b < a; (a..b).sum` is sufficient
<ruby[bot]>
havenwood: I'm terribly sorry, I could not evaluate your code because of an error: OpenURI::HTTPError:500 Internal Server Error
<havenwood>
#=> 42
<this_dude>
when i remove the " elsif a == b "
<this_dude>
line it gives me the nil
<this_dude>
for 5 and -1
<this_dude>
why tf
duderonomy has quit [Ping timeout: 256 seconds]
<apeiros>
because you still have a condition
<apeiros>
none of your branches is it
<this_dude>
wdym
<this_dude>
my dogs name is duderonomy LOL
<this_dude>
-1 < 5
<this_dude>
so it should execute line 4 no??
<apeiros>
`if cond1; stuff; elsif cond2; suff2; end` if neither cond1 nor cond2 is met, none of the `stuff` branches is executed and it evaluates as nil
<this_dude>
but thats what im saying...doesnt 5 and -1 meet the condition of line 4 https://dpaste.de/FMda#L
<apeiros>
this_dude: if you take out line 6 and 7, your method will be broken. but it should still return the correct result for 5,-1
<this_dude>
exactly my poiny
ellcs has joined #ruby
<this_dude>
point* no idea whats going on
<apeiros>
(and does so for me)
<havenwood>
this_dude: To clarify, you want to do `(b..a).sum` when b is smaller, and otherwise, for all cases, do `(a..b).sum`?
<this_dude>
correct
<havenwood>
this_dude: So what should your if/else condition be to express that?
<this_dude>
dude i ran it again and now i dont get the error
<this_dude>
im so done
<this_dude>
this website is broken af
<this_dude>
oo oo pop quiz
<this_dude>
gimme a sec
<havenwood>
this_dude: That's a reason stuff like https://exercism.io/ is great - you run the tests locally.
<this_dude>
what i have no?
<this_dude>
if a < b (a..b).sum elsif b < a (b..a).sum
<havenwood>
this_dude: "all other cases" is just: else
<this_dude>
oh
<this_dude>
rip
<this_dude>
if a < b (a..b).sum else (b..a).sum
<this_dude>
?
<havenwood>
this_dude: To clarify, you want to do `(b..a).sum` when b is smaller, and otherwise, for all cases, do `(a..b).sum`?
<this_dude>
wait no
<apeiros>
alternatively <=, but just else is better.
<this_dude>
yeah
<this_dude>
ok cool ty
mojtaba has quit [Quit: Leaving.]
<this_dude>
and i guess this is how you do it in one line
<this_dude>
return a < b ? (a..b).reduce(:+) : (b..a).reduce(:+)
<this_dude>
no idea what that means though
beefjoe has quit [Ping timeout: 272 seconds]
<havenwood>
this_dude: that was the days before #sum
Creatornator has joined #ruby
<this_dude>
oh eww
<this_dude>
ooo this next problem is interesting
<this_dude>
In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out.
<havenwood>
this_dude: b < a ? (b..a).sum : (a..b).sum
<this_dude>
oh wow
<apeiros>
reduce, aka inject will "inject" the operator between every element, i.e. [1,2,3].inject(:+) "becomes" 1 + 2 + 3
<havenwood>
this_dude: that is called a "ternary" operator
<havenwood>
cthulchu_: Check it in IRB or Pry: [:a, :b, :c].each_with_index.to_a
<this_dude>
whats the difference between .grep and .gsub
<cthulchu_>
it's just to get the index variable inside the block
<cthulchu_>
makes sense
<this_dude>
get replace and get substitute
<this_dude>
isnt it?
<this_dude>
i thought its the same thing lol
gheegh has joined #ruby
<cthulchu_>
lol
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<JJonah>
any suggestions for hosting private gems? (either SaaS or something i'd run on my own server). I want something easy, with good discoverability (ability to search gems by keyword).
<this_dude>
google isnt helping
jcarl43 has quit [Read error: Connection reset by peer]
<this_dude>
i have no idea what that code is even doing lmaooo
<apeiros>
but String#[] & + is indeed the better choice than via #[]=
<JJonah>
this_dude: it's Xing out every char but the last 4
<JJonah>
apeiros: which edge case are you thinking?
<this_dude>
well i figured but
<apeiros>
JJonah: short string
<this_dude>
i cant follow the syntax lol
<JJonah>
apeiros: if it's a cc number though, should be fine
<apeiros>
never trust user input :) but yes, if you know the value has been validated beforehand, you can skip code to handle edge cases.
<JJonah>
apeiros: yeah, i was assuming that was the case
<apeiros>
I assume the opposite unless expressly being told :)
<apeiros>
though, of course, even then you have to know what you want your code to do. if you want it to raise, your method is still fine.
<JJonah>
apeiros: i suppose it depends on context. but if this were production code i'd want to see the method that does what i did split out from the validation one way or another.
cjkinni has quit [Quit: Ping timeout (120 seconds)]
gnufied__ has quit [Remote host closed the connection]
<this_dude>
y'all are way above my level and its so entertaining to read lmao
cjkinni has joined #ruby
<this_dude>
explain to me please how this works
<this_dude>
cc.gsub(/.(?=....)/, '#')
<JJonah>
this_dude: try breaking down the different pieces. it's fairly standard ruby. we're just repeating an X for "4 less than as long as the string is". Then I'm using [] to chop off the last 4 chars of the string.
<this_dude>
i still dont understand hashes or whatever this is
<apeiros>
this_dude: what do you know about regexes so far?
<this_dude>
nada
<this_dude>
that wasnt in the course material
<this_dude>
and its all very confusing
<JJonah>
ooohh that regex solution is nice. that's better than mine.
psychicist__ has quit [Ping timeout: 265 seconds]
<apeiros>
ok, then the high-level explanation: gsub(/.(?=....)/, "#") replaces every character which is followed by any 4 characters with a #
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
patr0clus has joined #ruby
<apeiros>
JJonah: dunno, I like yours more tbh.
gheegh has joined #ruby
<this_dude>
0-0
<apeiros>
this_dude: basically, gsub will go from left to right through your string, trying to match the regex as often as it can, and replace the matched substring with the second argument ('#' in your case)
<apeiros>
and // is the delimiter for the regex (like "" is for strings)
<apeiros>
within the regex, . means "any character"
<JJonah>
and since the final 4 characters don't have "4 more characters to their right" they don't match, and hence they don't get changed.
plutes has joined #ruby
<apeiros>
and (?=…) means "followed by …" (the term is "positive look-ahead")
<this_dude>
wild
<this_dude>
so complicated
<apeiros>
so (?=....) is "followed by 4 characters"
<this_dude>
im kinda following
<apeiros>
but a (?=) group is itself not part of the match, hence it's not replaced, only the first .
<this_dude>
(?={4}) == (?=....)
<this_dude>
?
<apeiros>
almost
<apeiros>
(?=.{4})
<this_dude>
f***
<this_dude>
why
<apeiros>
you still need to quantify something :)
<this_dude>
i dont quite follow
<apeiros>
{4} means "4 of the atom to the left", but you have nothing to the left of it :)
<apeiros>
.{4} means "4 of ."
<apeiros>
a{4} means "4 of 'a'"
<baweaver>
oh no
<this_dude>
crazy
<this_dude>
hey weaver
<apeiros>
useful
<this_dude>
theyre teaching me regexes
<baweaver>
Pandoras box has opened
<apeiros>
run while you can 😄
<this_dude>
knowing you, you probably have an illustrated course on it dnot you
<cthulchu_>
but I guess that method gets called implicitly
<cthulchu_>
aha, ok
<baweaver>
Now are there ways to _make_ ruby do those things? Sure, but don't do it.
<baweaver>
It's slow and prone to errors.
<apeiros>
cthulchu_: re hash.a = value, take a look at OpenStruct
<this_dude>
You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.
<apeiros>
but baweaver's slow & prone comment is of course on-point :)
<baweaver>
Hehe, OpenStruct kills method cache too
<apeiros>
I even try to avoid hashes if I can and use Struct instead
mroutis has joined #ruby
<this_dude>
im trying to think how you would do this mathematically
<apeiros>
baweaver: is that still an issue? I somehow thought that was resolved?
<apeiros>
you can't call to_i on an array. but the elements in the array are strings.
alfiemax has joined #ruby
AJA4350 has quit [Ping timeout: 256 seconds]
<this_dude>
wtf man
<cthulchu_>
omfg
<cthulchu_>
byebug is so extremely useful!
<cthulchu_>
I made a wrapper for it
AJA4350 has joined #ruby
<this_dude>
OH
<this_dude>
numbers.map { |n| n.to_i }
<this_dude>
???
<apeiros>
👍🏻👏🏻
<this_dude>
im on pc..cant see those characters
<this_dude>
are those emojis
<cthulchu_>
hehe
<this_dude>
did i get the answer right or no?
<this_dude>
xD
<apeiros>
this_dude: thumbs-up + clap
<this_dude>
oh shoot
alfiemax has quit [Ping timeout: 240 seconds]
<this_dude>
im learning
<apeiros>
and shouldn't pc's be able to display emojis too?
<this_dude>
woah
ellcs has quit [Ping timeout: 256 seconds]
<this_dude>
my pc is from like.. 2008 XD
<this_dude>
it originally ran on vista
<this_dude>
lmfao
<this_dude>
wtf
<apeiros>
ok, not adept with windows. but my wife's macbook from 2010 can display emoji with no problems :D
<this_dude>
"string cant be coerced into integer"
<apeiros>
you get that when you do something like 1 + "2"
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<apeiros>
ruby does perform type coercion, but not across certain boundaries. e.g. 1 + 2.0 (integer + float) will work. but 1 + "2" (integer + string) will not
<this_dude>
oh wait you're right
<apeiros>
of course. I'm always. Even when I'm not. :D
<this_dude>
forgot .to_s
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<baweaver>
>> '1 2 3 4 5'.split.map(&:to_i).sum
<ruby[bot]>
baweaver: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
<arooni>
so i have a server that runs an old rails app via nginx + passenger; on ubuntu 16.04 and ruby is setup with rvm. that works fine; but is there a way using rvm / perhaps something else without changing anything that would let me run a separate version of ruby for that app but use a different version elsewhere
chongtxtx has quit [Ping timeout: 240 seconds]
chongtxtx has joined #ruby
<baweaver>
.ruby-version iirc.
dviola has joined #ruby
<apeiros>
arooni: passenger can run multiple ruby versions at the same time, yes
Pisuke has joined #ruby
<apeiros>
just configure the ruby version per virtual host
<arooni>
oh wow; didnt know i could do that;
<arooni>
been awhile since i looked at this app lol
<arooni>
so if i set a default in my shell (fish) that wont affect the app?
MyMind has quit [Ping timeout: 268 seconds]
<apeiros>
probably depends on your passenger config. but I think even in the standard config it shouldn't matter if you change your shell's ruby version.
ciro has quit [Quit: WeeChat 2.2]
alfiemax has joined #ruby
chouhoulis has quit [Remote host closed the connection]
alfiemax has quit [Remote host closed the connection]
Puffball has quit [Remote host closed the connection]