<Guest2587>
Is anyone here or am I alone in this channel, I am new here and don't know if I am at the correct place
<caleb>
It's returning the original value, you're not manipulating it in the block. Only outputing
<caleb>
also IRC can be a slow medium, sometimes idling for several hours to get a response is necessary
<caleb>
if you wanted it to return the mutation you're printing as a new string you could do
<caleb>
s.each_char.map {|c| c * 2 }.join
<Guest2587>
Hi caleb, thanks a lot for your answer and info about this channel! Is there an even faster way to get help with Ruby or is IRC already the best shot?
crax23 has joined #ruby
crax23 has quit [Remote host closed the connection]
crax23 has joined #ruby
<sam113101>
it probably is your best shot
cartdrige has quit [Ping timeout: 256 seconds]
<Guest2587>
caleb @solution: GREAT! Thank you so much!!
Y05hito__ has joined #ruby
<caleb>
happy to help
crax23 has quit [Ping timeout: 268 seconds]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 260 seconds]
desnudopenguino1 is now known as desnudopenguino
smp has quit [Ping timeout: 268 seconds]
smp_ has joined #ruby
smp_ is now known as smp
Rounin has quit [Ping timeout: 268 seconds]
markong has quit [Ping timeout: 268 seconds]
<weaksauc_>
Guest2587 discord has a fairly active ruby server
<weaksauc_>
not that i want irc to go away but if you really need some help fast that's an option
pvalenta has joined #ruby
Y05hito__ has quit [Quit: Leaving]
<caleb>
weaksauc_ is right, but I stay here for the lack of gifs and memes
cartdrige has joined #ruby
<Guest2587>
sam113101t thank you for the hint! I just found it!
<Guest2587>
weaksauc_ thank you for the hint! I just found it!
grokify has joined #ruby
<Guest2587>
caleb yes, and lack of politics is appreciated by me, too.
grokify has quit [Ping timeout: 260 seconds]
Al2O3 has joined #ruby
entropie has quit [Ping timeout: 248 seconds]
cartdrige has quit [Quit: Leaving]
entropie has joined #ruby
Al2O3 has quit [Quit: I'm quitting, thanks for all the sharks.]
<Guest2587>
I am stuck since hours and have tried so many different approaches on this with all hints that I could find on the web:
<Guest2587>
I get a string s e.g. ZpglnRxqenU
<Guest2587>
My task is to create a new string from that with each character being multiplied with its position in the string (i.e. index+1) and have the characters separated by a dash "-"
<Guest2587>
I have almost reached to the solution but what breaks my head since hours is that using "index" with characters, either in a string or in an array, always gives me the index of the FIRST time a character is found, no matter if it gets repeated later. so the multiplication of the same character will always be done with the first index of the first
<Guest2587>
same character found. and i just cannot find a work arround for that.
<Guest2587>
here is my current code attempt and what i get with it:
<Guest2587>
s.chars.map { |c| c * (s.index(c)+1) }.map(&:capitalize).join("-")
<Guest2587>
it works well as long as the s string does not contain repeating characters. if it does, e.g. the n, i get this:
<Guest2587>
I have tried it with map turning it into an array, with each_char, leaving it as an string, and now trying to somehow make 2 arrays, one with the characters and one with their positions and then attempt to zip them to a joint array, but wont get it working either and it seems very clumsy.
<Guest2587>
and ideas about what is the best approach and solution to this?
<Guest2587>
(also part of the task is to capitalize the first character of each series)
<caleb>
all enumerables are mappable so you solve your index problem by getting it in the first map
<caleb>
s.chars.each_with_index.map { |c, i|
<sam113101>
Guest2587: where are you getting those exercises from? I'm looking for something similar to project euler myself, but focused more on the programming than on the math
<weaksauc_>
advent of code is fun too but a bit harder than exercism and more story focused
<weaksauc_>
can be harder*
<Guest2587>
caleb THANK YOU!! I was fiddling around with each_with_index, but did not apply it on the right spot, etc. but now with your great help it works like a charm and I understood why my other attempts did not work! THANK YOU SO MUCH, learned a ton again!
<caleb>
give yourself a pat on the back as well. You did a great write up, short concise snippet, and a clear explanation of what you were trying to do
<Guest2587>
sam113101 I practice on codewars.com and really love it. It is gamified like a karate dojo and you get to solve problems that have difficulties according to your belt rank, etc. it is really nice and i learn tons of stuff. it supports dozens of programming languages and you can also solve the same problem (called kata like the forms you do in
<Guest2587>
karate) multiple times with different languages if you want. at the end you can compare your solution with the others, ranked, so that again you learn the best approaches, etc.
<caleb>
lots of people who hop on IRC ask a question with no context, complain no one answered it in 5 minutes and then leave
<caleb>
so it's nice to have good questions to help with
<Guest2587>
@caleb: thank you! yes, i read the rules in the mean time and therefore put some effort in it to comply as good as i can with my second question :-)
<caleb>
if you'd like to stick around without using a web browser I'd suggest getting an IRC client and connecting directly to the server irc.libera.chat
<Guest2587>
caleb yes i will do that! havent used IRC since decades but this channel will bring me back to the good old times and i love it!
<adam12>
Guest2587: Welcome back to 1999!
<caleb>
and that's right where I want to stay
<caleb>
I even moved back to a flip phone recently
<caleb>
do you know how awesome it is to only charge my phone every 2 weeks?
<adam12>
Heh
<Guest2587>
adam12 Thanks for having me! Feels like home already :-)
Aminda has quit [Remote host closed the connection]
<adam12>
Guest2587: I'm not sure your timezone but I'm here every day 9-5 GMT-5 answering questions. And others are around at different times too. In the off hour of GMT-5 I do notice it a bit quieter.
Aminda has joined #ruby
<Guest2587>
caleb : that's a radical move back to the future :-) #oldschool #noapps
<Guest2587>
adam12 thanks for the info! I am currently UTC+2 so a 7 hour difference. it is in the middle of the night, so a big shoutout to caleb for the kind provision of a solution so that I can go for sleep finally. :-D
<adam12>
Guest2587: No worries :)
<Guest2587>
Ok, will leave now and come back soon, with a proper IRC client next time. Any suggestions for Linux?
<adam12>
Guest2587: X11 or terminal?
<Guest2587>
both if you have recommendations!
<adam12>
Guest2587: weechat or irssi for terminal. I'm not sure on X11, maybe xchat? It's been a long time since I used Linux on desktop.
<Guest2587>
ok great, will check them out!
<Guest2587>
thanks guys! have a good one!
<adam12>
Guest2587: Cheers.
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
<adam12>
weaksauc_: Advent of Code is sometimes incredibly frustrating :P
<adam12>
I generally give up near like day 8 or 9. LOL.
cartdrige has joined #ruby
<cartdrige>
Hey.
<caleb>
howdy
<cartdrige>
I try to split a large binary file into multiple smaller files, but ruby gets constantly killed by the kernel OOM killer, any idea?
<adam12>
cartdrige: How are you doing it? can you share code?
<cartdrige>
says I read 300 MB, then i write that to a file, then again 300 MB etc, but then at file 4 or 6 it gets killed.
<ruby[bot]>
cartdrige: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<adam12>
cartdrige: I'd look at using IO.copy_stream perhaps. It goes to kernel directly, no chance of OOM.
<cartdrige>
It works ok for like 1GB or 5GB but my file is 40 GB
<cartdrige>
Ok, thk you i'll look into that.
moldorcoder7_ has quit [Ping timeout: 260 seconds]
<Guest2587>
good news for ruby since this will help keeping the ecosystem alive and will contribute even further to the current popularity turn-around trend of Ruby on Rails and thus also of Ruby https://rubyonrails.org/2022/11/14/the-rails-foundation
<weaksauc_>
rails is back
<caleb>
back again
<caleb>
shady's back, tell a friend
<weaksauc_>
yeah with hotwire and all that new foundation jazz and the shopify stuff it's back big
<caleb>
I'm trying to move to the DevEx team at Shopify so I can work on Tapioca
<caleb>
but I haven't been there long enough to do an internal transfer yet
<weaksauc_>
ah nice
<weaksauc_>
you in toronto?
<caleb>
nah, Chattanooga Tennessee US
<caleb>
they do full remote as of the pandemic
<weaksauc_>
chatty nice
<weaksauc_>
got some good climbing down that way
<caleb>
climbing, good motorcycle roads, and EPB just rolled out 25 gigabit residential internet
<caleb>
it only cost the same as my mortgage
<weaksauc_>
lol
<weaksauc_>
i have gigabit and it's fine
<weaksauc_>
for my needs
<caleb>
if you ever come through hit me up and I'll come say hi
<weaksauc_>
sounds good
<Guest2587>
caleb @25Gigabit: Oh man, i just got this massive '90s backflash. Nothing changed AT ALL since my last IRC usage back in the day. I was sitting with a freaking dialup modem in Europe and the guys in the IRC channel located in the US had 10MBit LANs in their dorms :-) The numbers just increased on both sides but the gap remained :-)
John_Ivan__ has joined #ruby
<adam12>
caleb: Weren't you RV'ing it? Or am I misremembering.
<adam12>
Guest2587: I was one of the first recipients of cable internet here through the beta, and we had a very popular local channel... with lots of dialup users. Sometimes it was nice to flood annoying users off without much difficulty.
John_Ivan_ has quit [Ping timeout: 260 seconds]
<adam12>
bbl.
<cartdrige>
adam12, i'm using your file splitter code, it's working it seems on my large file.
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
grokify has joined #ruby
grokify has quit [Ping timeout: 260 seconds]
bhaak has quit [Ping timeout: 260 seconds]
bhaak has joined #ruby
ur5us has joined #ruby
Guest2587 has quit [Quit: Client closed]
finsternis has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
Pixi has quit [Quit: Leaving]
Pixi has joined #ruby
c10l has quit [Quit: See ya! o/]
c10l has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
polishdub has quit [Ping timeout: 260 seconds]
Vonter has quit [Ping timeout: 268 seconds]
D_A_N has quit [Quit: leaving]
ur5us has joined #ruby
grokify has joined #ruby
Linux_Kerio has joined #ruby
grokify has quit [Ping timeout: 260 seconds]
Linux_Kerio has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 268 seconds]
Vonter has joined #ruby
otisolsen70 has joined #ruby
otisolsen70 has quit [Remote host closed the connection]
otisolsen70 has joined #ruby
Sankalp has quit [Ping timeout: 260 seconds]
Sankalp has joined #ruby
kerunaru has joined #ruby
teclator has joined #ruby
cartdrige has quit [Ping timeout: 268 seconds]
cartdrige has joined #ruby
dionysus69 has joined #ruby
cartdrige has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
cryptkeeper has joined #ruby
Aminda has quit [Remote host closed the connection]
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
gr33n7007h has joined #ruby
lutrinus has quit [Ping timeout: 252 seconds]
D_A_N has joined #ruby
lutrinus has joined #ruby
fandre1986 has joined #ruby
John_Ivan__ has quit [Ping timeout: 268 seconds]
<adam12>
cartdrige: Neat.
lutrinus has quit [Quit: lutrinus]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
lutrinus has left #ruby [#ruby]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
lutrinus has quit [Client Quit]
lutrinus has joined #ruby
grokify has quit [Remote host closed the connection]
FullMetalStacket has joined #ruby
grokify has joined #ruby
D_A_N has quit [Quit: leaving]
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
D_A_N has joined #ruby
grokify has quit [Ping timeout: 260 seconds]
cartdrige has quit [Ping timeout: 260 seconds]
polishdub has joined #ruby
sagax has quit [Ping timeout: 246 seconds]
kerunaru has quit [Remote host closed the connection]
FullMetalStacket has quit [Read error: Connection reset by peer]
FullMetalStacket has joined #ruby
FullMetalJacket2 has joined #ruby
smp_ has joined #ruby
smp_ is now known as smp
smp has quit [Ping timeout: 260 seconds]
fandre1986 has quit [Quit: Connection closed]
constxd has quit [Ping timeout: 268 seconds]
lutrinus has quit [Ping timeout: 260 seconds]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
Linux_Kerio has joined #ruby
FullMetalJacket2 has quit [Quit: Konversation terminated!]
walez has quit [Ping timeout: 268 seconds]
grokify has quit [Remote host closed the connection]
Rounin has quit [Ping timeout: 268 seconds]
meuk has joined #ruby
<meuk>
Howdy :)
<meuk>
I'm learning ruby and understand that methods that have an exclamation mark mutate in some way. I am wondering why Array#pop doesn't have an exclamation mark?
<leah2>
mostly, ! is only used when there's also a non-destructive variant
<leah2>
but for pop that doesnt make sense
<leah2>
compare .reverse vs .reverse! etc
dionysus69 has quit [Ping timeout: 260 seconds]
cartdrige has joined #ruby
<adam12>
meuk: Hello!
<meuk>
leah2: Yeah I can see that. You _want_ to mutate an array with pop.
<meuk>
adam12: Hi
<meuk>
:)
<adam12>
pop, shift, and unshift I think have enough long-standing history in CS that everyone expects them to mutate their receiver.
<meuk>
Yeah, I came across them in other languages.
<adam12>
(lunch time. bbiaf)
<meuk>
I was even wondering why they are called like that, but decided to let that question go as I don't want to get sidetracked.
<meuk>
adam12: Enjoy your lunch, thanks for the reply.
<meuk>
leah2: You too, thanks.
dionysus69 has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
cartdrige has quit [Ping timeout: 268 seconds]
_ht has joined #ruby
grokify has joined #ruby
___nick___ has joined #ruby
grokify has quit [Remote host closed the connection]
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #ruby
grokify has quit [Remote host closed the connection]
cartdrige has joined #ruby
hightower2 has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
Guest9741 has joined #ruby
grokify has joined #ruby
<caleb>
adam12: we were full time RVing however we stopped late this year. Our 3 year old just wasn't getting the amount of socialization we were hoping for from other full time families and the people we would meet up with.
<caleb>
we close on a house in a week
<adam12>
caleb: Ooh. Congrats.
<caleb>
thanks!
<adam12>
Chatanooga?
cartdrige has quit [Remote host closed the connection]
grokify has quit [Remote host closed the connection]
<caleb>
yup
<adam12>
caleb: How's the tech scene there?
<caleb>
it's actually really good
<caleb>
all because of EPB
<caleb>
there's 3 dev groups, though really only 1 or 2 matter
<caleb>
lots of rubyists in town
<caleb>
I like to think we're the great value brand portland when it comes to ruby
<caleb>
at one point all the good rubyists in town worked for Clearbit. Had a big office and everything.
grokify has joined #ruby
<adam12>
I didn't realize that. What made you pick Chattanooga?
<caleb>
I really love the smokey mountains, the outdoor scene here is amazing, great motorcycle roads, $300 10 gigabit residential internet, tech scene is good, already had lots of friends here.
aeris has quit [Ping timeout: 255 seconds]
<caleb>
future climate wise we have the tn river flowing through, we have one of the largest hydroelectrical battery storage in the form of raccoon mountain, and a nuclear power plant as well
grokify has quit [Remote host closed the connection]
<adam12>
Yeah, that sounds quite nice, tbh.
<adam12>
IIRC, Chattannooga had a great night-time scene too (not that you get much of that with a 3yo)
grokify has joined #ruby
<caleb>
yeah I don't stay out too late often unless coworkers are in town. But there are lots of good evening hangs
<caleb>
I walk down to a place called Tremont Tavern once a week and almost always strike up a fun conversation
<caleb>
there's lots of tech money moving here though so prices aren't average for a city in the southeast
aeris has joined #ruby
<caleb>
the more the merrier though, I'd love for more tech people to move here
<caleb>
it only gets better
grokify has quit [Ping timeout: 260 seconds]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
<dorian>
hey random question: is method resolution at the class level notably slow?
grokify has quit [Ping timeout: 256 seconds]
<dorian>
i was running rbspy on a long-running process and noticed a call to `self.class.foo` taking up like 40% of the runtime, but moved it to an instance method and it sped right up
<adam12>
I bet it's the self.class part.
<adam12>
If you could resolve it to a constant and stick it somewhere, it's probably faster.
<adam12>
I think this was a Rails issue for a while, because they use self.class a lot.
<dorian>
i have a class that has a bunch of stateless methods which i wanted to be able to access directly but i didn't wanna do the `extend self` trick
<adam12>
module_function maybe?
<dorian>
yeah i just ended up doing `define_singleton_method :foo, method(:foo).unbind`
<adam12>
I can't find the thread, but I feel like one of the Rails core team was complaining about self.class lookup performance.
<adam12>
Which is funny because I use it a lot too.. but haven't really thought of it much.
<dorian>
for stuff that gets called a lot in loops (which this was) it made a huge difference
<adam12>
I feel like Range#to_range should exist (returning self, obviously), but then I wonder if that's crazy, because there's no Object#to_range... hmm.
<weaksauc_>
i think it should too
weaksauc_ is now known as weaksauce
joto has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
phenom has quit [Ping timeout: 268 seconds]
phenom has joined #ruby
<dorian>
ruh roh, just dumped pry and reloaded it and that define_singleton_method trick no longer works, lol
<caleb>
what's the `define_singleton_method` trick?
<caleb>
I mean, I've used that before but I'm not sure in the context of pry
<dorian>
oh, above
<dorian>
i had originally had a bunch of class methods (because they are stateless) but it turns out `self.class.foo` is *EXTREMELY* slow
<dorian>
so i am turning them into instance methods but i also want them accessible as class methods (because they are stateless, and they are useful)
<dorian>
ie so i don't have to instantiate a given object in order to use some random method
<dorian>
anyway i had rewritten them with `define_singleton_method` but was just checking via `reload-code` in pry
<dorian>
i exited pry and restarted it and that construct no longer works