The Hidden Gems of Ruby - RUBY 651
Valentino Stoll takes us on a tour of the "gems" of features built into the core Ruby language. We explore tips and tricks for using irb that can also improve your Rails console.
Show Notes
Valentino Stoll takes us on a tour of the "gems" of features built into the core Ruby language. We explore tips and tricks for using irb that can also improve your Rails console.
Links
- Dependency on mimemagic 0.3.x no longer valid
- Add this `.irbrc` file and your Rails console will show a colorized banner with the environment | Twitter
- GitHub | pry/pry
- Ruby Jard
- Tree-sitter
- GitHub | ruby/ruby
- GitHub | ruby/reline
- GitHub | tree-sitter/tree-sitter
- GitHub | bcicen/ctop
- codenamev
- Twitter: Valentino Stoll ( @thecodenamev )
- GitHub: Valentino Stoll ( codenamev )
Picks
- Charles- SodaStream Aqua Fizz Sparkling Water Maker Bundle
- Charles- Soda Stream Flavor Syrups
- Charles- Teachable
- Charles- ThriveCart
- John- Char-Broil: 6-Burner Cart Style Gas Grill, Stainless/Black
- Luke- Dependency on mimemagic 0.3.x no longer valid
- Valentino- GitHub | reenhanced/gitreflow
- Valentino- Bitbar
- Valentino- Twilio
- Valentino- Twilio Powered Minecraft Server on AWS
Transcript
Hey, everybody. And welcome to another episode of the Ruby Rogues podcast. This week on our panel, we have John Epperson. Hello, everybody. Luke Stutters.
Hello. I'm Charles Max Wood from devchat.tv. Just wanna shout out. Go check out dev influencers.com if you're looking to be a dev influencer. I guess that's pretty straightforward.
We have a special guest this week, and that's Valentino Stoll. Valentino, do you wanna introduce yourself? Let everybody know why you're awesome and all that good stuff. Stay there. Sure.
I'm a software engineer at Doximity. I've been working there for quite some time now. I've been working on Ruby quite a long time, and it's kind of my go to crutch of a language, if you will. But I I really enjoy, hacking away on embedded systems with Ruby. That's been my my latest craze.
And, you know, I I I've really been digging deep into the Ruby core library and kind of just exploring it. And, it's really not that scary. So I'm I'm hoping to kind of make people a little make it a little more approachable for people and, hopefully get some more contributors out of it, including myself. Nice. So we have you on the docket to talk about the hidden gems of Ruby's IRB.
But before we dive into that, you said embedded systems with Ruby. So are you using, what is it, mruby for that? Or For some projects I have, primarily, I've been working on a Raspberry Pi. I'm I'm no expert, so I picked up one of those starter kits that has a bajillion tiny little components to work with and slowly chipping away at converting some Python examples. To prepare for this episode, I also bought a, collection of Raspberry Pi related devices.
Oh, there you go. Could code along with Valentino's Ruby guide. And, as he says, the Python Python has infested absolutely infested the Raspberry Pi ecosystem. There's Python everywhere and trying to trying to root it out trying to root it out of your hardware, getting getting a kind of really pitchfork and digging all of the Python out of the examples is really, fantastic work. So thank you very much for doing that.
Code by code, we'll, make it through. Gross Python. Anyway so, yeah, we'll we'll send people over to your, Raspberry Pi, Ruby stuff because that that that's just cool stuff. In fact, we should just get you back to to nerd out with that on anyway. Sure.
But, yeah, let let's talk about IRB because it's a tool that we kind of all go to whether we realize that it's the Rails console kinda runs on top of IRB or whether we just run it ourselves and then run stuff in it. Why don't we kinda go with kind of a high level overview of what IRB is for people who are just getting into Ruby, and then we can just assume that people know it and use it, and we can dive into, okay, stuff you didn't know about. Right? Sure. Yeah.
I mean, IRBs, these are just a REPL. They give it input, and it'll evaluate the Ruby that you give it, analyze the syntax of it, and then directly show you the output for whatever that it is that you give it. Mhmm. So people work in rebels all the time. If you open up any console, that's a rebel in a a bash shell, basically.
But Ruby's IRB kind of has a hierarchy to it that, you know, breaks up all the different pieces of it into little modules that then pipe through as it's going through and evaluating just the strings that you're giving it. And it could does that in real time, And it does that basically in what they call a session and wraps that in a context and then evaluates it inside of a binding, which is really the underpinnings of Ruby. Ruby's own core evaluation is the binding object. And then through the binding, it can basically compile Ruby on the fly into, you know, low level code and do whatever it is that you tell it to do. You know, IRB, I it it's kind of like what gets you really into Ruby.
Right? You go and you're you're trying to learn a new like, try and learn any new language, even JavaScript as an example. You'll go and what do you do is you open up the JavaScript console, and you try and play around and move elements around or, you know, try and be the first to purchase a pair of sneakers or something like that. But, you know, what learning Ruby is so easy. You'll do the same thing.
You open up a IRB session, and they just type anything that you want, and you could play around with the language. It's it's pretty powerful. Yep. Absolutely. So, yeah, I I don't wanna go too deep into, you know, what it is, and you kind of, connected the dots, I guess, on how it evaluates code.
But but I I'm always looking for kind of the the neat tricks. Right? So so let's start there. And then if we have time, we can come back around to internals or other things you learned while you dove into this. Sure.
So so what are the neat tricks? Like, what what were the the things that you didn't know it did that that it does? So coming into this, definitely the customization of the prompt itself. So I believe it was, it was Matt Swanson that I discovered the, you know, customization of the prompt for when you're in a production server that you could just signal, hey. This is a different server than your development console.
You might wanna be careful what you write in here. And from there, it kind of just exploded into, okay. Well, what else is in this customization? And, you know, you open up your you find out you start you start with the IRBRC as, like, your starting point, and it kind of leads you into the rabbit hole of customization. And what I realized is that you can basically make this file that will evaluate anytime you open up IRB and do whatever you want with it.
So anytime you're trying to, you know, open up specific set of code in a specific context, you can make a custom IRB file for whatever that context might be. So that was probably my biggest, you know, moment is and as an example, what we eventually ended up doing, Doximity, was making a a special Rails console that tagged the system internally to say, hey. Any changes made to the database, you know, make sure they're attributed to whoever the current user is. So we implemented that and then allowed, you know, full auditing for whatever user was logged into the system, you know, with just a simple little Rails customization. Gotcha.
So so then we know, you know, John is a witch. He turned me into a newt. Right? Yeah. Exactly.
I got I got better. Anyway. Yeah. But, yeah, you could see where that change happened. Right?
And you can go and you can reverse it or go slap somebody's hand or something like that. Right? Yeah. More for accountability than anything else. You say, hey.
You know, what were you doing during this change? Sometimes you just need to audit the specific scenario of a change so that you can go and make sure it didn't affect anything else, you know, as a side effect. Yeah. Makes sense. Do either of you, Luke or John, use a custom I what is it?
IRBRC? I didn't even know it existed. Is this the same thing as pry? Because I use pry all the time. I know.
I know it's not. But but but I get like a question for me. I know he's good. He's IRB pry. No.
Short answer, no. I mean, there's a kind of a discrepancy to hear. And it's 2 worlds colliding where somebody made a better IRB at one point. And now kind of the features of pry are sneaking into the native Ruby IRB, and that awesome. Yep.
So, I mean, they're very they're they're completely different things at this point. What what about the rails console then? It it's built on top of IRB. Right? Yes.
Rails rails console is wrapped on IRB. Unless you install rails pry and then you hook into IRB. Yep. Yeah. And it pry has a pry RC, doesn't it?
It does. Yep. Yeah. So so what does rails do in order to torture or otherwise modify IRB? I haven't looked into it.
You haven't looked at that. Okay. I don't know that it's torturing it. My my understanding. So so, you know, obviously if I'm wrong, let me let us know.
But my understanding is that most of what rails is doing with its shell is just loading a bunch of rails files. Basically, you're just loading your environment. Right. So you're adding to the context. Yeah.
I mean, if you open an IRB shell, right? Even if you open it in your rails directory, you don't have all those files loaded. But if you open your Rails console, it's already just like if you're running a real server preloaded everything and run the initializers and all that kind of stuff. Gotcha. Yeah.
So as as far as, like, what Rails is doing, it's probably just a elaborate IRB or C. Mhmm. Because anything you have in your IRBC will be in the context of whatever that is ends up being the IRB session you're in. So when you do rails c, I imagine it just loads the application and makes, you know, a few things available to the terminal, like, you know, the reload command or something like that. Yeah.
That makes sense. Well, the reload can't command is just part of Rails anyways. So, yeah, I mean, that that, yeah, makes sense that that would be in there. Yep. So I mean, that's that's kind of the value of the IRBC too is, like, you could define methods in there that do whatever you want.
So, you know, Rails has the customizations with a bunch of methods that it'll inject into the session and, you know, give you that available. So I I have some myself, which will will give me me as an example. So then I have a, who am I, Right. Basically, that gives you access to your current user's name and, you know, a bunch of related ones to that. See, now I wanna create an evil IRBRC that, like, redefines common methods off of kernel.
I mean, what you could do is you can make your own input method that then remaps all of the characters. So as you're typing, it'll output a different character. Yeah. Yeah. Sounds sounds like my my Apple butterfly keyboard.
Already implemented in hardware. That's what's John John is saying. So good. It's it's Yeah. My It works.
My butterfly keyboard, it didn't do that. It was just p p p p p p p p p p p. You know? Yep. I just tapped it once.
So, alright. So I have this really sweet so so first of all, I've actually done the auditing thing. Right? We did do it through an IRBRC or whatever the, we did differently or whatever. So that totally makes sense to me.
But you guys you guys implemented that through your IRBRC? Not technically the IRBRC. We have a custom initializer for rails itself that will just make some modifications to the rails console itself and then start up, kind of call super on it. Okay. So so we're just talking about extensions here to our environment.
Alright. Yep. No worries. No worries. So this kind of environment automation and the warning is kind of really important for you because you're dealing with medical data and things.
So it's kind of really important that you don't get it wrong? Yeah. That's right. And, I mean, the customization of the prompt too is just hugely helpful, especially when you have to jump context through many servers. So we have a proximity, a series of staging servers that are separate from development, right, so that we can add quality control and test out a lot of our changes.
And then we have several production servers that are, you know, are all different. And it's nice to see them labeled so you know instantly, especially if you have a bunch of different terminal windows open, right, that all have a IRB session in it. You don't wanna get confused about which one you're in. Right. Of course, I've worked at a lot of places that don't even give you that kind of access to to the production systems to even be able to run IRB.
Right? I mean, you might your your ops people might be able to do it. Right? And you might be able to give them specific instructions or check-in a rate task or something that will do with the work, and then they can run their rate task for you. But yeah.
Yeah. And I mean, we don't all have access. And, it's it's certainly limited. But somebody's gotta log in when That's true. Systems go down.
Yeah. And it's Friday afternoon, and we're trying to do some stuff. Like, just it just happens. You know? Yeah.
This is the kind of double edged problem of this your sphere is because not only does it have to be really high security, but it also has to be high level availability because the code is literally saving people's lives. Right. Yep. Alright. So we talked about some stuff that's coming over from fry.
I I actually I'm like super interested because as a very heavy user of pride, basically, since I discovered it, like, I don't know. I don't even remember. Because I don't remember my life before pride, to be frank. What are the odds you're hijacking? This IRB talk with pride.
I mean, okay. Alright. There are there are times when I load up IRB. Right? And it it's primarily when either I'm writing like a Ruby script.
Right? So I don't have a rails thing going on. Right? And Mhmm. You know, and I just wanna load something up really fast.
Or if I'm working on a very large rail system that takes forever to load and I just wanna test out something really fast. So then I just, like, load up IRB, require 1 or 2 files, and do the thing, and then exit. Right? And in both of those instances, one of the first things that I often do is I I type IRB and then I go require PRI. So I have not lived without PRI for a very long time.
So what are some of the cool features that that we'll get over if you know them? Sure. I know a couple. The I mean, a lot of these are, like, brand new, like in rails 3, but they there was just merged a, a pry like LS command. So you can basically list all the methods on a particular object as an example.
I imagine the next step to that would be, you know, the CD command to pry where you can, you know, basically move into the object, and you can kind of already do that with IRB because you can run IRB on any Ruby object and enter inside of the context of it. So if you make an instance of something and you IRB that instance, then you're in the context of the instance. And you could do the same with the class at pretty much any, you know, object in Ruby. How do how do you do that? How do you go inside the objects?
Sure. So when you're in the IRB console itself, you just run IRB and then the the object. So if you did, you know, string new and you just said IRB string new, you can enter inside the instance of a string and play with all the methods like that. You don't have to do the strings object name as the variable and then dot whatever. You just enter the method.
So it's kind of a fun way to explore the object. And without having to, you know, run a bunch of chain methods. You can get it all You know how smart you know how smart I'm gonna look at work tomorrow. I didn't know that. I did not know that.
I didn't either. Yeah. And I mean, another another cool thing, which pry gives that maybe you just don't know about IRB is you get a lot of context from the source code, just using the method method. Right? So when you say, you know, method and then colon some the name of some method, it returns a special Ruby object that describes what the method is, what it does, the source location, and you could pull all that information to open up a new you know, I use Vim as my command or as my editor.
So I I often well, I'll I'll have a, special, you know, method in my IRBRC that allows me to open a VIM, you know, editor with whatever the source location is for the method that I'm interested in in the context of an IRB session. So it ends up, you know, being a you can open up any editor. It can be doesn't have to be Vim. Yeah. Right.
But Yep. No. That makes sense. That that sounds really handy. Yep.
So the only, the only yeah. One of the main reasons that I like price actually this, but it's not, cause you just use show desk source. Right? Right. But it's mostly because it's complicated to remember all the steps that you have to do, right.
To grab the method as an object, then call, you know, source location or whatever. The other, the other thing that's an issue here is that pry actually does a reasonably good job. Now. It didn't used to, but it does a reasonably good job of showing me, like, all the dynamic stuff that goes on when I, like, prepend 8 things into which, you know, is just going to cause problems anyway. But, you know, if I'm overriding my method a 1000000 times in weird odd ways, things can get weird.
So yeah. And I don't know if anybody else has has looked in, and not to plug pry again. But the pry there's actually a project called RubyJared that combines pry with buy bug, and it's pretty incredible. You you basically can do just like you can, you know, binding dot IRB in your source code, or, you know, pry in your source code. You can do a JAR in your source code.
And when it stops the execution, it has this really beautiful kind of split pane debugging session where it shows you the current line in context, but also shows you some lower level, like, definitions within that context. And it's it's pretty wild. I definitely recommend people check that out. I've been using that on a couple projects as well. But IRB is still my go to for, you know, just testing out random Ruby files.
Yep. I'm pretty sure I saw that in a Ruby weekly, and I just a bit slow to get around to looking at it. But I like pretty things, so I'm we'll be checking it out. Yeah. That's really great.
Alright. So some sweet, any other, like, things that are coming over so we can wrap up that part? Sure. Yeah. Let's see.
From from pry itself, I'm not sure. I do know that they the IRB itself has introduced kind of, some tracing mechanisms and, measure utility to make it easy to, you know, trace the execution of specific method calls, while you're going through as well as, you know, processing time. So I actually do that for a lot of just quick performance testing of, you know, will this array method lookup work faster than this one in this context? You know, just turn on the measuring processor and just check how fast it runs with each case. That's the thing that comes with Ruby 3, right, specifically?
Yeah. I believe so. So that's really nice interface because it just does it for you after you turn it on. Yep. So you type measure, and then anything you run from your IRB or whatever after that gets measured.
Yeah. And it's line by line measuring too. So whatever you enter, every single thing will be, you know, show you the processing time for it, which is really nice. Is that combined with the tracing stuff? So is it gonna so if I if I create if I turn on tracing, right, and then it's giving me my whole back trace, am I also getting whatever we call benchmarking, right, for each of those lines?
Yep. That's pretty sweet. I'm gonna go into my IRBRC, and I'm gonna alias that to vanity. It's still type in vanity, and then it'll tell me how fast all my stuff is. What else is coming to Ruby 3?
Oh, go ahead. I was gonna say, I saw one thing that I saw that I thought was really nice in the article that that it kind of spawned to this particular interview was that IRB is getting colors now. I don't have to Oh, yeah. Something separate to get colors. That's that's actually in, 2.7.
So if if you're already on 2.7, you should have colors. Nope. I'm part of the same crowd skipping from 2.6 to 3. Oh, there you go. We we did we did the scientific for that.
Go ahead. No. I believe it's turned on by default. Okay. Okay.
But one other thing I will note, at least with Ruby 3, but actually it's 2.7 was the, the inline documentation. So if you just double tab while you're on a particular method name, it'll give you the documentation in the context, kind of like a man page. Oh, nice. And it and it does that through our docs. So I don't know if anybody else here has a gemrc that doesn't include documentation when, you install gems because it takes longer.
I used to have that. Dash dash dash dash Yep. So I've turned that back on now because it's so great to see, you know, tab tab. How does this method work? I use that all the time now.
Well, yeah, because you had to use the command line utility to get our docs before or open up some kind of wonky web interface, and it just was never worth it. Right. But if it's in line when I'm working, that makes a lot more sense. Yep. Because because real to be frank, the only good docs readers were all web browsers.
And so whenever whenever my Internet goes out, I have to be like, oh. And then, like, go re remember how to get my docs working locally again. Like, for the 3 hours that it's up. Yep. Or get it on the 5th try.
Oh oh, these are the right parameters. Yep. That's super cool. Yeah. It's also you know, if you use a higher level, like, documentation app, right, which has some nice things as well.
Like, if you I use Dash as an example, but it has some drawbacks and that you have to know what you're looking up. And so it's it's nice having it in the direct context that you're in without having to go, okay. Let me go to this other app, you know, look up this context, this method. Yeah. I, I stopped using Dash because I didn't like paying for it.
I felt like my web browser version was better. It just this this is kind of what I meant, but the web browser version is weak whenever my Internet goes out. So Right. Yep. 22.
I don't pay for the dash. I just wait for it to load. So you mentioned the banner thing that that kind of, like, started you down this road. Were there any were there as in as somebody who likes my console to look aesthetically pleasing, you know, were there any things that you were just like, oh, yeah. No.
Now I do this all the time. Customize my RV show and, everything is, you know, pink and green or something. I don't know. I Sorry. I have a lightning.
I shouldn't say that. Sure. Pleasing stuff and then immediately pick those two colors in conjunction. But I have a thing with lightning bolts. My, you know, starting prompt is a lightning bolt.
It tells me I'm in IRB. That's kind of nice. My I used to, for the longest time, use there's a theme that has a cloud. And when you have changes in, your Git repository or in whatever repository you're working with, it'll show a lightning bolt to tell you that there's changes made so you know whether you're clean in a clean state or not. So it's just fun.
That's cool. It was kind of interesting making the custom prompt, because I was just, you know, playing with it, seeing what you could do. And so I had actually picked up the quoting. So when you're in different modes in IRB, so example, like, in a string and you have a string open in line, that basically has a signal to IRB to style it differently. And so I, you know, I wrapped it in the quotes icon so that like an emoji quotes, which was kind of interesting to to use on a regular basis for a while.
So I definitely will be using some emojis in my prompt for for a while now. Nice. I was trying to figure out how to get an x wing on there. Hey. It's possible.
Real emoji? Probably not. I don't know. Just probably everything in the emoji space. What am I saying?
You might be able to find an emoji font that has it. You know, it's like a it's a smiley emoji, except it's I don't know. There's probably a power line font out there with it in there. Yeah. Anyway, very cool.
You mentioned, yeah, that you kinda got into this because you you saw somebody else doing some stuff with it. What's the story as far as, like, you learning this stuff? Right? Because I'm I'm assuming there's a bit of a journey there. And, you know, it didn't just, like, you know, upload to your brain.
Right? So so what was the journey there? And how did this kind of get implemented over time at work and things like that? Sure. I had dealt with IRB customizations for a long time.
So I was familiar at least with the notion of IRBRC and and being able to kind of customize small things. But I didn't know the extent at which you can do it. Like, probably another topic of conversation or blog post is the the history itself, IRB, and you can kind of save those histories in as files. So you you could in essence and that's kind of where I'm gonna go next with some of our servers is to customize the IRB session per user so they all have their own history, especially when you deal with a a shared server setting. You run into a lot of oh, you hit up a few times and you're scrolling through somebody else's history that's sharing the session with you.
And so that that's an easy fix, scoping to a particular file. And so it started, you know, just small realizations over time of, oh, hey. You can do this. You can do this. And then finding the actual need was we have we have these hack days at Doximity where the whole team will split up and work on some anything in particular that could help be useful for the team.
And one of the problems we had was this auditing in that our auditing would be had to be explicit explicitly set anytime any user logged into a IRB session or rails console. And so, you know, sometimes it would be forgotten. The auditing would get missed you know, get lost, and we'd have to go back and readdress those data concerns. And so it somebody was like, hey. It would be nice if we can just automatically do this.
And and that basically is what started me down this rabbit hole to begin with. Is that possible? 1. And there were some prerequisites to that in that, you know, how do you know what user in the system is related to the user that logged in to the server? We happen to have some, you know, formalities in place that lined up those usernames.
So and I know working out really well and and being easier than was expected. And then so as you go through and once you have a custom rails console, it makes you think, oh, well, what else can we put in here? What other, you know, proximity specific customizations can we inject inside the Rails console, limitations, you know, how can we add restrictions, things like that. And it becomes very easy once you have that place, that source of truth to kind of make those customizations. And I I work in the terminal almost exclusively.
That's kind of why I Right. Yeah. Because because Vim but more so, I I have a very elaborate TMUX setup as well that I've just grown comfortable with. And so I try and do as much as I don't like leaving the console at all. Even I've been looking at a couple projects to do even code reviews from the terminal.
They're not quite there yet. But that would be my my dream to just, you know, never leave. You know? I used to use oh, what was it? There was a chat service for a while when, Campfire was around that allowed you to do that from the terminal as well.
Maybe it was WeChat. Mhmm. But that would that would be my ideal environment. So, you know, playing around with IRB and being able to do as much as possible there, you know, open up any files, you know, send things to the background when I don't need to use them kind of thing. It this is a very nice workflow.
So Gotcha. That's that's kind of my foray into the IRB space was, you know, what is possible? What can you do with it? And how can you make things easier to develop? Right?
Can I ask you about the ripper? Sure. So this is from the Hidden Gems Ruby article. The the ripper, it says, is a lexical analyzer, and you run a when you run a ripper command on a hello world, you get loads of stuff out. How did you how did you, get into using that?
And what what what are you using that for? Because that, to me, looks incredibly technical and obscure. So mostly, it's for analyzing memory usage. So with the instruction sequence compiler, you can then use it to see how Ruby is, you know, making those instructions on the low level and kind of it's it's a helpful way to debug how it's compiling those instructions. And sometimes you when you're debugging a particular memory issue, you can elaborate on that using the lexical analyzer to see how it's constructing it on the back end.
Got it. So if you if maybe you if you're calling in some external library that's, memories going missing that kind of situation? Yeah. Something like that. It's mostly useful for really cross compiling.
What do they call it? Transpiling? I haven't used it for that. But I know what is it? Opel or or Ruby Opel.
There was some kind of project where they're translating the Ruby code to JavaScript as an example. So that's that's primarily the value of ripper is its AST kind of generalization. So I don't know if anyone's familiar with TreeSitter, which is what GitHub uses as their code hinting. So anytime you've, you know, been on GitHub in a code review and you've, you know, hovered over a method name and it shows, hey. This is defined in this file.
They actually use an AST called tree sitter that they've made with Rust. It's it's pretty wild stuff. It is pretty cool. It doesn't catch all the all the dynamically named stuff or the dynamic calls mostly. But yeah.
No. Unfortunately. I mean, that's Ruby. Rails specific mostly. All those after commit things that you're Right.
One of the things that I I noticed in here was the switch from read line to read line. So does that mean that we're dropping the the read line dependency? Like, I guess, I tried I tried to look that up, and I couldn't find a answer real fast. I don't happen to know if you I don't know. I I unfortunately, I haven't joined the Ruby forms themselves yet.
I I imagine that will come soon when I wanna add a feature to IRB or something like that. But, so I don't know what they have plans for it at at at this moment from just the master branch of the repository, or have they moved the main branch? I'm not sure. But they haven't removed it. It's still there.
So they at least have it backwards compatible. But, yeah, that I mean, that the realign's really cool because mostly for the multiline support. So if you paste it in, I don't know, 15, 20 lines of Ruby code, you can actually just scroll up and edit it right in place. You don't have to go and, you know, line by line edit and hit up again. It's it's really nice to work with.
Does it does it increase my buffer for pasting now that you're talking about pasting in here? I I can't answer that one. I haven't played with that. Always had a problem with that when I'm, like, writing long scripts or something. Cool.
So I'm kinda curious now that you've dived. It's it's so funny because talking through this, I'm sitting here going, man, I really kinda just took this for granted that it just worked. Right? But Yeah. Now that you're yeah.
Go ahead. I was gonna say that there was a a few years back where I was looking at somebody had tasted just the lib directory of Ruby's repo, and there's a ton of Ruby files in there. And at first, you know, it's just like delegate class or something like that. Some simple ones that I could recognize, and then you realize, well, there's a bunch of other gems in here that are I guess this is the core library. Right?
That's what's included. And that's kind of what got me to to IRB eventually is that, you know, there are all these cool things included in Ruby. And I imagine the same with Rails, right, where there's just way too many features for you to know all of them. Right? But if you just spend a day and and poke around, you're, like, really surprising how much stuff is in there.
And I'm kind of hoping to turn this into kind of a more longer form series on what's included in in Ruby's, you know, core library. Because there is just so much, like, like you were saying, you know, you don't even know you take it for granted that all this stuff is there. You just open up an IRB session and do what you're trying to do in the moment and don't realize kind of what's all available to you. Yep. So I guess what I'm kind of aiming at next is you've done all this work to understand IRB, understand how it works, you know, dive into the feature set.
What do you wish it had that it doesn't? That's a good question. I guess I wish it had more native integrations. Like like, as an example, you know, being able to use Versus code or something like that, and, you know, hooking up IRB to the editor So you can evaluate, you know, various things live from within the editor, which I know are kind of external to the Ruby source itself. But it would be nice to have kind of some more native things, even like a mechanism that would make it easier to make more more extensions to IRB.
Like, say, for example, this JARD project, which I know is built on something that's kind of a competitor to IRB. But they're basically they have a ton of modules that make it easy to do, you know, x y z. It would be nice if there were support from the, you know, Ruby core team or or something like that, that could help expose what's available, and make it easier to extend and say, Hey, this is how you do it kind of thing. Right. It kind of sounds like IRB is giving you a lot of what you want already.
I know it's hard to poke in these holes. Yeah. I mean, they already add extra features that I wouldn't have thought about. So Yeah. Fair.
Alright. Well, anything else you all wanna dive into here before we do PIX? Alright. Well, let's let's go ahead and shout out about some cool stuff. John, do you want to start us off with picks?
Yeah, I will. So I, I just recently replaced my grill, my grill of over a decade. It just I replaced the grates a few times. Anyway, I've tried to keep that thing alive because I had it was one of those, like, double sided. One half was gas, one half was charcoal.
And I was very happy that I got it. And I got it for, like, $200. And so, you know, I got it like a decade ago, and I'm like, oh, sweet. I have I'm ready to spend $200 on a grill and, like, like, $200 will buy you, like, little dinky thing that sits on the ground, and you may have to crouch down and use it. So I was like, oh.
So I had to reevaluate a lot. And, I went around, dug around, and event I was just pretty angry that everything that I wanted to buy was, like, $600. But I eventually, like, found something that was pretty good, and I've been using it for, like, 2 months now. So I've been pretty pleased with it. I had to give up having one side charcoal and one side gas in order to get a good gas grill, because apparently, they just they just don't put those 2 together unless you're willing to spend, you know, a small fortune on it.
But yeah. So I found, like, this nice gas grill that gave me, like, 6 burners and, like, didn't completely bank break the bank at $350. So I was pretty pleased with it. I'll put a, like, link to it or whatever. But it also wasn't a deal because, like, there was a different grill that I really wanted that was, like, the $400 price point.
Only, like, my wife was like, well, you need to you need to think over it for another night. And I was like, but I have been thinking about it for, like, a month now. And this anyway, whatever. The deal was gone by the next day. So this one has stuck around for a while.
So at about that price point, so that seems like this is probably its natural price point. So yeah. Anyway, got a sweet grill, and it works pretty swimmingly for what it is. So and now I just have to work on convincing my wife to let me buy a separate charcoal burner so that I can do charcoal stuff when it when I have, like, more time or something. So Right.
So I like that. That's that's my pick for this week or whatever. Been able that's been very helpful because I my wife does not like Mexican food, and the number of things that I can cook that are not on a grill are pretty much all Mexican foods because that's, like, that's how what I grew up eating. So that's what I know to make. So, yeah, my wife very much appreciates that I can grill some stuff since, we are dealing with baby things.
Nice. Alright. Luke, what are your picks? Well, I've gotta pick my magic, haven't I? The, MindMax Magic gem is definitely my pick.
We what a marvelous gem it is. And, you know But only version 3.5 or lower? You know you know, John, how we were talking about, JavaScript features kinda coming into to Ruby 3? Well, now we've got kind of MPM features coming into, the gem ecosystem the Ruby Gem system. It's really we're really, really taking our lead from, JavaScript at the moment.
So I've linked to an issue on, GitHub where some developers are saying that because this license changes to GPL, then everyone has to release all their source code. This really isn't true. This is this idea of a viral license was introduced by Microsoft in the early 2000s. And if, you know, you can go with Peter and look it up. And it's kind of a slur used against the free source free software movement that that there is this kind of nasty license that if you include it in your code, then you suddenly have to release all your source carriers and your business is over.
There is a license called the AGPL, which has restrictions on software as a service systems. But there is no there is no strange magic license that you introduce that suddenly makes you do things. And people miss this miss the point with free software a lot. They seem to kinda confuse it. The whole point of free software is that you have freedom.
And if someone's making you release your source code and you don't want to, that's not really freedom. So, people need to calm down on the on the GPL side of things. GPL's a great thing. It's built the the computing infrastructure we have today. The MIT license is not so great, and, I'm not such a big fan.
But if you don't believe me, look into it for yourself. So there we go. My pick of the week, my magic. Thank you for keeping Ruby interesting. Yeah.
And so I'm gonna pile on that because I was gonna pick, similar. And, essentially, there's an issue in the Rails repo. I think it was introduced yesterday, the issue. And so, yeah, my magic used a list of MIME types that was GPL license in the gem. And so because of that, yeah, it it the the whole thread is essentially a discussion over this, idea of viral licenses and, you know, how it does or doesn't ruin software, which I found to be mostly not helpful.
Ultimately, there's gonna be you know, they're they're gonna talk somebody's gonna talk to some lawyers. They're gonna figure out what they're supposed to do, and then they're gonna fix it so that if you're using Rails, you don't have to worry about it. But in the meantime, yeah, just be aware that this is a conversation that's going on. I'm gonna see if I can find somebody who is an expert on this stuff so we can do an episode on it. Right?
Because I'm not an attorney. I don't know how all this stuff works. I don't know what the implications are. But in the meantime, yeah, it's something to watch for sure. So, I will put a link to the issue in the in the show notes and, yeah, let everybody kinda follow-up on that.
But they did actually close commentary on the issue because after the first probably 20 or 30 comments, yeah, it just kind of evolved into people arguing over what it meant as far as this is good or this is not good. And ultimately, I think what we need to just see is what are the implications for the rails community at large and, you know, how do we continue to be able to write software the way we write software? Because a lot of these conversations about kind of the social structure of software and the legal structure of software are things that we don't really wanna think about. We just wanna think about writing code and enjoying enjoying technology. So, anyway, yeah, we'll get somebody on who can tell us what we have to care about.
So, yeah, so that's one pick. I was looking back through my Amazon history for some ideas on other things I could pick. One thing that I've really been enjoying lately, I have a SodaStream, which is a carbonator. You can make your own soda. They also sell mixes.
And then I just order drink mixes in general off of Amazon, so they have, like, different fruit flavors and stuff like that. I don't drink alcohol, so it's kind of funny because I get this stuff that people add to their alcoholic drinks that just or the flavors, you know, and we just carbonate that. So anyway but I'm really liking it. They have an energy drink flavor and a cola flavor and a root beer flavor. And, they they don't have a cream soda flavor, but you can find one on there that is I get the sugar free flavors because I'm diabetic.
So I'm gonna I'm gonna pick that. I've really, really been liking having that. And so, that's something I'm picking. And then for the Dev Heroes Accelerator, one thing that's really been working out nicely for me lately, that I've been using to get people in and then get them the content they need, I've been using Teachable, and I I'm really liking Teachable. It's a terrific platform for just putting the videos up and giving people what they need there.
And so I've been putting videos up on, hey. You know, during a coaching call, it's a group coaching call. Don't always have time to dive into everything that everybody needs, but afterward I can do a video on it. Right. And then everybody has it.
And so, I've got some videos going up there, which is awesome. Probably gonna turn it into a course at some point, people can just buy one off. Right? And then if you want the, you know, the direct coaching teaching, you know, you can go for it. But, yeah, I'm really digging that.
If you want to apply, you can go to dev influencers.com/apply and get that. I'm also starting a podcast for dev influencers. So if you're thinking, hey. I'm not sure how to grow my career from here. We're gonna be talking about how to grow it by building an audience, making connections through something like a podcast, in fact, specifically through a podcast.
And I'm also gonna be interviewing other people who have built audiences and influence in the dev space and talking to them about how they did it. And, yeah, just giving you ideas about how that can be done. Right? Because some people, what happens is they they kinda become senior devs. They realize that, hey.
The job I have now looks a whole lot like the job I'm gonna have in a few years. Not really what I want long term for my career. You know, I wanna keep learning. I wanna keep growing. You know, I wanna get paid more 5 years down the line kind of thing.
And so how do I do that? They don't really wanna go the architecture route. They don't really wanna go the management route. And so where do we go? So you can go the influencer route.
Right? And it's a lot of fun because you get to meet people. You get to explore areas. You don't get to explore other ways, and you still get to code. And so that's that's kinda what we're doing there.
So anyway, long pitch, but ultimately, I'm doing Teachable and I'm really enjoying Teachable. And then for the cart to sign people up, I've used all kinds of stuff, all kinds of membership software. I hate them all. I hate the shopping cart in Teachable, by the way. It sucks.
But I've been using Thrivecart for for all that stuff, and I really like it. It is terrific. It has an affiliate system that actually works, which is awesome. And so if you're gonna be selling stuff online, I highly recommend Thrivecart. So those are my picks.
Valentino, what are your picks? Sure. The first one I definitely recommend any developer out there is, called Git reflow. It's a tool I actually built a a long time ago now that helps automate your Git workflow. So it creates pull requests automatically for you.
It makes sure to, close out all your branches when you've merged down to your main branch. It does a lot of things that just save a lot of time when you do over and over again. So I highly recommend check that out. Another pick I have is for an app called Bitbar. It's a if you're using the macOS, it's a nice little, kind of menu bar generator so you can run scripts and show icons and various things on a periodic timer, which is kind of nice.
So I use it as an example to see how many Docker containers I have up and how much CPU it's consuming because Docker is painful at that. And a, let's see. I had one one that just escaped me. Oh, yes. Twilio.
I Twilio is incredible. I used it not too long to and not not to shout out to Python, but I used it to automatically orchestrate a AWS server for my kids to play Minecraft with their neighbors. So all I had to do was send a, some commands to a specific Twilio number, and it would start firing off commands on AWS, which is really cool. So that that was kind of impressive how, seamlessly that worked. And their their documentation is really well really well worded and and mapped out.
Nice. So now I have to ask. My kids love playing Minecraft, and they want to be able to play with their cousins, but we do not let them play on public servers on the Internet because I do not trust who's gonna be on public servers on the Internet. So how do I set up a private server that their cousins can get on or, you know, things like that? I just put the link in the show notes that we can add.
Is that what you're talking about, Valentino? Yep. That's the one. So Awesome. Yeah.
It's it was a little painstaking to get set up and configured it. I kind of hoped at some point to find some time to automate this so other people could just spin up their own AWS server that you can whitelist IP addresses, on the fly using Twilio app. So maybe I get to it. Otherwise, you can, you know, go through the setup I went through to get it all configured on your own AWS account. Looks good to me.
It it was it was really fun playing with, Lambda server and and things like that to kind of just spin up, you know, EC 2 instances on the fly. And, my goal was to just drive the price down as much as possible per minute, which is where I got to a nice comfortable spot with, spot instances. So, hopefully, I can get back to it to make it easier for other people to kind of do the same thing. But right now, it's just a a series of Lambda scripts, that just make it easier to spin up stuff. And how much does it cost you to actually run this?
My monthly bill is maybe 3 to $5 a month. Oh, okay. I I feel like yeah. On average, it's around 3. So I mean, they're they use it regularly.
So it's definitely been the cheapest I've found. Just not time wise. No. I like it. Because, yeah, my I mean, especially with my kids, most of my brothers and sisters live pretty close to here.
But even then, you know, they're connecting from their houses. But my wife's family in particular, she has a a brother in Oklahoma, a brother in Texas, a sister that lives an hour and a half away. Right? And so, yeah, it's just it's not ideal. But, yeah, they'd still like to be able to connect and, you know, go play in the same world.
So Yeah. It's been great. So what I what I ultimately did is, made a way for just some environment variables as, you know, the allowed admins to whitelist IPs, which basically just become the parents. Right? Right.
So then any parent that wants to be able to get their kid to join or, you know, to stop their kid from playing or anything like that, they could just text this number and say, hey. Like, you know, remove this whitelisted IP for now. And then it cuts them out of the server. Right? No.
That makes sense. Yep. So it's been really helpful. You know, just to help I mean, it's hard because like you said, like, how do you trust any one of these servers outside of Minecraft's, you know, realms or whatever it is with and, you know, that that is great too. But then, like, any of their friends have to be in the realms also, that becomes this thing of, okay, well, who's paying for what?
Right. And then, yeah, the other question I have then is it just it keeps your e c two so you shut down the e c two instance, but it still saves all the data because it it keeps the hard work around. I have all that backed up to s 3. Right. That's how that works.
So then, you know, as So when they turn it back on, all their stuff's still there? Yep. Okay. Because, yeah, they like to build towers and castles, and they'd be devastated if it disappeared. So Oh, I know.
This is the sound of Chuck's weekend disappearing, Julio. That's right. I have I have 3 things to do this weekend. Now I have 4. But I I'll tell you what.
The 3 things I have to do this weekend make me the hero with my wife, which pays off. Right? And then the 4th one makes me the hero with my kids. And if I get it done this weekend, I get it done a week early for spring break. Boom.
Well, I'll tell you what. My Minecraft servers are not that hard to to get configured and spin up. So at least there's that for you. Yeah. My kids keep asking me to add what they're they're the extensions.
I can't remember mods to the server or to our setup at home, right, on the Xbox. And so that'd be nice too to be able to just yeah. It's it's all about reducing that management time. Right? Like, sure.
Getting it set up the first time is fine. Issue is, like, when you're going in there for the 20th time because, you know, Minecraft is updated and your kids want this cool new mod, and you're, like, trying to decide what dependencies are gonna be an issue or not. And you have to remember because the last time you logged in was 6 months ago, and now you have to, like, go read a million things, and your entire Saturday is gone before you finally finish with the darn thing. Yeah. Yeah.
Luckily, I haven't hit that wall yet. My kids aren't as demanding with the mods. Well, I'll tell you too, though. Like, giving my wife, you know well, I'll just take away Minecraft, and all she has to do is text the number to do it. Yeah.
It's it's pretty huge. Boom. About delegating the administration of it to someone else. Yes. Ultimate power.
Yeah. Alright. Good deal. Well, I've asked you enough questions about that. Thanks for coming, Valentino.
This was awesome. Yeah. Absolutely. I've had a blast. Thanks for having me on.
Alright. If people wanna find you online, I'm assuming you're, like, on Twitter or GitHub and stuff. Yeah. I'm on Twitter, thecodename b, the codename b. Find me on GitHub at codename b.
I have a blog where I post about my experiments with embedded systems and Ruby. That's that's at least been what I've been writing about currently. And that's, blog.codenamev.com. So that's where you could find me. Awesome.
And, yeah, my, my kids' lives just got better because of, Twilio powered Minecraft. There you go. You're welcome. Alright. Honestly, let me know how that goes because I I've been the only one that's used it so far.
Will do. Yeah. You're gonna get you're gonna get an email, and it's gonna be like, this is so great. Alright. Thanks again.
And till next time, folks. Max out.
The Hidden Gems of Ruby - RUBY 651
0:00
Playback Speed: