 can find you there and you'll see all the code that I'm going to show you. So my name is John Britten. I work at a company called Twilio out of San Francisco, but I live in New York. I write, I've originally got a programming in-feet programmer. I know that's kind of a sad origin, but that's where I came from. And now I do Ruby stuff. And I want to talk to you about quick and dirty apps that I build. Basically whenever I have an idea and I want to push something out really quickly, these are the tools that I use to make that happen, you know, in hours instead of days. So I usually sit down with an idea and I want to get it cranked out and pop and running in all of them in a few minutes. So we're going to talk about Sinatra, DataMatter, Roku, and Restline. So if you're not familiar with Sinatra already, it's a really lightweight framework that lets you do stuff like this. Just specify your URL, do some Ruby code, and then return it to the browser. Reload it to Sinatra. DataMatter. So I originally, when I started writing these small apps, you know, quick and dirty apps, I don't like to store data because it depends, you know, if I can get around storing things, I try to. But I found DataMatter and it's, you know, really simple to set up, you know, persistent objects within these small apps. And Restline. So I use a lot of APIs for all these different things. I like to go across and, you know, pull in different data sources. Restline makes it super simple to do. You can see if you want to do a get, you can say get, your URL, post your URL, whatever you want to use. With DataMatter, you can do simple stuff like this. Just define your class, include DataMatter, and now you can set up relationships and set up different fields. Automatically increments all its stuff. It's really easy to do. And then Naroku. So once you build these apps, and you want to get them out the door, and you don't want to set up the server, you don't want to manage anything, you just put them on the Naroku. So I'm going to give you three different examples of apps. So we're going to walk through what I built and how they work, and we're going to ask you questions. Feel free to interrupt at any time. So I sent three emails to the organizers asking them all kinds of information about this event, and, you know, the common responses. Let me Google that for you. How can I find, you know, what's going on? I had an idea, you know, maybe the information's not out on the web, but it's something that's been emailed to me before, and I get really fed up with people saying, you know, hey, can you send me that again? So it's in your fucking Gmail. So I made this little app. It's online. It's off online. It's in your fucking Gmail.com. Basically, it's a SNOTRA app, and it sets up one handler that responds to get requests at any URL, and it captures a regular expression, which is just every character that comes after the slash, and it creates a redirect, and it redirects to that. So you can go to it'sinyourfuckinggmail.com, and you'll see all of my stuff that's really on else. So now my friends ask me, how do you, like, where is this event going to be? What's going to be? I've already emailed it to you. It's in your fucking Gmail. Go there, and you'll find it. So it's a really simple app. All I had to do was simple get in it, create an app.rb file. It's six lines, and then you have, you know, Jetfile, use SNOTRA, and big.ru just sends SNOTRA app to Heroku so you can get everything set up. That's a really trivial example. It doesn't use anything. It's just SNOTRA. So the next thing that I want to show you is something a little bit more complicated. It's called call Congress. So again, my friends have a lot of things to complain about, and they say, oh man, I really wish that this bill was passed, or, you know, the government would choose to make the laws, and they came my way, and what's the response? You know, don't worry about it. You don't tell your Congresspeople. The problem is they might not know exactly the phone numbers or how to get in contact with people. So I came up with this idea, wouldn't it be great if we just had a phone number that you could call, and it would directly connect you to the Congresspeople that are relevant to you. So I'm from Massachusetts originally, and I'm still a voter in Massachusetts. I've never updated my business since I left. And I'm going to show you, first I'll show you the app, and then tell you how it works. Here it is. So you can go onto my GitHub, and you can find this there. This is a public forum where anybody can call it. So the idea for the app was, you know, you call this number, 491-2262, and then you can say you've got a speakerphone. So I'm going to call John Kerry. Why don't we connect you to John Kerry? Alright, he's a lot of people right now, so I've got his voice up. But if you go out and you call this number, what will happen is it'll look up your area code, it'll figure out where you're from, it'll give you a list of the senators and representatives in your area, and it'll give you a dial-in menu. Now this is all done in a web app, and I'll show you how that works. Alright, so the first thing we do is we require some gems. Then next we grab our sunlight key. So it's an environment, a little bit of a set, and sunlight labs. If you haven't heard of them before, you should definitely check them out. They have a bunch of APIs for getting government data. Usually government data is pushed out into CSV files or, you know, Excel spreadsheets on IPPs, really ridiculous stuff, and sunlight goes out and finds all that data and puts it into really nice APIs. So I grab my sunlight key and the first thing is you make a request to my Call Congress app, which is how I'll bring up, call-congress.heroku.com slash what I need to do as a post. Alright, so I'm using an HDD console, there's a command line app to do setting, put post, put delete, HD request to whatever, you know, whatever HD resource you want to do. And you'll see on here that if I do a post request to, you know, my app, it'll give me a builder, which is my welcome thing. And this is what you just heard on the phone. It's just planning trees and call Congress, we make it easy, and then we send a redirect to people. So we'll do a post on people. And what that does is it will bring up it'll take the zip code of the person who's calling in, put a post on that API, grab their legislators, and then spit out the names of all those people with a dial in. So press one for this, press two for John Oliver, press three for John Kerry. If you don't have a zip code when you call it, the app will spit back a, we don't know your zip code, and it'll drop you into a National Congress dial in number. And the last thing is you press a button and press one, it will go out to the API again, get the list of people and then match it up with both the user entered and then connect me to the center of the Congress person that I selected. So the interesting thing about this app is that there is no data storage. So I'm really lazy. I save, I'm doing two API calls. So once when I give the options and another when I process what users selected, just because I'm super lazy and I don't want to store that stuff in my app. So the next app that I want to show you guys is called Spong Lottery, and this one's a bit more interactive. So if you can all take out your cell phones, I hope everybody here has a cell phone. And there's beer, there's beer on the line here. So if you don't take out your cell phones and call the number here, call this number that's highlighted. So it's pretty simple, it says hey thanks for calling and I hung up on you. So now now that you've all called in, I'll show you what this actually does. What I've set up here is a new data mapper which is super convenient for small apps like this. I can just define a class, call entrance, so each one of you is an entrance and you all have an ID and a phone number and an eligibility. So once you win, I won't let you win again and I'll set that flag to default. And then I have a validation in here that says each one of you should only enter once. So each entrance should only appear in the database once for each phone number. So if you call again, you won't get entered again. So if you keep calling, oh there's a lot of ringing going on. Okay cool, so you're getting your SMA. So that's why I'm just defined as the entrance so each one of you. And then this line here, data mapper.auto-upgrade which is really nice. What it does is it sets up my database. From up here I have a SMApper.setup and it has my database URL from Roku which is like preset. Or if I'm running this locally, you'll just use an sqlite database. And this auto-upgrade line, what it does is it just actually goes and creates the table and updates all the columns in the table forming. So if I was to change this and add another field, it would just you know, I can't go back and add a new field. Because I take it out of the field and leave all the data, so you have to be a little bit careful about that. But I don't have to manage migrations at all for really simple apps that I've been trying to just bust out in a couple hours. This is really great to have. So when you called in what happened was my phone number is connected to this URL. See it? But it just slash entrant and that's handled by this handler right here. And it just creates a new entrant with your phone number and respond with the entrant builder which is just an XML that says thanks for calling we'll call you back if you may. We're going to skip over the host right now. Actually let's see who I'm going to show here. What I'm going to show next is account. So this is if I go here I'll just take refresh. I'll see that 71 of you entered. And the way that this works is it do a get request on account. It figures out how much there is and returns a hamlet. And then what I want to do now is I'll call the number. So I think there was a prize to give out. Yeah, Altrac has another gift for the winner of this one. It's a messenger bag. There's a messenger bag and a beer for the first person and then everybody else gets beers. So there's four more beers to give out after that. And I'll tell you how this works. What I've done is I set up a special number here. So I'm calling this number and I'll hold it up for your mics. So make sure all your phone ringers are turned on so that you know who's going to call me to the first person who wins. And this is actually just running this winner handler right now. It's collecting all the eligible end-runs and then it's creating a call to one of them. And marking them as I'll somebody over there answer. Alright, so you go in the bag. So I just put star on my keypad and it hung up on you. And now it's going to connect me to the next winner. It's going to hit this URL again to the winner of URL. Select an eligible person and then it's going to connect me to that. Alright, so I have four beer tickets to give away. Alright, you're welcome. Go get it. Alright, I'll leave that there for a second. So the next person who wins gets a beer ticket. So I'll step through here and grab your beer ticket. So what's going on here is I'm going to grab your beer ticket. I'm going to grab your beer ticket. So what's going on here is I'll call that later on What's going on here is it's going out to the entrance grabbing all the eligible end-runs randomly selecting one and then redirecting my call to a a piece of X and I will connect my phone to the winner. And now the next thing I want to show you is a little bit of stuff with breasts on it. Let me see if I have this. So for all of you people who didn't win I created this other thing which is called losers. So it's really I'll put it in here. What you can see is these are all the phone numbers of all of the people that lost. So they're still eligible to win but haven't won. I'll just kick that name together. And the way I'm doing that is right here Yeah, it's all good. So it's going through grabbing each one and then just collecting them into an array and then returning that array stuff. I'm also I'll just give you the last two digits of your number so that you don't get angry with me. So that's pretty cool but all I'm doing for that is I'm just going through the database I already have and using DataMapper So where am I using breast plan and all of this? Well, if I want to do something interesting with all of your phone numbers, like call you back. I could use the rest client to actually make requests out to the Twilio API and here's the call that I'm using kind of hard to read here. Like I said, this is really dirty but it's just a restplanned.post and then the myaccountsid which is an environment variable, myaccount token is an environment variable, the Twilio API URL and then the calls resource, live from phone number, live from phone number and then your loser phone number and then a URL that just says what to do when you answer. So if I go back to my app and I do a get request on the call and we just wait for a minute. So this is everybody who data wins to get a call now. Okay, it timed out on the output. Well, I also didn't answer the call. So, I'll answer the call. Sorry I didn't win. So that, that's just an idea of what you can do, how restplanned works. It's really simple to use just post URL and then at the end I just had my franers so just a simple and now I'm going to need to take that URL down right away. You guys hit that URL and then it's just going to make them break down. Yeah, it's just weird. Let me get a ruby. What happens if we post this slash clear? Excuse me? What happens if we post this slash clear? It will erase the ruby numbers. It's totally not secure. What's the overlap? You just talked in the earlier talk about Luckily, I built it so that there's no way to actually view your numbers directly. They're all obfuscated, so that's where I found it. Let me take this down a little bit. Maintenance mode. You can turn them off now. You're going to go off now, it's okay. Destroy app. So the app has been destroyed. Shut it down, good job. Alright, so that's mainly what I had to show you as far as the main parts of Perogus and Otro, REST Client, and DataMapper. But I wanted to show you a couple more tools that I find really useful in building these kinds of apps. So what is called HTTP Console? How many of you have used this before? Okay, not that many, because I only discovered this not too long ago, and I think it's really awesome. So it's on GitHub, it's cloudhead-http-console. I think this guy does a lot of Node.js stuff. And basically what it lets you do is you can say, HTTP-console-console, and then a URL, hdb-con-slash-call-con-gris.erogu.com. And now I can navigate around the resources, so I can say like, I don't have any resources defined in this, but I can say slash-con-gris. And now I can see my prompt changes, and I'm operating on that particular resource. I'm operating on sub-resources, so I can do slash. It just builds on. And now I can issue a post request, or an air request, or whatever kind of HTTP get one. So obviously there's nothing there, but it's doing a request to that particular URL. And then I can actually, if I do like a post, so let's say I do a post to, let's do a quick one. It'll give me a, it'll give me a, just a prompt. And I can actually enter in my parameters that I want to put onto that URL. So it's really helpful. If you use curl for this kind of stuff, this is just like a thousand times easier to use. There's also HTT-Y, which is very similar in inspired by this. Oh, okay. That's good to know too. I did not know about HTT-Y. HTT-Y. So it's HTT-Y. HTT-Y. So it's HTT-Y. Oh, okay. I'll get some more. Google's not all correct in here. Oh, yeah. There we go. So yeah, that's one. I wanted to show you, and then the other one, for Heroku, I just destroyed my apps so I can't do the sound, but, I wanted to show you was, they have command that uses taps. And it's a Heroku DB pull, and then the name of, you know, something local at sqlitelocal.db. And what this does is it'll go out, it'll grab your post-grade, your Heroku post-grade database, and sync it to your local machine, which is really nice. And you can specify any kind of URL adapter here. So you can specify my SQL database, you can specify a post-grade database that's on your local machine, and that command line would actually handle everything, pulling it from Heroku and putting it on your local machine for demo. So that's all I had to share for presentation, but if you have questions, I'll have to answer them. Yeah, go ahead. So the question was, if my phone never rang, do I get a beer? That's probably a timeout issue in my app, so you can have one of the beers. I have a formula. Any more questions? Yeah, go ahead. Do you have a real question? No. Anybody else? Get in the back. Call Congress seems like magic. Are you a wizard? Oh, thanks. No, I'm not a wizard, although I wish I was. So the question was, the statement was, Call Congress seems like magic. Are you a wizard? No, I'm not a wizard. Why do you say it seems like magic? I just wanted to ask if you were a wizard. I just wanted to ask if you were a wizard. You got someone over here with a question. Yeah, go ahead. Could you show, the only place I saw where you were actually calling out to Tulio in the little app you were demonstrating was on the call action. Could you show like some of the other ones, like where we call in and then a playback response? Yeah, sure. So let me go to Call Congress. So the only time I needed to make a call out to Tulio was with the Rust client, was to make the outbound calls. So to initiate an outbound call, I had to hit the API actively and set, like to use my account token or my account C, to use my authentication to make sure that I had the rights to do that. So how about inbound calls? But inbound calls don't actually need an authentication unless you want to have authentication. So if your app is logging the stats or something like that, you'd use a request sign. So you'd know that the inbound request is coming from the Tulio API and you could deny all of the requests. But the way that works is let's go to, let's go here. So Call Congress, and I'll do a post request to just go there. And so what happens is in my Tulio account, I have a phone number called Call Congress. I'll zoom in on that. And you'll see it has a voice URL associated with it. And when somebody calls this number, this Tulio makes a request to that URL. So you'll see here, this is us making a request to that URL and you'll see the response. And it's just playing XML. So it will speak to you and it will redirect the Tulio API to the resourceful people. So if you want to post people, I'll get nothing back because I'm not sending the appropriate parameters, but here's people. So what it does is it expects a from zip parameter, which will go into the sunlight API and look up the appropriate people to call. So it uses the XML templates? Yeah, it uses the XML. I just use Builder. Like really it's just, you know, Builder. I can show you those templates. It's just really simple. So Welcome is just this. And then the people one is for each one, for each person that I got from the sunlight API, speak their name and the index plus one, press one, press zero, press one. And then when you press the button, another request is made to your app with the button that the person pressed. So I can, the dial, here you go. Right here it's taking the program called digits, which is what the user pressed. So I pressed one to get to John Kerry and it's just looking it up in the index of people. So it's a little bit sloppy because if any guy returns the result in a different order each time, it would break, but it doesn't. Cool. Yeah, go ahead. Do you have an irrational fear of straight interpolation? Um, no. Why don't you use it then? Excuse me? Why don't you use it then? I just wrote this a minute ago. Okay. Okay. Anybody else? What's the benefit of REST client over just the ability to be library and I don't quite get the question. So the question was, what's the benefit over REST client versus other HTTP libraries? Yeah. So REST client, I use it just because it's like super simple. There's nothing to it more than, it follows like the, just REST client.post and then you post it around your app. It's like all there is to it. I don't need anything more than that. There are also gems for doing this kind of stuff. So like eJPI, something like for example, has a gem for API. So I can just download this on my API gem and say, get me the numbers of numbers, but if there isn't a gem for the particular API that I want to use, I'll use REST client. Any others? If not, I think that's all I've got.