 Hey everybody, my name is Justin. I've been here since April and this is my first time presenting at a meetup. So please let me know if there's anything I can improve. I'm always open for suggestions. So like I said, my name is Justin Burris. I work for a company here in Singapore called Neo Innovation. We're a Rails consultancy, but we also dabble in Python and other things. So without further ado, I'm going to go into my five tips. So I've been like really into spaghetti westerns recently. So I've tried to name these things after like characters that might appear in a western. So I'll start off with the quick draw. So this tip works in Ruby 2.0 and above. And I'm going to talk about option and keyword arguments. So with Ruby, you can pass in a hash to your method and that hash can contain any number of keys inside of it, as you would expect. And then whenever you call your method, you can reference that hash based upon the argument that you specify. Now what you can do with Ruby 2.0 now is you can have these things called keyword arguments. And so you can take this same hash and you can now break it apart into separate keywords. But what's really nice about this is instead of referencing it as like options, colon, one of many, you can just say one of many. And this can really help to clean up your code. And it just makes it easier because you don't have to type in your your hash name every single time. 2.1 allows you to have required keyword arguments. But most people aren't on 2.1. So I didn't talk about that. 2 is a reductionist. So one of the things that I think is really awesome about Ruby is map and reduce are really easy to use just due to the nature of the way Ruby handles. There are numerators. But unfortunately, a lot of times people won't really know like the best use case for map or reduce. And so I just wanted to quickly go over like how to use them. So map is pretty straightforward. What it does is it takes an array of things and then it enumerates over them, performs some operation, and then it turns an array of whatever the result of your block is. So for example, if you have 1, 2, and 3 and you map over them and you multiply them by some sort of secret value, which in this case is 10, you get 10, 20, and 30. So use map whenever you want to have an array as your result in a sentence. Reduce allows you to take an array or anything you can enumerate over and then apply some sort of function to it. In this case, I'm just going to add in the numbers to my accumulator. So whenever I reduce 1, 2, 3, I get 6 with this particular function. But you can do anything like you can take an array and like concatenate a string from it, all sorts of stuff. And like most enumerators, you absolutely can just use a symbol reference here and you don't have to have all this gnarly method stuff inside your block. Map is also known as collect. This is something I didn't know until recently. They're actually just the same thing. It's just some syntactic sugar. And the same thing goes for reduce, it's known as inject. So like sometimes I'll use one or the other based upon my mental model of what I'm doing. Like if I'm injecting something into something, I'll call it inject. If I'm reducing it down, I'll call it reduce. But they're totally optional. Tip three is the expressive regular. So regular expressions in Ruby are like really easy and they're pretty straightforward to use. You can just use slashes to delineate the regular expression. But it can get a little weird when you have like a URL. Because now you have to escape these slashes and it just kind of looks ugly. It's hard to parse if you have a lot of these things. So what's nice though is you can just use %r. And you can wrap that thing in curly braces. And you can get that same regular expression without all the ugly escapes. So it makes it really easy. Tip four, the exorcist. So I've been working with a lot of system level code recently. And I have a need to demonize some of my Ruby processes. And I was using process.damon. And this works great to send your process to the background. But there's a small problem if you need a PID. Because your process just exits. And so like your options are like, well, I could like look through all my running processes and grab the name. And that's just ugly. So you can just use fork. So whenever you fork a process, it returns a PID. And then you can just write that PID to like whatever your PID file is. And then detach the process at that PID. And then exit your original process. And so this enables you to demonize something and grab a PID from it. And you can also do some cool stuff if you want to have like two processes or whatever you want. All right, tip five is the hired guns. So in addition to like some cool code tips, I wanted to give like some general Ruby and or development tips. So I want to go over Rubyler, which is like a really awesome website that enables you to just type in a regular expression and a test string here. And then it'll show you what matches. It's super intuitive, very easy to use. And has a quick reference as well. Also want to talk about private mode. So a lot of people are familiar with pride, you can open up like a console session that's like really nice and easy to use. But it can get a little more complicated when you have a setup like this. So if you have a Rails controller, and you're hitting some sort of action inside of that. And there's something going wrong in there. It's not necessarily an error, but there's something you want to dig into here. What you can do with private mode is you can just drop in this binding here. And whenever you visit your website at that particular action, you can just invoke it just by calling private mode on the console. Now what's really nice about this is if your if your particular website runs in the background using something like pow, or any other HTTP server, this enables you this enables you to grab onto your session at wherever you drop this binding. And it makes it really easy to debug. Now, this is you can use this in conjunction with better errors. Better errors will do the same thing, but in the browser. The advantage of private mode in this case, though, is that you get the full terminal. So you can do like tab completion, and like all the sorts of things you normally expect out of a console. But I definitely recommend using both. Next, I want to talk about graphite. Graphite is like a really, it's a Python tool that enables you to log a whole bunch of information very easily and very quickly over a UDP connection. And what that does is it will just send off packets, and it won't wait for an acknowledgement or reply or anything. So your server doesn't have to wait on actually figuring out if they received the packet. You can lose them sometimes, so that's a disadvantage of UDP. But what's nice is if you're collecting a ton of analytical data, it makes it very easy to just pop it off and forget about it. And it does this in real time. So what's cool about graphite is, let's say you get thousands of hits a second, well, it just records it over a certain specified interval, and then it ships them all off at once. So you don't flood your server, which is really nice. And then finally, I want to talk about Remark.js, which is the tool that I used to build this slideshow. You can build your slideshow on a Markdown, and it's pretty easy to use. I literally used it today, and this is the first time. And if you want to talk to me, that's my Twitter handle. As you can see, I tweet all the time. Not really, I've had this account for years. And thanks. Any questions? Have you made any success with Primalone and Pullman? I found that when I run Pullman, I've got a lot of... Yeah. So I haven't had a lot of luck with Pullman, unfortunately. You can just drop in a prize session, though. Biden got pride. Can I attach to a different process? I don't know. Because I found that when you find a prior form start, which is like a long, simple thing, you get to do a time position like that. Wow. I haven't had that problem. So maybe our form and setup is configured differently. Unfortunately, I didn't set it up, so I'm not exactly sure. So the same project as that. We have had issues with Primalone, if I remember correctly. There are two different providers, and anyone who wants to see a movie version, you might have issues with Primalone. There is an open ticket for that, and their solution is basically way in place. Okay. So I don't remember which one I'm thinking about, but it's an issue here. Who used Primalone prior is a new product, so I think it's probably not enough. No, no, no. So buying a bug in Primalone doesn't matter. So we noticed that I'm on a private project where just remove that and just stop shopping. So it might be worth checking out what the bugging tool kits you're seeing and see which one it moves. Like I said, I'm always looking for input. So especially if you're new to Ruby, or if you're very experienced, I'd love to hear, you know, how you talk about Primalone.