 I'm broke. I'm a developer evangelist for Twilio. I'm mostly standing out at a table over there. I just wanted to tell you a little bit about Twilio today and then write some code, because I didn't think we've seen enough code just yet. I hope that's okay with you. Quickly, Twilio is a communications API, a platform for you to send a receiving text messages or making a receiving phone calls into your applications using the tools, the languages, the frameworks that you're already using. Ac mae'r iawn yw'r gwlad a'r adeg y meddwl yma i'w wneud ni'n cywethaf yw'r ysgrifennu. So, mae'n tylion, a mae'r gwahaniaeth am yw'r gweithgareddau. Felly, mae'n tylion, mae'n tylion. Cyngorau'r môl yn ymweld, mae'n golygu'n gwahanol. Felly, mae'n golygu'n gweithio gyd yn ysgrifennu. Ac mae'n gweithio'r Gwyl Pwysig, mae'n golygu'n gweithio'r gweithgareddau, I'd insist you get it out of your pockets right now because that's going to be really useful. I have an address. Oh God, it's all gone horribly wrong. Forget that. International people, how about you guys? You can do this. I'm going to do this in the UK to make sure this works. Oh, that was a nightmare. Good, you need an address in Spain to get a number and I don't have one. So let's get a UK number and if you buy that number, that's my number and that's wonderful. So in order to make this work, we have to give Twillio a URL because what happens is when you receive a message at this phone number, Twillio takes that message, bundles up into an HTTP request and makes it to your server or in fact my server in this case. So I'm just going to add that in there and I'm going to put it to something that's running here on my laptop. There we go. Cool. So we're just going to make a post request to that URL and that URL, that's going to load slowly, I guess, in the background, that URL points at this application currently empty. So let's build one and just going to require Sinatra because we've talked too much about Rails today and we're just going to write that post request to messages and all we do with Twillio is return some XML, not Jason, certainly not Proto, but XML and that XML is pretty simple, thankfully. So you can just send a response and in terms of text message, for example, we can respond with a message. So I can say, hi, full stack fest. Here's a promo code because I'm feeling generous. This will get you $20 of free credit and if you want to ask me any questions, I'm Phil Nash on Twitter. Lovely. We'll end that message and save that and I tell you what, we'll just run that server and that is being served. Someone's done it already, that's amazing. Who managed that? This is the phone number. You took that off screen very quickly. If you have any, if you don't mind sending a message internationally, please do send one to that and you will get that response back and we'll be very excited. I'm going to send one right now. So it's plus 447481347601 and I know I'm sending. Let's see what's happening. So we're getting some messages coming in. If you've received a response back, give me a shout. Good stuff. I just got one too. That's cool. So I'm just going to get out of that and then I'm going to tell you a little bit about our REST API because we have a REST API as well because we want to be able to make these things happen as well. So I'm just going to require our Twilio library. We have libraries in other languages but who needs those? And create myself a REST client and give it my account, SID and auth token which is basically the username and password for the API which I'm keeping hidden from you. I don't know. I'm keeping hidden from you and I'm just going to go and get those messages that we sent to that number. So I'm just going to list them out. I still like hash rockets by the way. And then I can put those on screen so I hope nobody sent anything bad because you know codes of conduct and stuff. And also I might just steal your phone numbers as well because I can. That's okay, right? I'm just going to put the message body and return the number you sent it from. Lovely. So there's some good stuff. As we can see it works with emoji. It's good to see. Thank you very much. But we're not done. We're not done. We're not done. I hope we're not done. Because I took your numbers I can call you back, right? And with that num I can go, I can take my client and create a call to your number from my number and give it another URL. I'm going to write this URL out pretty quickly because I'm probably running out of time. So with the URLs we can do a lot of other stuff with voice such as we can use a robot voice for example to speak things out to you. And we can play what do I call that call? We can play back MP3s over the line if you want to do a recorded message or just play lovely music to people. But right now I think this is time to get a bit more social. We're about to get to the party time so why don't we all have a bit of a chat or at least anybody who texted in have a bit of a chat because I can dial you into a conference. That would be nice. So once I hit go on the thing in just a minute, numbers, your phones will start to ring and you'll be able to chat with each other. So that's going right now. It should start working. And whilst that goes I'll just tell you that my name is John Ash. I'm a developer for Twilio and out there all day so come and say hello. Thank you very much. Yes. Okay. Hi, I'm Peter. I want to talk to you about Reka lightning talk. This is Catalan in case you were distracted by the speakers presenting that this is a Spanish area. So let's look at some code. The code is awful. There are many things wrong with this code. Let's look from the bottom. The initialize takes a parameter that it doesn't use. The snake case method performs a nil check which we learned is a very bad thing to do. It actually takes a control parameter so the color of this method actually knows which path this code will take. The parameter is a Boolean flag so that's another problem. It calls the nil check twice and it actually has no descriptive comment. I won't go into details whether having or not having comments is a problem. There are two sides to this issue and the truth is usually in the middle. But let's look a bit further. This conference class can compute the distance, the direction to the conference and the distance can be computed in two ways. So what's wrong? The distance to method is really badly named. All of this tests the latitude and longitude at these three times and it also takes latitude and longitude together to four different methods now because the constructor was the first one. So let's go a bit further. Do we have excited attendees? We take a collection of attendees, partition them whether they are excited and check whether they're excited are more of them than in different ones. The problem with this method though is that it has nothing to do with the conference. It only operates on the attendees which is a utility function so it could be moved to anywhere else in your code and work just as well. This one actually operates on the object because it checks the city of the conference but still it operates much more on the attendees collection so it's a feature envy. This method probably should be moved to the attendees collection. So there are very good reasons why you would write code like this. So there's nothing always obviously wrong with this code but there are also some smells. So all of the things that I showed you are things that are output by Rick and Rick is basically like Rubocop but for your architecture. It checks whether you're making any OOP violations and flags them as smells and you can plug in to your rate test or your CI. So you can configure it as you like so if you have some methods that you know should be smelly you can say so these are some default configurations for example we say that too many instance variables are when there are more than nine but a method has too many parameters but it has more than three unless it's a constructor then we're okay when it has five so we can you can configure it in a very big detail and also you can configure it on a oh yeah so if you're like Tom and you really don't like gathers you can actually enable the smell that will flag all your gathers in one go. So you can also configure it on a per method basis in comments so whenever you edit that method you will if you add another duplicate method call it will flag again so it can be like I'm okay with two but maybe with three I'm not okay so whenever somebody adds another check it will be a problem. So these are good things when you have an existing code base that is really smelly but want to want to flag all the existing smells as okay for now I will refactor them later or get somebody to refactor them later I just don't want to introduce new ones so making you happy with my code was what taught me the most OOP in the last year but please always be critical of such tools and there are many reasons why you should be or could be critical and you know there are times when those tools are just nudging you in the right direction so I'll skip this this is a very good thing if you're not into LISPs but yeah so if this is the representation you would work on if you wanted to hack on rake which we really encourage you to and also do not refactor your application to this kind of state. Thanks so much the slides are on talks just on that if you want to learn more please come through become Portugal I'll show you refactoring to actually get you out of those smells thank you. I want to talk about growing juniors and infinity yeah my name is Malina so imagine a headhunter they go to the forest and they are looking for seniors of course they're always looking for seniors but what about juniors and what even about pre juniors because if people look for juniors they might they say okay you're full stack and you have two years of experience you know that's a junior for people okay you could say well they know too little they ask too many questions we don't have time then they are maybe shy but on the other hand think about if you get juniors you can grow the community and you can influence them and you can teach them best practice right away for example my colleague Luca wrote me a message on Skype quick quiz how much is 0.9 minus 0.8 are you sure try it in IRB what do you get and why so I went to IRB typed it in and then I was like okay I expected 0.1 and I think all of you are at the moment like well I knew that but do you really know why that happens so I did a research so 0.1 is of course in decimal 1 over 10 which is in binary 1 over 1010 and now if you start to divide 1 by 1010 of course you first you have to get down these zeros um this is by the way the american division notation so yeah we have the numerator there the one and the denominator to the left and up there's the result and what we see here is that 100 like the 100 comes up again and again and again and fractions in binary only terminate if the denominator has two as the only prime factor and so this repeats forever which then looks something like this and but you know in computers we don't have this periodical bar we have only a certain finite number of bits right so at some point there's a rounding happening and um yeah so we have we are thinking of 0.1 and doing all stuff and then in the computer the computer just takes all the bit that it can take and then rounds the last bit and then puts it back to decimal and of course if you round something it will not be the same anymore so unprecise results of course they hurt especially if you are working with money and if you have a business that puts money from one from one account to the other so how can we handle it so my colleagues too told me things we can use integers as long as possible and just in the end calculate with floating point numbers we can learn about big decimal or we can always read about the i.e. 7 5 4 standard for floating point arithmetic so if you want to grow juniors too now and you don't have a company to support them well you can always support um beginners workshops like red skirts or closure bridge which we just recently had in Berlin um yes you can support learning groups and all kinds of workshops yeah thanks that's all what i have hi i'm philipe espinoza i work in hyper um come from norway um so i'm going to talk really briefly uh something about we do in the company uh about mox and api design workflow but why is that uh we do a lot of ios and android applications and those applications need to connect to a bucket so we kind of like uh wanted to improve this work uh the workflow the way we work with ios and android developers just to kind of like make the whole process better so we kind of like got this approach that is consist about like uh making api proposals in markdown discuss it agreed on on them uh mock this these agreements the the endpoints and then like uh just start working on so initially uh it's a it's a markdown document where you says like the name of the endpoint the reverse parameters the headers what kind of result and most importantly the rationale why do we need this endpoint so this is uh because it's markdown and both ios and backend developers can can do this so we kind of like see really early like uh if the the endpoint is doing something that we want uh or not or if we need some data or it makes sense or not for the the consumers that's the whole point of it so after that uh anyone can make a request out of it and we are going to discuss it so there is a lot of addition and conversation back and forth until we say okay this is good to go we can start working with that so merge the request and after we can just mock it on the on the rails backend to start serving this mock endpoint mock data on just a json file in order to to kind of like really quickly deliver this this agreement so after this for example this is the poll client for Mac so you can start using the endpoint and like at some point you replace the the mock data with the real data and if you agree in the in the in the contract that you made with the with the api design everything should work like perfectly so this was a a little bit of uh experiment that we did now and it worked quite well because like uh well we have also the ios developers doing this and we they didn't have to wait until we implement all the functionality in order to be start working on the ui parts on the and displaying the data and like the all network connection and also is or the most important key or takeaway is that you get to design the api but the perspective of the clients because like as a backend developer in my experience i i many times i've designed apis but like they are thought of my point of view not what the client really needs so after that i just say like i did this really a small gem for rails to do these helpers for quickly serve these jason files and well check hyper oslo because we have a lot of cooler open source stuff thank you very much hello everyone my name is bruno and tonight or today i want to talk to you about timx plugins so i want to start with a question uh how many of you are using timx either on a server or as your development environment okay a couple of people so you know what it is right so i'm not going to talk about what timx is uh i'm going to talk about you know an extension to timx timx plugins timx is great for managing your development environment and it's great for command line productivity right so we are ruby developers rails developers and we have things like railserver we start that from the command line we have to use git uh we have to use maybe a site processes like memcached read this stuff like that and we run and interact with the command line a lot on a daily basis i think uh so you know timx enables you to manage all your command line stuff better and if you're maybe using vim from the command line that's where timx comes in great as i mentioned at the start i want to talk to you about timx plugins right so timx has plugins and you might not know that because that's like a relatively new thing since a year ago or so um you can check out plugins on github.com timx plugins i'm going to show it to you so we'll just slide through the selections so there's about 20 plugins so far all the way from for example plugin manager to enhancing some functionality that timx doesn't have for example regx searches then there's like basic things like timx sensible some sensible configuration options you would really expect to have just like when you install timx but for some reason it's not there and it's even fixing some bugs that come with timx so you know things like that tonight i want to show you a timx plugin that a lot of users find useful i think and it's called timx resurrect you know what it does is basically it enables you to restore timx environment after you restart your computer so let's check it out all right i have timx here in the window do you see so this this window and you know i fired up a simple rails application in a window i'm running vim like vim i hope you do too so this is a gem file nothing special this is a controller not much to show really then i have of course real server i started from the command line then what i do for some reason i decided to just check out curl man page over here and lastly a cat everyone likes cats and this might be the first time you see a cat in the command line and uh no it's not like a hoax it's not a scam it's a really unicode and 256 colors cat in the command line yay so um you know uh as i mentioned we're in timx right and say so this is like a really this might be like a cozy you know development environment for you but now you have to for some reason restart a computer maybe you have to upgrade it uh or something similar and you know what you have to you know scratch the whole demox configuration and all this cozy environment is gone that's where timx resurrect steps in it enables you to save everything you saw everything i showed you right now so we're going to uh you know i have it everything set up save uh so i'm going to save this timx environment right now i'm going to press prefix control s all right it said demox environment saved all right so i'm going to do you know scratch this whole environment now kill server it's all gone so let's pretend you know i restarted my computer i upgraded it whatever and i'm going to start demox again as you can see i have a blank uh blank pain right now my whole environment is gone but i can restore it right now with prefix control s control r sorry right i got a message demox restore complete and let's check out what what are we oh sorry so yeah we have everything restored whim is already running the cursor is at the exact location i left it rail servers again is running it started automatically main page is restored and the cat the cat picture is also restored thank you i came up here to tell you that it's september first it's 6 15 p.m and the ruby community has 230 000 problems plus minus 99 um and with problems i mean open issues on github so this is sort of good news because i've been told developers like to solve issues and i don't know if that's true because i'm mostly a designer that all changed though as um as i walked into rails girls workshop earlier this year and i met ruby i met the command line and the community itself and it would have been a madness not to stick around and try to solve problems myself so where do you start go on github nah seriously like where do you start right so it's uh it's kind of tricky to find projects that are worthwhile your time and um thus i decided to solve the problem of finding problems first and therefore i would like to introduce ruby issues which is a curated mailing list of open source issues on um that are in github right now curated i mean we estimate the necessary skill set that you need to solve the issue uh we try to get in touch with the maintainer in advance and see if he's responsive so oh sorry wrong button um what about this so the response has been quite good i think so there's been some issues that have been solved fixing bugs fixing um zombie links for example adding some missing translations but i'd love to see some of the more sophisticated issues being taken on and i'm in a unique position and it's very humbling that this project is a sponsored one so i work for magic labs and our community work is sponsored by odin but ruby issues is really about you and the open software tools that you use because in the end um until we find a way how to sustainably do open source work and make that available for everybody you know we have to um sorry until we figure figure that out it would be nice to help each other out here so with that being said um i'd like to hear about your issues i'd like some feedback i'd also like some subscribers but really i would like to see the number of open issues going down and that's all folks hello there my name is carlos paramio doesn't meet with it and um i could see the myself uh devop and as you know ops are lazy we ruby devs are lazy so the combination of those two is like the constant desire of having siesta all the time so uh in order to have more spare time to read hacker news and do other stuff it's usual that we build our own script to automate tasks that are we need to do in a daily basis so uh you start to create those scripts you start to share them with your partners in the team but then you discover that some of the tasks are useful to be triggered for other members of the team that are not technical or that contains credentials that you don't should not share et cetera so at the end you need basically to be around or have a resplit companion like a bot in your channel to trigger those actions safely only for the users that should have access to so as you know there's a very common bot that works with a lot of adapters and services out there which is you both which is by the great guys of a github everything coffee script or no gs but of course we want an alternative in our uh referral language or robot language which is later it has been around for a while and uh i just wanted to to show how easy is to write handlers for it and connect it to your um to your uh a shutting system et cetera even htp services so basically uh it brings with a lot of uh comes with a lot of adapters for htp campfire irc et cetera slack all the common ones um there is tons and tons of plugins um and it's really easy to write your own handler to respond to certain messages so uh you just write a little handler barucho for example and then it creates you uh some files uh and the proper directory barucho and then you just need inside that file to define routes those routes are going to be a couple of expressions the matches for a certain string uh you can scan part of that stream so you can pass parameters and then you uh say which method you want to be called inside the handler then inside the handler you always get a response and then that object that little response object answers to a lot of other methods like replay and uh which will replay with that message that you can post in the public channel or you can reply private privately et cetera uh you can restrict the execution of the handler or that particular route to a certain group of users and then uh you can interact with Lita in the channel directly to tell okay you can add now Carlos to this group so he can trigger that action uh some of the methods that you can use for from that response object or as I said reply reply privately you can collect the matches on the string to get the arguments uh read the entire message check the user settings like the id of the user in that service et cetera um and you it brings also with a lot of clients like uh read this client because it uses read this for his brain uh HTTP client translate read the configuration in case that you want to store the credentials et cetera it's very easy to use um as a sample also you can you can populate the an entire HTTP interface in case that you want to automate the stuff with another application it's very easy like uh creating a good hook and call this particular path when someone pushes and uh it just uh uh will call this uh this another method uh and of course for the HTTP interface you can also collect um arguments and have your models or whatever you want to do that and for example fetch information from your ticketing system and output it on the channel uh even has a timer already implemented inside so you can uh delay a response for five seconds after the trigger was done or uh repeat a process each 60 seconds so that's all check the gems that are out there I wrote some for engineers I I hope you find it interesting thanks hello everybody uh my name is Robin um I live in Berlin um and I moved from Hamburg uh two years ago to Berlin um I run a consultancy which is called magic labs um this is my twitter handle this is uh me on github and I want to talk about uh the alchemist cms um which is uh basically a content management system written on top of rails um open source on github and um I was wondering um how many of you already know about this project or have heard about it or even used it so I see few hands so not not that popular but I see few hands okay that's cool um this project was um founded in 2007 um it was proprietary and uh it was open sourcing 2010 um it's licensed under bst license and um I just go on um what what is alchemist cms or what does it provide and so my first point is um we have a strict uh separation of content and markup which is basically the the fundamental aspect of alchemy um we think it's it's important that we have plain content instead of um mixing content with markup um and if you do that you you have freedom on the designer side and uh you have flexibility on the developer side and how you deliver your content like you can just render html you can render your content as jason xml or whatever um another thing is um the usage for the editor which um is yeah I think it's it's easy or it should be easy so alchemy focuses on on a good user experience and um we try or alchemy tries to um to be um to be less complex and um to to reduce complexity whenever possible in in the back end on the UI side um also flexibility for the developer um of course um it's it's built on top on on rails so it means um we um have all the benefits from rails um it's a ruby gem um it's it's mountable you can just um mount it in your host application so you have the freedom to to develop your your own uh individual model views controllers everything um you want to have in in your in your very individual application and just um get the um features from from some cms uh behind that um freedom for the designer um is quite related to the first point um which means um due to the fact that um the separation of continent markup is a thing um the designer is completely um independent of of designing the website because um the designer is in control in in full control of um the markup and the styling and there's no no requirement given or or anything um which comes from the cms or some somewhere else and um yeah that's that's another important point here um this is uh the website um of course you can find on ruby gems also but you can find some more details here you can try the demo um or just uh yeah contact me and that's it yeah uh hi my name is yan i work at hitfox i used to be a ruby developer um then i turned into a javascript developer these days i described myself uh my job more as a programming cheerleader for our team of developers the people on my team love rails and they love sas and they love javascript they love react but they really don't love the asset pipeline so much because it's inflexible it doesn't allow for much customization in how your assets are processed try to integrate things like css post processors babel js or module systems and you're entering a world of pain in 2015 it still doesn't support source maps it wants you to use gems to manage your javascript dependencies it wants you to concatenate all your javascript into one big blob whereas what you really want to do actually as a javascript developer is to use npm for proper module management webpack to bundle your stuff for the browser and gulp to finely tune how everything is processed in short the asset pipeline is nice for sprinkling some jQuery on top of your views but it's inadequate for sophisticated front end development and single page apps so what's railed solution to this turbo links you're supposed to build your front end in the back end basically i'm not a big fan of this something a lot of people do now is to build two apps they built their back end api with rails and whatever front end stack they like to build a single page app that might work fine for you but it comes with disadvantages deployment gets much more complicated too complicated for simple apps you need everything in sync you need to keep it to code bases in sync so i was looking for a solution that would let me integrate rails and gulp i found something that i think works quite nicely it has a very boring name let me show you the gulp assets gem gulp assets has exactly five features first to initialize your app running the provided generator installs a directory structure a package JSON in the gulp file into your repo the second feature is the built-in webpack dev server you have to launch with npm start in parallel to rails why do you need the separate server grant rails serve the files by itself you might wonder yes but using the webpack dev server allows us to use webpacks awesome hot code reloading functionality it also makes it possible theoretically to serve front end assets without actually spinning up rails so our designers don't have to install postgres to write css the gulp process started with npm start also takes care of watching and recompiling files and running a live reload server the live reload client is automatically injected into your rails views during the using the rec live reload middleware and third the gem provides a couple of helpers to generate links in your rails views to the output files that are created by gulp assets using these helpers generates proper links for dev for production environments pointing either to the dev server or to the hashed file names that are created for production we also hook into the rake assets precompile task to trigger a gulp production build whenever you precompile your assets this means you don't have to change your deployment scripts much just make sure that notice available on the server and that you run npm install whenever you also run bundle install finally i don't actually want to replace the asset pipeline there are still valid uses for it and developers working on less fancy pages might be happier just copy pasting jQuery code from stack overflow into the app assets directory gulp assets is designed to work side by side in harmony with the asset pipeline as long as your file names don't conflict you can find a detailed readme page on our github repository that thing is on ruby gems in a pre-release version so if you want to give it a try you need to specify the pre suffix in the gem version um finally i'm presenting this here because i think this is really useful i know a lot of people who had the same problem um and i would really love to get some feedback on it and some help thank you very much hi everyone sorry um this called this talk is called metaprogram methods and performance um toby you can find me as prectop and i'm from bitcrow that's what that asset really looks like um so what is metaprogramming metaprogramming is code that writes code and i want to talk about the performance uh of that a bit but this is not about the performance of the method definition time or the direct call overhead if you want to learn more about that uh there's a link i want to put these slides online i'm going to read them out uh from erin um who did a very in-depth analysis of memory cpu and everything that is involved with that so we're going to do a simplified example but this is real code live code from my beloved shoes4 which i'm working on and so let's start um we're going to have a fake dimensions class um shoes is UI programming so we need lots of dimensions to position objects everywhere so this is just a simple fake dimensions thing it is initialized with a margin start and then it has a method to check whether value is relative and then it calculates the relative value which is if the margin is given as a rational like uh has a float sorry uh like 0.1 so now we want to have a method that calculates our margin start and at first we're going to define the full metaprogramming version of that method as i would usually define it so we do define method full matter and then at first we have to get the instance for your name here be aware that this looks stupid here now but in the real world of course we have some sort of data structure we are where we have lots of different symbols there's not only margin start and margin end but that's why this is a simplified example so we create the instance variable name we get the instance variable and then we do the relative calculation second um a bit different we uh get the instance variable instance variable name right from the start as a constant so we don't have to do the reallocations all the time do the same stuff then for comparison sake we have the direct instance variable access without instance variable get and then we have one version where we uh just do a bad bad evil of the code as a string so we can potentially interpolate it if we want to do like really replace values in there and then the normal method which we call full direct and then let's benchmark that um IPS style as we learned in the performance in talk that doesn't look so well but it just creates a fake dimensions class and call each of these methods and reports so what do we see um the full direct is of course the fastest but our full matter is much much slower and still the direct instance variable access is 1.2 times slower this is because the defined method takes a block uh which then uh creates a closure and has to get all the variables from around blah blah blah and now the computer is locked and I cannot handle max I'm sorry thank you young um but we see full matter is 3.3 times slower like what the hell what is happening let's have a look at it again this is the full direct version and this is full matter and we can see here we first create one string we create another string and then another string when we add them both together and we do an instance variable get but even if we remove the first creation of the string and we put it into constant which we could also freeze if we use that version it is still it is still two times slower like what the fuck what is happening um and that's due to like my assumption is it's due to the one is the block over it was 0.2 times and then instance variable get in that case shows us how slow it is compared to normal direct access and that was really surprising for me and you would say this is a super micro benchmark like does it matter like does it maybe not unless use that method a lot this is the actual pull request which my friend Jason O'Clock did and we discussed about like is that relevant do we need that performance improvement by way this is me and Jason programming together at your camp discussing both stuff and to coach Jason Jason he ran an example of ours and he said and yes you read that right choose dimension extent was called eight million times and we don't know whether what you're going to shove off that's good and obviously we should reduce the core count but dimensions always bound to be in our hot path so if you have a method it gets called that much then that these sort of performance optimizations can be very helpful otherwise maybe not thank you very much my name is Sefian Feripelitsa do you know what this is hands up you know what this is okay for those of you who don't know let's take this example here's a class that's an infinite range that can have an infinite bound so for example from one to infinite it covers 100 and it does not cover minus 10 so when we run this you can see that it works correctly well let's try let's try ruby dash w oops we have made an error there so Ruby wants to help you but uh does anybody actually use this in your Rails projects hands up very low hands okay let's run a demo so I have enabled there were both mode here in my rails application and let's try to start it so this is what you get that's that's all the warnings that come from all the all of your dependencies all the gems like awesome nested net set um some somewhere else money dragonfly you don't want that okay let me try one more thing that's uh butary file just on comment this try it one more time look at that you get your warnings but none of those warnings from all of your gems cool right so are you not sold yet this is what you do just use this gem and those put those three lines of code in your config that are b and that's it so so I'm here to present you altable or on a ruby one liner bits rust by one liner I mean a couple of lines and by bits rust I mean a rusty code so I work at Shopify at Shopify can I see my presenter notes on that okay well I'll try to remember so at Shopify there's one cool thing that I like about the company is that we run on the exact same code base since 2006 so we don't know about the um second system syndrome not at all but there's also one side is one bad side is that we run on the same code base in 2006 so we end up with controllers like that time goes by bugs get fixed features are added and we have that thing pretty pretty bad uh lots of before actions rescued from so if you take a look at the size of that controller it's almost size of the empire state building but don't worry that talk is not about skyscrapers so I'd like you to I'd like you to focus on all those before actions can anyone tell me what the pay action does yeah well that's that was also our reaction so there's actually an action called pay and we still don't know what it does and we still haven't seen the code the code relative to the action uh so that's pretty bad we want our controllers our actions to be described as stories we wouldn't be able to tell them like to tell easily what they're doing so we introduced a small pattern called altable first thing you can realize about that code I don't know if Lauren is still in the room but that's a sonnet I added some rhymes at the end a b a b yeah second thing is that it's readable you understand right away like what this guy does so the way this works is that each and every step of the flow is responsible to either bail out or um interrupt the flow we enter and we introduce a small keyword called alt that uh simply enables the flow to uh to uh to be interrupt so we wrap all the steps of the flow into an altable keywords and uh it really really is super easy so to uh our altable works you first define an identity function um no that's whoa that's not true at all so it's simply a throw and catch around around the flow so that enables us to describe all our all our actions with stories simple steps that are reusable so we don't have any more uh before filters we don't have any more uh special rescue from in our in our country or in the country super simple I'm Christian I work well use your slide there at one point yeah maybe not so I'm Christian I work at Shopify feel free to ping me if you have any questions thanks my name is Gavin Joyce I'm an engineer at intercom um if you're not aware of what intercom is it's a uh tool our mission is to make web business personal the tool you can embed in your mobile and web applications have uh conversations with your customers um engage your customers by sending messages to them at the right time support them and learn what they're doing within your product uh I'm going to give a quick talk on a gem that we use called mutations I'll come back to some of the details uh in a minute uh I'm sure everyone's familiar with NBC uh the client application in our case we have multiple client applications iOS android sdk uh uh libraries uh quite a large ember js application and then customer applications which are built on our set of apis so in this case the view layer in rails is not useful to us um so we simply don't use it uh our controllers are really a set of apis um there's mobile apis ember apis and then public apis uh our database we've many of them and we've a hundred models plus and 40 engineers uh who work on the rails application uh pretty regularly um so uh that should say a hundred models but um it's obviously very complex uh active record models have got quite a large surface area um I'm sure also some of you are familiar with callback hell where you create a couple of callbacks and then all of a sudden come back a few months later and it's like a Rube Goldberg machine um it's very brittle mutations is something that we use to tame that complexity uh here is a mutation um in this case it's a list command it defines that an app id is required it's an integer it's got three optional parameters um you can see the state string uh can be one of four actual strings and then within the execute method we've a very clean context uh where we can actually run some logic so in this case it just returns a page list of uh serialized messages um here's how you invoke one of these commands uh you run you can uh call the run uh method um mutations can take a series of hashes uh subsequent hashes uh take precedent over previous ones meaning you can accept untrusted parameters from uh uh HTTP and override some things that you care about like uh id or app id or something like that um so a hundred models uh we use mutations in a number of places in our rails application uh one is to provide internal APIs um that uh encapsulate the complexity of some of the related models uh so in our case we have uh three instances at least that we use it um by different teams uh these are logically decoupled again it's all started part of the one rails application but uh the mutation APIs uh hide the complexity um so our APIs use those we also use mutations to define the external APIs and uh this is still a monolithic rails application but the nice thing about this is preparing uh it's preparing us for the the time where we actually physically decouple these uh the user message and conversation APIs will very easily be uh extracted to actual physical services um if you have any questions there's five uh me and four other intercom raids here so come talk to us and thanks very much