Okay, so we're gonna start with this one that is not it was not actually in the list But that's the first one is not here. We'll do this like surprise talk so please Hello everyone, my name is Vitaly bochman. I'm a software engineer at cloud lock So and today I Want to talk about how to create a telegram bot Because yesterday there was a talk how to create a Twitter bot and I thought like Okay, why not create a telegram one? so the first thing you need to do is you need to create a bot and The most convenient thing is that you do not need to call your mom Instead You just need to talk to bot father So bot father is a is a special telegram bot which Allows you to create and manage your box So you just type command new bot answer a few questions like the name of your bot The description and that's it and you get your token which you then can use to build your bot application so in pipe Pui there are tons of different Python packages which allow you to create those bots Like as you can see that it's not a complete list But it's a huge one in this talk. I would like to focus on the package which is called a Iotg so this is a little framework built with a sync IO Which allows you to build a telegram bots really easily? so the first Thing you do is like you define a bot like you could you construct your bot class You provide a token and the name to the constructor then you Define some commands handler so that your bot can understand what what it needs to do if somebody calls that hello command for example and and also you can define Any other Handler any other message handler for like you can define what to do in case of audio message comes in or video message or image or Whatever message comes in and the last thing that is left is To run your bot So it just runs a Loop like in an in an async IO event loop and it constantly polls for the new updates from the feed and in case of a new message appear Like every message is sent to to to a handler that is defined to handle that Type of message So that's basically it You can find the the whole source code under that GitHub project name Let's do some live demo Okay. Thank you The next one was supposed to be global interpreted block Sorry, you're going to That's like if there is a time I would like to do a demo like well. Yeah, you have some yeah. Yeah, you sorry My first time hold on for a sec. How do I do? Mirroring up. Do you see anything at all? I'll call them so That this is that the standard Europe Python telegram group Like you think it's okay if I invite the bot here So that everybody can look at it. Okay, so let's Invite a hello EP 17 bot here it works. So yeah, if you go to To the repo there is a Docker file over here you can compile your own docker image or you can just Pull this one from the docker happened Try it. So that's it. Thank you. Thank you It's here now the one who was going to do the talk about global interpreter block Not here. Okay. So please come to a stage and prepare Yourself and I need here Peter diva You're preparing. Okay. You have everything set up nice As you may have noticed I'm not harrowed. I have changed a bit, you know, I have I'm smaller with more feminine but Sorry, that was the sad part they asked me to host this thing But the first thing I thought is I have not that many jokes And I have I don't speak with that many people. So I have no histories about yeah Just yesterday I speak with I have no this story. So I have to just try to improvise a bit Mostly I just speak with robots actually. So this gives me and they don't kind of Have very interesting stories all the stories they have I have put them then you ready Like it's working second. At least it's something just a day. Everything was great. So this improvement Also, there's a Miguel Beltre Okay. Yeah, you were preparing This time it's going to be smaller. So we have some big time constraint, but okay. Yeah Okay, so hi everyone Okay, so my name is Oz tiram I work for a company called mobility house in Germany and I want to present a small Python library, which I think might be useful for other people too. So if you've worked with this or MongoDB, you know, you can put expiry time for Your keys or even collections in the case of MongoDB collections and but there are cases where you don't want to bound bind your application to a Database or you can't even because you're working very limited environment. So I was looking for a solution for quite a long time and I didn't know what to do. So I found out that there's something called time to leave dictionary, which is was not really maintained So I forked it and there's now a pi pi package available the Pository repository in Github is also available and I want to show you a small little demo If you may give me the opportunity Just need to get a terminal on it. Yeah, is the context good enough on the screen? No, okay, so This better Bigger bigger bigger. Okay. Yeah Okay, so the Library contains simply just one thing an order dictionary which remembers the order of your keys and values and accepts an expiry time. So if I create it like this with the three seconds values and Put a value in there. I have this key And if I will wait a few seconds and I will try to get it I get a key error because three seconds have passed and it's expired. So just to show this again Quickly it's there It's gone and the nice thing about there's no threads no magics Please don't use it for thousands of values. It's only nice for Very small amounts on the order of like a couple of thousands. So you can use it for kind of like a cache or I don't know whatever use you see for this. Thank you. I keep forgetting that I have a microphone So he's gonna set up now and I think I have something to Improve my jokes. I find on the internet and I found this by York spot. So As I don't have them I may have Right, I write them like the first one is I've been using being for a long time now Mainly because I can't figure out how to exit Now you're supposed to laugh, please Thank you. There you go.  So for Python Okay I will be talking about a little bit about tooling for workshops So who has ever attended as a student the Pilates jungle girls woman called you give her a pie coat, etc Raise your hand up, please No three four. Oh, I've expected more so who has a mentor during those workshops please raise your hand more that's nice and Who was organizing or helping organizers to execute the workshops? Two three four. Okay. That's less than I expected. So for those who don't know It goes like that first. We recruit the The students and the mentors Then organization team handles at the same time stuff like PR marketing funding, etc But honestly, we are having problems with managing everything at one place Especially if we go at scale and in postline I can be proud of we had like 220 students and weekly sessions for some time it dropped out it dropped a little bit in the time so we finished with like like hundred students at the end after 40 weeks of classes and It's hard to manage that amount of amount of students without proper tooling So what we were using for my ladies and also jungle girls in post nine. It's Google Docs Google Forms Trilo or asana Facebook Sphinx or PowerPoint for passing that knowledge and a lot of smaller stuff So I was thinking that if All of our groups of jungle girls over the world have the similar problem and from what I heard they have We can adjust the Necessary tooling for removing for Google Google Doc forms for recruitment, which is especially Not nice when reviewing their recruitment process And also we are having issue with the storing the material which is mostly on order github with Which is not so good for not save the users text a V and We could also Use some more stuff. We had first approach on Pico cards event. We I've built our registration app which allowed you to Register and review the users It helped us a lot especially we had over 900 People wanted to join us And but the UX of that and the design is awful because I did it like in 24 hours Just not to use the Google Forms So I would like to invite you to share your ideas. What do you need? What do you expect for an application to handle the workshops today in two hours? So 1455 or to 235 p.m American time to break out free room when we can create a backlog of the features We would like to see an application that would help us do the workshops next time Thank you for your attention and see you in two hours Thank you, and this bet no time here. Okay, so go prepare and Miguel Beltran Just move move. We have not that much time He's going to speak about back Python cool. Yeah, why not? So I think that I have no to introduce myself. I'm lady more known as the mother of robots Um You'll probably find me in the reception desk, please don't do that Are you ready? No, I cannot see what I'm doing. No, well, at least we're seeing something.  What is happening with this? Yeah Okay Two seconds Oh, can you Sorry, I cannot give that much information right now. So you're ready. Okay. Cool. How are you supposed to look? Okay, I don't know what happened there, but that first line is supposed to say pack Python Yeah, I'm Miguel Belter and I work for Babylon Health a company healthcare company digital AI based in London And this is like that. Can you see that? Okay. Yeah.  I'm not a big fan of integrated tests This is a quote by JV Reinsberg So the solution to this is to do consumer driven contract testing This is a pattern to evolve Your services basically With this technique or system what you do is that you have an API and you publish your documentation And every time someone is using that API they will they will generate a contract and then They will send that contract to you and then you can validate that contract every time you are I wasn't really nervous Every time You are building your service you validate that contract and then you can make sure that you're not breaking your clients The thing is that sometimes you are expecting clients to use your API in one way But they then they start to use it in different ways that you didn't know they could but they are still doing it When you have many clients it's really important and you don't break them every time you update your API. So basically this is a way to try to avoid that The system is really simple. You have a consumer that will generate a contract and publish it to a common place Then you have the provider that will download that contract Validate a contract for different consumers. This is like the simple structure Well the library pack Python is just a Python implementation of the pack The standard let's say so it's long with the The standard is language independent it works right with microservices You can move fast and make and be sure that nothing is going to break I don't know if you have the problem of Like when you have like 20 microservices and you need to do integrated test Trying to orchestrate that on a CI is really difficult I've been in that hell many times And this is definitely a way to get out of it. And yeah throw away integration tests If you want to check out the library because this is like in five minutes, I cannot tell you everything about it. You can visit the Website that will tell you everything you need to know Yeah, this is the the website you will find everything here All the libraries for the different languages Python Java everything so it doesn't matter if you're using Many languages in your company can always use that the Python library is actually in active development We definitely need people to get involved If you can give us a hand, that would be great. Thank you so then just go there and Adrienne Adrienne is okay. Just set up your computer really quick Then he's going to speak to us about We don't know what because the deal is the detail will give away the talk so Supposed to be super short. I guess you ready? Yeah Okay, so my name is Ben I work for the Raspberry Pi Foundation and giving this talk a title would have kind of given away the contents of the talk So I haven't given it one So I do a lot of Python on Raspberry Pi and so a lot of things like this so pip install numpy the way this works is It browsers pi pi.py or simple slash numpy Looks for a wheel file with a platform tag matching the current platform If it finds a match it downloads the wheel and installs it and it takes no time That's what the wheel platform the wheel standard in in Python is for Providing pre-built binaries of these packages if they're implemented in C you don't have to rebuild that when you download it if no match is found for the platform that you're on if they only provide if you're on a Linux machine 64 bit and they only provide say windows 32 windows 64 And you don't have a match you have to build the thing from source the package from source and if they don't provide any source along with Their wheels and things then you you fail you can't install it at all so If I type if I go back and type pip install numpy And it says well which type of x86 or 64 are you I have them all so this is what numpy provides Although these are all their different platform wheels for their different versions of Python and different combinations of all of that And it's a well which one are you? Actually, I'm Linux on v7l. That's my platform. It's like what I've never heard of that Here's the source build it yourself and this takes a long time So it takes a reasonable amount of time on a laptop, but on a Raspberry Pi Pi 3 takes about 20 30 minutes And on a pi one it takes two and a half hours. So really With a single core very quite quite slow clock speed takes a long time to build So just running pip install numpy or pip install anything that relies on numpy. You'll be saying I'm waiting a long time So I kind of thought well fine. I'll build my own package repository So pie wheels is essentially the name of the project and the name of the talk So I have a pie three in my in my living room that builds a get a list of all the packages on pi pi and there were 106,000 at the time and I just sat there it's rated it's rated over that list building wheels of all the packages or attempting to I Log all the output from the build process into a database so that I can look back later and see why certain things Failed or look at any information that there is there and Then on the same time I just host a web server and the very minimal unique the minimum you need to do to host a python package repository that will work with with pip is a Directory listing of all the directories with the package names containing in the wheels or or other types of package distributions So that's literally all I do have a raspberry pi Running rasbian derivative at devian with an Apache web server just hosting the files that it's built So this is on this was on github But it wasn't particularly sort of friendly as an open source project in terms of you couldn't exactly get clone this and sort Of set it up and build it feels Tested out for yourself and try and contribute But but it was there And it took ten days to complete the build run so all hundred and six thousand packages It was just the pie was just sitting there over ten days in my living room Just building building and building and I managed to successfully build 76% of those packages And the the repository is live at pie wheels up and not all calm and now pip install numpy if you provide The the URL of the server works And it takes six seconds instead of half an hour or two and a half hours So v2 of pie wheels Is a pie three in the data center? So there's a company called mythic beasts who provide raspberry pi 3 hosting you can rent a raspberry pi for six pounds a month and So I'm using one of those I And rather than build the latest version of every package I'm building every version of every package and again. I'm hosting the repository on the pie this build build run is likely to take a lot longer, but It's I'm gonna have to resolve a come up with a solution for that There's a test suite and installation instructions and develop a documentation on GitHub as well So do take a look at that. I need to complete the build backlog Continues build all releases try to fix anything that fail and look at things like that rebuild for different Python versions and See if we can enter in recipe and actually Configure pip to use this as an additional index so that users get pie wheels for free without needing to know about it just last last quick thing before I finish is somebody came across this project and asked the The developers of the next-gen Pi Pi project if they would allow uploading arm wheels And they accepted that so you can now upload arm platform wheels to the next-gen Pi Pi and they appear on the The main Pi Pi website So take a look at the GitHub project if you're interested and come and talk to me. Thank you Okay, since that it has been some kind of misunderstanding. So we have two lists for the Lightning talk sessions. We're gonna Try to unify them, but the one with the small ones so Christian Barra Victor and you out We're going to be the last ones Now Adrian's going to speak to us about beautiful Django also it's here Tom Who wants to speak about building the indie web? Yep, so if you can come here and Configured everything There you go. You were you prepare You were ready to go Not yet. Nope. Not yet So also we are having oh Yep, we're having so a bit more talks than time. So We're going to do a survey later because now we're going to hear about Adrian Hi everyone, I want to talk to you about beautiful Django and it's a bit of a call for help So first Who here use Django? Raise hand. Okay And who has read beautiful card? Oh cool, so It's quite an old book now, but the ID is each chapter is written by a different person The subject is completely free. It could be tech related or about documentation about an internals of any technology And the aim is to illustrate What a beautiful code is so with beautiful Django, which is a book for and from the community Wanted to do the exact same thing So right now it's not going really good because it's still the beginning I'm lacking some time and money to launch this project Sounds like a real life project anyway What we have so far we have a github repo you can find it on beauty on github beautiful Django We have a website manifesto code of conduct the diversity statement We already have some developer ready to help one reviewer. We also have some good feedback right now So, but I still need you so all you can help maybe you could provide a chapter Help with the editing spreading the word Giving help for reviews giving some feedbacks and Anything else you can think about Last but not least maybe Django isn't the right subject Maybe the this idea would be better if used with a python Maybe you can talk to me about it later and if you need any more info or contact information You can go on beautiful Django.com I'm leaving your python today. So please just send me an email. Thank you I think that it's officially lunchtime now. So I'm going to ask you want to go to still see the Lights the lighting doctor left Do you how many of you want to sacrifice a bit of the lunchtime? No one one Okay, it's a bit sad. Anyway Well, we'll continue until there's no one left probably. Yeah, that's why so She or but Can you for yourself and now we're gonna hear about building the indie web? Hello, I'm Tom. I'll try not to keep you from your lunch for too long So I'm gonna talk about the indie web. It's a community. I've been involved in for a while It's trying to build an alternative to commercial social networks. It is simple way. Why would you want to do that? Have any of you used any of these services? Please put your hands up Right, you're not using them anymore because they're all dead If you've uploaded photos to them, they're gone. If you've uploaded location to them, they're gone blog posts community forum posts all gone They've been sunsetted Which is another way for saying deleting all your stuff They will have probably written a blog post which contains the sentence. Thank you for being part of our incredible journey Which translates for we got acquired. We're now rich. We're deleting all your stuff The commercial social networks have some other issues too. They can be a bit overly sensorious 2014 Instagram deleted a picture of a newlywed gay couple kissing because they determined it was inappropriate Facebook routinely removes photos of breastfeeding and mastectomy scars because they're apparently pornography This seems bad So I'm part of a community that's trying to build alternatives to this called the indie web We have this radical idea that you should put stuff on the web And that maybe if we work together we could build something that's better or more interesting than the didn't existing corporate social social web So we have a few simple principles Publish on your own site and then syndicate the existing networks So a lot of people will publish on their own site and syndicate out to Twitter or Facebook The HTTP and HTML is kind of enough. We don't need lots of complicated protocols because nobody understands them We reject all this stuff around like Federation and identity because it's way too complicated And you need a PhD to understand it and we've all been on mailing lists where people have argued about this stuff for years And nothing ever happens And you can implement it however you like so long as there's a web page That's kind of all you need so I do it in Django some people do PHP some people do wordpress no JS whatever We're against monoculture Diversity and implementation is good We've built some very lightweight protocols because all of the existing ones were bonkers The we've got three or four of them which are now on the standards track Micropub which is kind of an alternative to all those nasty old XML RPC post your post your blog API is Web mention which is kind of a way to syndicate replies back to your site And Yeah, we'd like to be involved. It's a cool community and we're building stuff. We've got events coming up this year in Berlin and in Dortmund In San Francisco Baltimore Brighton London and Berlin we have bi-weekly Clubs for people to come along and chat and we have an ISE channel which I didn't manage to on there Which is hashtag which is a channel indie web on free node So yeah, we'd like to get involved. It's it's kind of cool community You can come and chat to me afterwards if you like or just go to indie web.org I hope that's interesting So can you Okay, there you are and Bobble Bobble so Shenco It's that many people moving that I cannot identity fee bubble. Is there someone? Oh, there you are. So, okay, just It's going to be someone left Just okay the resistance nice Oh So you're ready or you did some few minutes? Yeah, I think I'm good. Let's see if the projector can do Full HD So let's make more noise as we are few Visible good enough. So hi. I'm ready. I'm gonna show you a quick thing So first of all, who am I? I work for this company called press labs We do I'm a software developer do operations there. We host WordPress one of the biggest problems Well, other than the fact that we run other people's PHP code is that we run our own CDN for hosting so ideally we want when someone wants to access one of our Hosted sites when they when you do a lookup you want to take you to the closest the lowest latency edge We've got and we want DNS to do this for us Sorry, that's a bit cut off, but I'm not gonna fiddle with the projector now We also want to have some redundancy so like you've got multiple edges in geographic locations And we also want to make sure we load balance like We specify weights and well, we basically through DNS make sure that Requests hit all edges in a certain geographical location We could use route 53's policy records for this they do exactly this however they cost about I think I put up euros. They're actually us dollars But still 50 us dollars per record, which if you got like, you know, the apex ww CDN domains adds up to about $150 just for DNS for one customer, which is ridiculous. We couldn't pass that cost on to our computer. So the solution Actually, if you have a look at how AWS implements those policy records, they Documented pretty well and they let you basically kind of roll your own It's just a set of aliases with you specify latency and which location So we roll our own. It's called zinc. It's open source. It's in Python trees How does it got a simple rest API pretty good testing? I think and Let me shut it off So Quick demo time Like this is This is if you see here, like this is the CDN record for A demo site you can see is just an alias an alias to all of this top-level records Now if you go in and change like I want to change the policy Switch it over to some different policy and you will see that It's now saying it's not saying we got a way to welfare reconcile look to basically Solve this problem for us. There we go. It's now green and if I refresh here Hey, and I've got a very simple different policy now with only one IP There is a rest API. We've got swagger. You can check it out. There's Documentation and all that on github you can check out the code here And that's it if you need this, please use it Thank you. So now This nectar and Vita Vita is here Oh cool, so can you come here and configure your? Okay, so He's going to speak about faster testing. Yeah, right cool. So Hi, this is my first ever talk and first lightning talk, so Hope it goes well. I'm gonna do a live demo as well But I'll keep it short So hi, I'm Pavel. I'm not sure the right audience who here uses sublime text All right, we got some people here good who writes tests A lot more yay Great, so I'm gonna show you something. Oh, sorry There it goes. All right, so can you see this a bit? Okay, so we got a little project here it's Got some work that needs to be done. There's a couple of Functions that do work and there's a test module so it tests the work But it's a bit slow And we need to wait for it. So So usually what to do. Yeah, as we write by test here, for instance, if you use by test for Testing, it's good. And then you wait basically for all the tests to finish and some of them might not be as fast as You wish to do it so you keep waiting and waiting and Yeah, you see a lot of fails, which is Which is why we have this slide all of them failed and See Yeah, that's not gonna work really good So there's a better way to do that. We know that so what we usually do is We write by test and then give us a specific module and then run that module It also takes time While it takes time, I don't have any jokes or anything so We basically wasted lots of time and we failed again. So, yeah, well, probably we should fix some of these So here maybe you do Yeah, lightning equals lightning Hopefully that's right Python is larger than awesome and In you rock at least a lot. Well, this probably works and I actually didn't get there that far So yeah, so you could run a specific module any specific test. I'm sure you know that so for instance Let's run just this test Yay, it's much faster because you just ran one test So everyone knows you should run as few tests as possible right when you iterate and work and it also passes so we could So we basically this is basically a plug for my plugin that I built for this thing which basically allows you to Run a specific test in sublime by basically just going to the right location and You just build the right test. You could also build a whole module or the whole project and Since these past tests pass We have another slide Wait, this is not before we This is going really well And all tests pass yay Alright, thank you. That's basically it. Oh Sorry, that's the most important part of course I Hold on the link. That's not what to do Right and here's the link so it's very sad project just four stars. So go ahead and start it one of them is mine Thank you very much. It's Yeah Anyone else wants to talk Does anyone else go we're gonna talk? Yeah, we have four tags nice. Okay. So, yeah And even I think that at the end we're gonna have like four attendees to so it's cool So Vita and Victor can you prefer them? Okay, Vita is going to speak about big book as ankle. Yeah Well, he's going to be to a very selected audience So I think that's good. We are like now.  Yeah, almost You have to be fast. They are hungry I'm afraid of eating you. I'm hungry to I'm ready. Yes. There you go so Who here uses async I own one person to Who here wants to learn async I own? Everyone of course everyone So here's an even sadder project. It has one star but It's sort of a tutorial how you can build an async I own application and it teaches you to build An ASCII video player so you can play movies in your terminal because everybody of course wants that so This is a small repository that shows you how you build an async I own server that can stream data to multiple clients So you connect to it with telnet and it plays movies for you in the terminal So you might want to check this out if you want to see how to how to use async I own There's like five or six tags Which lead you step-by-step through the development of this So Here's the link again, and that's all for me. Thank you He keep it sort for us. So let's clap harder Okay, now Victor is going to go on stage and Anna is pretty much prepared. Yep So no problem. Okay. The last one is gonna be Joao junior is here.  I'm not sure if you are realizing this, but I'm really hungry You ready? cool Oh, no. Yep. Okay, so you're going to do first. Hi everyone. I'm Anna Anna not sorry I just sees Anna not did Victor. I'm doing sure of this Mine is very quick Go to this URL take my survey. I need more responses I'm doing a community research project, and I will be publishing results next year But I really need people to take this survey as many different people as possible And I'm not collecting any private information. I promise I swear I'm just trying to get the word out there So please go there and then retweet the link so that other people take it and thank you Now Victor is going to speak about keyboard UX free-tale Yeah, cool, and it's the last one. So clap really really hard, please Hello everyone Who attended for yesterday's talk about different languages and hardcore with keyboards? Yeah, cool So it's ended up that in most operating systems You have the compose key and you should learn how to use it because like compose key through all the Acrylic stuff in all languages. So I want to take you to the hardcore travel to different group of languages where all the stuff does not help So that's how it's named in originally and that's how it's used in Hollywood and in normal English So clearly group of languages and clearly script So if you Google a little bit for how it looks and what it what it is You may find out this when diagram that says that okay, like the bottom of it is actually Probably Russian or anyway Some career language and it's kind of similar to Latin and kind of similar to old Greek Which is not the case In reality the worst case of girl countries. There's no day critic as idea. So probably if you Yeah, if you can see This Like this letters this letter is not the letter with their critic on the top of it. It's actually different the same goes for all other and If you need more hardcore the Letters that looks almost the same as Latin one is different and yes, there's no unique calculation for that. They're totally different and the keyboard layout is different, too Which is yeah, so we're great for people who use it and if you think it's bad enough. No all this When all this script came after and changed this one Super easy, I guess so The idea help be the global standards if you know what the unique calculation is use it if you know What unique code is use it? If you don't learn about it is great Next the even if this is not the worst part keyboard error comes to people who use the acrylic and If you ever saw the people who use keyboard and speak Russian, Ukrainian some girl language You know that they're using kind of same keyboards as people who use Latin based languages. So 103 keys for the for default keyboards and Curricland wishes have more than the molars than most Latin one. So 33 kind of more than 26 in average. So Rest in peace all the special symbols on keyboard. So all the symbols you can see You actually cannot type them if you're using any curly keyboard out there and If you're a developer or if you're using any program languages, yeah, you have no curly braces Square brackets and all the stuff So super handy, I guess Move the hardcore if you ever saw the curly keyboard you can see the small key with dot and comma and comma in all the curlic layout is an uppercase so to input the comma you need to click shift and dot and If you know something about languages comma is more common than dot So super bad design if you think about it a bit So second idea if you develop and something that probably will stay around for more than one day simple to fit because The moment you release something global it will stay for a long time and sometimes you can throw it back if you like ever heard of Changes in Probably string model in Python 3.6 You only know a lot of bad design came into that which cannot be rolled back because it's already in mainstream And the third idea If you're interested in such stuff read the book called the end of average by Todd Ross The guy actual statistician who worked for US military in second World War actually One of the first people who understood that average Ideas like you take hundreds of people make the average of any measurement and say, okay the mean average is best for this idea is actually sucks and From the time that people saw that like this leads to Like I know thousands of pilots in US military air forces died in second World War two because all the Pilot copics was developed by average metrics of all pilots and this was like hell for everyone from the point of usability so going back to Later in keyboards if your developer then in most cases any keyboard layout out there is bad for you because it was developed for people who using the typewriter to type the text and Source code is different than text so What I can propose for you analyze the text you're typing and see how good your keyboard and your layout How it's how well it suited for your work you can analyze with a Lot of software that can actually make the hit maps for your keyboard While you type in in real time or with your actually type source code or you can use Python collection counter With your source code on the stand to watch some what symbols are more usable for you and You see that any keyboard layout you're using is super bad for you So what we know about it if using Microsoft Windows you can use MS KLC Which stands for Microsoft keyboard layout creator? Super easy tool that can actually build any layout for you So let's say you can move your curly braces and square brackets somewhere in the middle of your keyboard to not Make you pinky crimp the same golf linux with x sense by time


Hi everyone it's MJ and in this video we're going to look at creating functions in R. But let's maybe take a step back and ask ourselves well what is a function? And functions these things are mini sub-programs that contain sets of instructions and they're called on when needed and they can be repeated. Now what does a function contain? It has its input, a set of instructions as well as an output. Now where are the functions in R? Well either you can use pre-made ones in packages or you can create your own and that's what we're going to be doing in this video. But now if we want to make functions we do need a little bit of logic. So it's good to practice logic in R by trying to solve simple problems. If you don't develop your logical programming skills then you will become frustrated with this software. So let's do a simple problem together. Let's sort a bunch of numbers from smallest to largest. Now yes there is the built-in sort function in R but we want to develop our logic so we're going to try and make it ourselves. So how would we sort five random numbers? Well the first thing we need to do is we need to generate five random numbers in R. Let's say between 1 and 10 we can use the following code. MyNumbers is equal to a sample from 1 to 10 and we want five numbers and this will return a selector of 5, 10, 4, 2 and 3. Then I mean we could use the R function of sort myNumbers and we'll get 2, 3, 4, 5 and 10 but we are going to create our own function to try and mimic this. So it will kind of be of the structure. It will be mySort is equal to function and then with the open brackets you want to put in your parameters and then in your curly brackets you're going to put in the code. But it's best to think about a function before you start typing. So we're just going to go through a little bit of the logic and then we're going to go to our studio and program it together. So one of the ways that we can sort is to use this algorithm known as the bubble sort. So let's walk it through. How the bubble sort works is you first compare position 1 and 2. So we compare 5 and 10 and we will swap if 5 is bigger than 10. In this case it's not so we don't do anything. We then compare position 2 and 3. So we're comparing 10 and 4 and we will swap if 10 is bigger than 4 and it is. So the new arrangement is going to be 5, 4, 10, 2 and 3. So we can see we've swapped position 2 and 3. We then compare position 3 and 4 and now this new position 3 is 10. And so we're comparing 10 and 2 and we're going to swap if 10 is bigger than 2. It is so the new arrangement is 5, 4, 2, 10, 3. So we can see 10 has moved from position 2 all the way up to position 4 and then we compare position 4 and 5. So we're comparing 10 and 3 and again we're going to swap if 10 is bigger than 3 and it is so the new arrangement is 5, 4, 2, 3 and 10. Now what we do is we repeat the steps but we don't have to do this final comparison of 4 and 5 because the first cycle will have kicked the biggest number to the final place. So the biggest number is in place. After we've done the second repeat we'll then repeat for a third time but now we don't have to compare positions 3 and 4 because now the second biggest is in place. And then we repeat again but we don't have to compare 2 and 3 because the third biggest is in place and essentially what we're doing this is we're doing the cycles four times with one less comparison in each and essentially we are sorting the numbers by kicking the biggest one to the end then reducing the amount of comparisons we're doing and kicking those to the biggest and that's how it will eventually get sorted. So this is our algorithm but how do we translate this into code? Well what we're going to need is we're going to need two loops. We're going to need an inner loop and this is going to be doing the comparing positions and we can use a while loop for this and then there's going to be our outer loop which is going to be repeating the steps and we can use a for loop. So let's maybe discuss very quickly what a for and while loop is and then we're going to join the two together with the algorithm of swapping to come up with our function. So the for loop example if you had to go type in r 4k in 1 to 10 and then say print and then in brackets k then what will happen is you like the return will be an ascending list from 1 to 10 and you can also do it in the other way around you can say 4k in 10 to 1 print k and this will return a descending list from 10 to 1 and I recommend that you type this into r and you see that for loops they're not that difficult to actually set up. Now for our function we want the outer loop to depend on the amount of numbers we have. So the first thing we will do is you'll say n is equal to length and then the vector that we created and then our for loop will be k in n to 2 and we then will open up our curly brackets and have all of our code. So in our example our length is 5 so the first cycle we're comparing four pairs in the second cycle we're comparing three pairs, third cycle we're comparing two pairs and the fourth and final cycle we're comparing one pair. So we would want our k to be 5, 4, 3 and 2 and because this number is descending this is where we're going to be getting our while loop. So let's maybe talk very quickly about a while loop. With a while loop you want to have your parameter so I sometimes just use i so i is equal to 1 and then I say while i is less than 5 do something so let's say print i very very important that you have this thing where the i then steps up or changes otherwise your while loop is going to go on forever because i will always be less than 5 if it stays as 1 so you want to make sure that you increase it that way your while loop will end and if we had to type in this code in r we'd get numbers like 1, 2, 3 and 4. Now what we want to do is we've got our after loop and our inner loop and we can now combine the two together so we can say 4k and n to 2 open up our curly brackets i equals 1 while i is less than k and then we will open up put in our our code over there with the dot dot dot remember to say i equals i plus 1 and then you just want to make sure that you close the brackets and this is a little bit confusing having a loop within a loop that's why I say it's good to to play around with this in r with the print function so that you can see how the the loops are changing but yes this is a complicated idea is to have two loops one inside of each other and now just to make matters a little bit more complicated we're going to talk about the swapping process so the code we're going to use is we're going to say if my numbers at position i is greater than my numbers at the next position then what we want to do is we want to say the temporary variable is going to be equal to my numbers 1 plus i we're going to say my numbers 1 plus i is equal to my numbers i and then my numbers i is going to be equal to this temp and that's going to allow for a swap in positions so for example if my numbers 2 is equal to 10 and my numbers 3 is equal to 4 and you know if 10 is greater than 4 then we will create this temp value to be equal to 4 my numbers 3 we can now make it as 10 and my numbers 2 we are going to make it equal to the temp which is 4 and I guess y'all we need this temporary temp variable because in programming you can't change two values simultaneously so that's why you kind of need need a little bit of that but I have gone through this quite quickly so maybe watch this again if I lost any of you but we are going to go through it now in in r so let's go and do that so let's program this bubble sort function in r and maybe one thing that we can do just so that we're on the same page is we can set the same seat this way we will get the same random numbers I like the number 23 but you can type in any number that you want then what we need is our vector of numbers so we're going to say my numbers is equal and we're going to use the sample function and we want numbers between 1 and 10 and we want five of them so that's what my so if we had to quickly just run this we will set that set the seeds of 23 and we click run and then if we bring up my numbers and we run that as well we should get eight three ten one and nine and if you use the same seat you're going to get the same numbers okay now what we want to do is program my sort so this is the function that we're going to be creating so we call it function and it's just going to have the single parameter which is the vector so we've got our little function and first thing we want to do is we want to know the length so we want to just say n is equal to the length and we're going to say the length not of my numbers but of this parameter x remember when we run the function instead of writing x we've been going to write my numbers so that's why we're putting x in over there then as we discussed in the earlier we're going to need the two loops and the outer loop is going to be being our for loop so we're going to say 4k in in to two and what we're going to do is then open up the brackets over here now inside these brackets we're going to have our while loop and remember with the while loop you just want to start with saying i is equal to 1 and then you say while i is less than k we're then going to carry out our little function so once we've got inside the while loop we're now going to have our if statement so we're going to say if and now we're comparing our two numbers so we're going to be first comparing you know x with i and we're going to be seeing is this going to be bigger than the next position so we're going to say i plus 1 and then you can see there's a lot of and this is the level thing about using the script editor as you can see it does this indentation for us on our own remember we do need the the temporary variable just to kind of hold what is in the x i plus 1 so let's go i plus 1 otherwise we're not going to be able to we're going to be overwriting it because yeah x i plus 1 is now going to be equal to the previous one and if we didn't create the temporary then when we come to our x i is equal we're going to say x i plus 1 because sorry keep going i plus 1 we can't do it is that because then it's just going to equal itself because of this one here and that's why we had created the temporary so this is why we create the temp and then that's going to allow the swapping to occur then when you create while loops you just want to make sure that you now increase your i so i plus 1 otherwise the while loop is going to go on forever and what we can do now is we can even have it so that in our sorting function it returns our variable of x so what we can do now is we can just run this all into the code and now when we come to our console so we come down to the bottom of our console and we say my sort and we put in my numbers lo and behold we now get the numbers sorted perfectly and what's quite cool is let's say we wanted to set the seed to 25 okay so we set the seed to 25 and we now generate a new um bunch of numbers so let's get our numbers over here we've now got seven eight four one and ten then we can simply sort these numbers and we've got them one four seven eight and ten and because we've made it so that our length is you know it's n we can even have a longer vector so let's say we want to do it with ten numbers we can then come in and say my numbers two and we now have ten numbers and now we can go my sort on my numbers two and we can see that it will now even sort ten numbers for us as well so that's pretty cool so yeah we've got my numbers at seven eight four one and ten we've got my sort of my numbers and it'll give us one four seven eight ten look you could always have used the built in sorting function of our um and if we'd come in my numbers it would have done exactly that for us but remember the point of this exercise was to develop a little bit of our logic and to see how to create quite an advanced function because I mean we had two loops and we had an if statement so quite a lot was happening in this function it is quite a complicated one but I think it's a great way to to learn I think if you can if you can master this function you can you can master the others as well so in conclusion I mean what we've seen is that there are many useful functions have already been created and you can access them by installing the relevant packages in R but sometimes you will want to create your own function and look it it's not an easy thing to do and that's why if you are serious about R it's good to practice logic by giving yourself simple problems to solve and that kind of ends this R beginner course so now you must be asking yourself well what's next and I mean gosh this list it's it could go on forever but there are so many different topics that you can now use R and explore so we will be creating future courses so stay tuned watch the space new things will be popping up but if you're very impatient and you want to watch something right now I do have some videos on YouTube where I'm using Android Studio which is also an object oriented program and I'm kind of creating more advanced functions around just sorting what I'm doing is I'm creating a poker game and I'm checking to see if I've got a you know a pair or a full house or a flush or a straight and different things like that and it's quite cool to program a game because then you have like an end result of a nice little mini project and so you can go and see what I did with poker of course Android Studio the syntax will be a little bit different to R but at the end of the day logic is the same throughout programming but as always thanks so much for watching and I hope to see you all soon cheers