Hello, and welcome back to the Sports Biomechanics lecture series supported by the International Society of Biomechanics in Sports and sponsored by Viacom. For the second part of today's hat trick of lectures, we're joined by a special guest. We've got Architz Navander, who is a lecturer in biomechanics at the European University of Madrid. Architz is going to take us through a brief overview of hamstring injuries in soccer and some of the research relating to that, and hopefully focus a little more on some of the applied research and implications of that literature. Thank you very much for joining us Architz and over to you. Thank you Stuart. It's a pleasure to be part of this great initiative, organized by yourself and supported by the ISPS and Viacom in particular. And before I start, I hope those of you watching at home are safe, are doing fine in these difficult times and sorry your family members and your close ones. The situation isn't the best, but hopefully we'll come through this stronger and better. So, today what I'm going to be talking about is simple biomechanics behind hamstring injury in football, in soccer or football, whatever you may call that. My talk is going to be very basic. It's focused on, I'm trying to be as simple as possible, trying to explain simple biomechanical concepts to somebody who may not perhaps have a background in biomechanics. Again, feel free to get in touch with me. You have my contact details there. And I'd be more than happy to help and talk about other research that we've been doing. So I'm, you look at this, you say, this is a guy, he's got a weird name. What's he doing in Madrid? So I'm not a Spanish citizen. I'm from India. And that's where, like I said, the journey begins. I've not heard of biomechanics about 12 years ago. What I heard was some, I remember watching a documentary done by researchers in Western Australia about cricket bowling. And when I was back in university in India, and I got an opportunity to come to Spain for an internship. And I said, let me go try it. And obviously I love football. And that convinced me that once I finished my engineering degree to come and study my masters, my PhD, my postdoc in Spain from 2011 onwards. And right now, I'm working as a lecturer, enjoying the broth life. And I've been working in this area of hamstring injuries in soccer, been trying to research in this area since 2012. And I want to make it very, very clear that I'm not an expert in this, because I'm still learning, and every day I learn something new and or learn something which might be contradictory to what you've learned earlier. So if one would just search for hamstring injury, the word hamstring injury on PubMed, you'd come up with about 3000 for 3000 records. It's very difficult to read about 300 studies every, every year. That's the number that those are showing in the graphs. Specifically in soccer or football. It's a hot topic. You talk about 482 articles which have already been published on PubMed. There are a lot of articles which aren't on PubMed. But again, there are, which have gone through peer review. There are 32 reviews, specifically, again, looking at PubMed data on hamstring injury in football or soccer, when you search for these things. So, one more to ask, where do we start with so much information, you might be, what do I do, where do I, where can I start I'm interested in this is a hot topic. I'm, I want to know what can I do to understand hamstring injuries, or I have an athlete that has hamstring injury where do I start how do I go about looking for for rehabilitation program. So, a good source probably would be to look at the cause of integral model of the cause of injury. So, because this is a model developed by researchers in my few couple of Nordic researchers who are this and this paper is really well explained So, just to simple things down.  And predisposed athlete is exposed to some external risk factors, which are not in his control equipment location. And makes that makes it susceptible. The sum of internal risk factors and external risk factors, make an athlete susceptible to injury. And then finally, you have the injury mechanism, and you have the athlete who's getting injured. This is what we call on the cause of an injury, we can identify risk factors, external risk factors energy mechanisms. These are three things that we need to tackle in order to prevent injury from occurring or reducing the incidence of an injury from occurring Because there's a lot of people who say that you know you cannot prevent an injury completely but you can what you can do is try to reduce the risk of it. So, talking about injuries and football. It's football and soccer is basically a very injury prone sport. On an average, in Spain this data from Spain. You talk about 81 injuries per team per season. A single injury on an average can vary from a couple of days off single day off to about six months or eight months off. But an average would say about 11 to 12 days. So it causes a loss of playing time and a loss of money as well. Apart from the loss of resources, we can especially look at non contact injuries, of which almost 50% of non contact injuries are muscle injuries. Among these, in soccer, almost 85% affect the lower extremity. There's the thigh, the shank, the foot, and the majority of the thigh injuries affect the hamstring muscles, specifically the bicep femoris. So what are these hamstring muscles that one refers to? These are muscles located in the posterior part of your thigh, consist basically of three muscles, the bicep femoris, the semitendinosis and the semi-embranosis. The bicep femoris is the biggest of these two muscles and is biarticular because it goes over the hip joint and the knee joint. The main functions of these muscles are to flex the knee, help in the extension of the hip along with the gluteus maximus, and this biarticular mechanism, biarticular characteristic of the muscles, and a unique characteristic of this muscle of, especially the bicep femoris, is its dual innervation. It's not a single nerve that activates the muscle, but there are two nerves.  These are innervated by two different nerves and that many believe could be a cause of an injury. So if you're looking at where to start about to understand the hamstring muscle complex, this reference from Beltran is really, really good. So what makes one susceptible to hamstring injury? Obviously, the most common risk factor is having sustained the previous injury. The athletes are more susceptible of getting injured, that is, the younger you are, lower probability of getting injured. Males are more likely to be injured and have a higher injury rate as well. And there might be a deficit of force, especially in the lower muscle strength in the hamstring muscle complex. But how do hamstring injuries occur? They have various injury mechanisms, but the majority can almost 50 or 60% of these injuries occur during sprints. During the final part of the sprint, as you can see over here, just when the hamstring muscles change from eccentric to concentric action, if they change, they move to decelerate the knee in order to flex the knee more just before heel strike. And this movement causes a large biomechanical loads on the muscles. This increases the stress on the muscles. So imagine this happening continuously, constant elongation of these muscles, greater stress, and over a long time, this constant stress going over and over and over and over again, lonely cause the muscle fibers to be susceptible to injuries. So why is it that these, why is it so common in sprinting? I'm not here trying to say that hamstring muscle injuries only occur during sprinting. No, no, no. There are other injury mechanisms as well. Kicking, extending the intervallor through phase, or doing a back heel, jumping, there are different type of mechanisms. A person who is running a 10 kick could also get a hamstring injury. I'm not saying that doesn't happen, but why is it most commonly in sprinting? To understand that, we got to understand a couple of things specifically about force production. In running or sprinting, we can talk about two types of forces. We mainly talk about vertical ground reaction forces, which are, which are used to define the body weight, and to generate movement, generate flight, or horizontal reaction forces. Now these reaction forces are very important because these are forces which cause movement in the anterior posterior direction, that is in the movement direction. There's a breaking force and there's a propulsive force. So at lower velocities, these forces are mainly accounted for by activities of the lower limb. Basically, muscles, such as the tibialis anterioris and the calf muscles, the gastrocnemius and the soleus. This is fine when I have sufficient ground contact time because I have the achilles tendon working, some sort of, to put things very, very simply, working like a spring, absorbing and compressing and expanding, giving away the forces. But at higher velocities, when I sprint, the ground contact times reduce. I spend more time in air than contacting on the ground. So what happens? To do that, I need to be able to generate a lot of forces. I need to increase, I need to be able to generate a lot of forces as my speed increases. So as the speed increases, not only do my breaking forces increase but also my propulsive forces. So if I were to look at an evolution of how stride length and stride frequency change when it comes to running, walking, jogging, running and sprinting, we see that initially, we see large increases in the stride length. If you were to look at stride frequency, it's not so much. However, at higher velocities, when you go above seven meters per second, that's about 23 kilometers per hour to about almost 30 kilometers per hour or 30 kilometers per hour, you see a huge increase in stride frequency. So at these velocities, that's when the hamstring muscles become very active. You have some great work coming out of researchers in France and New Zealand, if I may remember correctly, explaining why this horizontal ground reaction force, especially from Jean-Bennon Maureen, talking about how the hamstring muscles work very, very work a lot to generate these forces at these velocities to produce horizontal force. So if you want to look at EMG activation of the hamstring muscles, basically the bicep hemorrhage and the semitendonosis, as the speed increases, so does the activation. Here the activation of each muscle is given as a percentage of the maximum voluntary contraction. So this is through electromyography where I measured the signal amplitude. So as you can see, the higher the number, the more the activation. So at higher speeds, if I were to divide the sprinting movement in different phases, the stance phase when I'm on the ground, the early swing phase when I just about leave the ground, the mid swing phase and the late swing phase. So as I increase velocities, the hamstring muscle activation, both for the bicep hemorrhage and the semitendonosis increases, especially in the mid swing and the late swing. So what happens with such a great activation and such a high load? There's a greater chance of suffering an injury. What happens to the hamstring muscle complex when there is a previous injury? Recently, there was an interesting paper coming out of some Japanese researchers who analyzed 10 university sprinters and found that in the last part of the swing phase, just before landing for his strike, there's a reduction in activation of the bicep hemorrhage muscle, comparing the uninjured limb with an uninjured limb. Uninjured contralateral limb with the same 10 sprinters, but university level. But however, and this was something that I found just yesterday, studies with Aussie rules football found something totally different where they compared seven injured athletes with eight uninjured athletes. And what they found was that what you see athletes with the previous hamstring injury were recovered from previous hamstring injury in orange. And those without a previous hamstring injury in black had similar muscle activation patterns. So what comes to be what comes to question over here is what is happening? And what happens when muscle is injured? When a muscle is injured, can it does the activation change or does recovery if it activates the same if it activates in the same way as it does without an injury. As in the case we see with professional athletes. Is there a greater chance? Why is there a very high chance of a re-injury? Moreover, can I strengthen these muscles and target them individually? So this was study which we did recently where we looked at three simple hamstring strengthening exercises. And looked at the co-activation between the hamstrings and the quadriceps and compared them for three phases. The downward phase, eccentric phase, isometric phase, the upward concentric phase. Just to put a long story short, what we found was that muscle activation differed between muscles of the same group. So you see the quadriceps consisting of the rectus femoris, vastus medialis and vastus lateralis. Each having different activation patterns in different moments. And the hamstrings, in this case the superficial muscles of the bicep femoris and the semi tendonosis, having different activation patterns as well. So can we really target a single muscle when we try to strengthen it? So far it's not possible. So what do we need to do right now when you look at solving a problem of hamstring, previous hamstring injury. So what we need to do right now is we need to try to eliminate internal risk factors through rehab program, prevent an athlete just getting onto the predisposed state. Is that possible? So a lot of testing has been done, a lot of research has been done all across the world. And many researchers have used, over time have used isokinetic machines to test for the strength. So an isokinetic machine is a machine that works at a constant velocity. As a name suggests isokinetic. And you apply a force, you apply a force against a resistance of the machine, which moves at a constant velocity. And you measure the force that's being applied in these cases. So what they found was that a force deficit in these tests done with this machine could help identify a previous hamstring injury. So identify a force deficit, again, work on the strength and possibly reduce the cost of injury. Do some exercises work better than the others? There's a famous Nordic hamstring exercise which has proven to work in some athletic populations. So well, that if you were to look up some great studies from the Queensland University of Technology, especially headed by Dr. Tony Shield, you'd see some great work coming out of there by the views actually being able to find use the Nordic hamstring and created a Nordboard to evaluate the hamstring strength and determine when an athlete is more susceptible to sustained injury. You also see some other studies such as the Askling L protocol where you try to lengthen the muscle fibers. And again, this has proved to work in the athletes where they have tested with such a converse with the lengthening protocol of these muscles because there's one of the risk factors is having short hamstring muscle fibers. So lengthening them probably could reduce the risk of injury. So these are some exercises which are done off field. Now what about what can I do to work with external risk factors or the injury mechanism itself? So looking at these two factors, what I can do as external risk factors is I can test the athlete in his or her context. If an athlete is a soccer player, I would do the testing on a soccer pitch. Basically, I have wonderful motion capture systems which I can use to analyze movement. So what have some studies found when comparing the differences of a previous injury in the running technique or sprinting technique or sport specific movement. So we're looking at sprinting technique. They found differences basically in the coordination and this coordination was linked to having a higher injury risk. A coordination with a greater trunk lean in the case of having sustained a previous hamstring injury compared to athletes who do not have a previous hamstring injury. It's a very good study by Shermans in Gaten posture, which I really suggest that you should read. For my PhD thesis, I studied the kicking and found something similar and the coordination was what was the most effective when identifying when comparing a previously injured muscle, previously injured subject to an injured subject. So keeping this in mind, can we create a model to prevent not just to reduce the risk of injuries, but actually just eliminate having an athlete predisposed or being susceptible to the problem. And one more thing to keep in mind over here is that an athlete, especially a high performing athlete needs to come back. And continue to perform at a high level. Let me give you an example. If a player is performing, scoring, let's say in soccer, scoring a game, a goal every two games. I need that player to continue to come back and score a goal every two games because that's what's going to define success for me. So my rehab program now becomes a rehab and reconditioning program. So keeping this in mind and keeping the previous studies that we have found some brilliant studies and you have, like I said, you have a lot of studies to look into and some great evidence, scientific evidence, which tell you what works and what could work rather. So the question is, can we prepare a rehab and reconditioning programs specific to professional soccer players, which makes sure that the athlete comes back for sure, stronger, comes back and performs at a very high level, and has a reduced risk of re-injury. So this was a problem planted by a colleague of mine for his BSD thesis. And he's a colleague who works in a professional soccer team. And what he did was he prepared an on-field rehabilitation program, on-field rehab and reconditioning program. The program, just to put it in brief, and this paper is down in the links and you have an open access. It's open access so you can check the exercises or whatever. And it starts with an indoor movement where you have a lot of controlled movements and moves on to a non-field reconditioning program. So indoor is used mainly for strengthening control movements, get the confidence of the player back, move on to on-field reconditioning so that he's not only gaining strength but also performing at a high level. How do we know this player is performing at a very high level? Because all these training methods are being controlled with GPS data. We have technology in professional soccer today. There is technology which one can use to control and monitor progress. So this model was sent out to experts around the world who were working with professional athletes, professional soccer players, and basically they said, yeah, the plan sounds good and let's see if it works. So they validated it, was validated by experts, because it focused on not just strengthening the athlete but also helping him or her make decisions and prepare the athlete for possible injury mechanisms. Making him or her strong to be prepared for the event of the eventuality when such an injury mechanism could affront itself and the athlete can go through unscathed. So did the model work? It's validated, but it worked. So over three seasons, he followed 19 professional players who had suffered an injury, specifically a grade two hamstring injury, which the layoff is about 23, 24 days, about three weeks. And what we did was we looked at their performance before injury, the day that they got back, the return to play, and we did a follow up six to 10 weeks after the return to play. So we considered a game a player to have returned to play completely when he performed, played more than 45 minutes in a match. And the second game was played within 10 weeks. Now we've got to understand in soccer. A lot of times the schedule is not in your hands. You don't decide when the players return to play because a person might be ready to play and it's in preseason. There are no matches. Or the player might be ready to play and he's not selected by coach or does an international break. So the return to play data is not really in the hands of the staff because it's determined by a lot of other factors. So what do we find when we apply this program? The return to play took more or less the same time in three weeks, about 22 days. But what you did find over here was their performance, especially at higher velocities improved. So if I were to look at, I know that here there are a lot of speeds and a lot of graphs over here. So let me try to explain that. So these are velocity distances run at high intensities, very high intensities. And these are any sprints above 25 kilometers per hour. The point represents the distance run per minute in the game before an injury at return to play and at the second competition. So we have at lower or at high intensities, not so bad, the distance they ran stayed more or less the same, improved a little bit. But what we did, where we did see it was this one we're able to run, cover more distances at higher intensities. One good way of seeing that is looking at the work, work to rest ratio. Work to rest ratio is basically a ratio of the distance run to the distance what is it the distance run about 6.4 kilometers per hour to the distance run in those 6.4 kilometers per hour. So regardless, it has stayed the same. But what has increased is their intensity performance. And the players are performing as good as they are, as they were earlier, if not better. And there was no cause of injury. And this model what you've seen is over three seasons. Obviously, this hasn't, this wasn't done overnight, you don't have 19 injuries in one season. And these are data from two clubs, not just one club. So that is something that has to be kept in mind. We have been able to prepare the athlete to come back to play. One thing that I forgot to mention was that the athlete didn't suffer a re-injury in the eight months for in the follow up that we, that we did eight months after having sustained injury. So an athlete is more prone to having a re-injury within one or two months in the case of hamstring injury. So we did a follow up for eight months. And in eight months, there was no injury. But now the question comes in is, can we shorten these timelines? Instead of three weeks, can we reduce it to two weeks? So this is something that was just accepted like yesterday or two days back is a case study with two players. And where the return to play was done within, where the player returned to play within two weeks. And missed only a single competitive game. Not just that we reduce the time loss, but the performance of the player was sustained. Now, all this sounds beautiful, sounds great when it is done in practice. And these are results that we have got. But there's one thing that one has to keep in mind. I'm just going to show you a video so that you can understand this concept a little better.  So basically what I wanted to say over here is that I may have the same rehab technique as a professional. But I got to know my audience, I got to know who I'm treating over here. I can't treat the same person. I can't apply the same program to everybody and that's not going to work. I need to understand the characteristics of the person that I'm treating. So if you are a biomechanist, how could one help in the rehab and reconditioning of a professional athlete? What is your role as one could go to? You could identify risk factors. That's the first thing that you're going to do, specific to the sport. Identify the demands of the sport. Look up research because I'm sure that how innovative your idea that other people simultaneously equally talented is not better already working on it. What of that research can you adapt? What can you accept? What can't you accept? For example, there's research which shows that the Nordic hamstring injuries, Nordic hamstring protocol worked brilliantly. But for some reason or the other, coaches and players are reluctant to implement that program. So you need to do something that they accept to do. It's very difficult to convince people when you're working the professional athlete and you're just a biomechanist. Make sure you monitor programs and always, always look to improve. So these six points I think are very important that one can keep in mind when you're looking at improving the rehab and reconditioning for not just for a hamstring injury, but for any other injury that you're looking at. And for those of you who are just about starting off or in the middle of your research program, doing your PhDs, doing your masters, or thinking about doing a masters, thinking about doing a PhD, think about learning more in this field. I would say just dare to dream. And you never know when the opportunity would come knocking on the door. Be prepared for that. I've had the chance to work with professional athletes at the elite level. But like I said, I've also had a lot of times when I didn't have that opportunity. But at the same time, make sure that you make the most of the time that you have at your hands.  You get a lot of rejections. My first article was published after being rejected. I think eight or nine times. And my first project as a lead investigator was accepted after, again, 12 project applications. So you need to persevere. But at the same time, one of the most important things that I've learned in these ages these times is don't forget to have fun. Make sure you make the most of it, especially given the times that you are that we are in. Enjoy your time with your family with your friends. And with your colleagues as well. So I just want to say a big thank you to all my fellow researchers to the athletes who have participated in particular. My colleagues at the university out of pay and my previous university, the technical University of Madrid, and stay safe. I'm here I'll be more than willing to get in touch with you so feel free to send me a question. Or write me by email or by Twitter and Instagram and I'll be more than happy to answer your questions as to the best of my knowledge. Okay, so that's my job. Thank you very much. And over to George. Thanks, that was great. I really enjoyed it. I've told you this before, but I really like your slides. I think they're brilliant. I love the stay home messages at the end. Thanks for that. Personally, I really like the fact you displayed individual data points as well from individual athletes rather than just masking them with group means. So we can really look into it and say, are there responders and non responders or how did what's the individual variation between the athletes and I thought that was really cool. The other reason which I mentioned to you beforehand why I really like this is a few people are where I previously torn both of my hamstrings. So this was relevant to me, what not quite so many people know is actually tall the first one while putting my sock on. So that's my kind of embarrassing story out of the way when you said hamstring injuries don't only occur during sprinting. That's definitely true for me. The kind of first question I just wondered if you could touch upon a little bit was the role of other muscle groups in hamstring injuries. So both in injury risk factors or injury prevention, things like the quadriceps and how that interacts with the hamstrings. So that's a very good question that you that you raise over here so I can talk about a couple of things over here and not just research that we've done and but also research other other groups have done. And especially we see a lot of work from from different researchers who said that you know hamstring muscles can't be targeted individually or as a group as a whole, and one must look at the complimentary muscles. And what we found in kicking, at least what I found my thesis was that there are phases if I were to divide the kicking in different phases that probably you'll see that in needs lecture a little later on. There is first the backswing phase for the hip extends and the knee flexes. Then there's the leg cocking phase where I have the hip. Beginning to flex while the knee continues to flex. The leg acceleration as the hip flexes then the knee accelerates, extends sorry, and the follow through phase is after the kick where the hip continues to flex the knee extends for something sometime and then begins to flex again. So the first phase of the backswing where the hip extends and the knees flex is very important. Because that's where the hamstrings are really, really active that's, that's their role extension of the hip and flexion of the knee. Now, the second phase, you have the knee flexing and the hip flexing at the same time the leg cocking phase that phase is very, very important so we found a lot of coordination differences there in that phase. So what would pay an important role would be the role, not just of the hip flexors, but also of the hip extensors, especially the gluteus maximus in its role as the extent, the primary extensor of the hip. And, and they also ask muscle and the quadriceps muscles for the flexion of the hip. These muscle groups were something that we tried to target in, it's in Sergio's thesis what he tried to target in his, in his rehab work. So, that's what's helped the rehab program in, in our opinion is that we looked not just at targeting hamstring muscles but also looking at the surrounding muscles, especially what we found to be very crucial was to be the hip extension work that we did the first movements that a player starts to do is control movements in the larger in control lateral movements. And when the player is able is pain free and is able to move in the societal plane. Then we look at hip extension, mainly, but avoid simultaneously it's initially avoid something is hip and the flexion.  I hope that answers your question. Yeah, that's brilliant. Thank you. And that speaking about different muscle groups and their interaction leads me on quite nicely to a question we've got on YouTube from surprise char and apologies if I pronounced that wrongly again. But they've asked specifically to do with isokinetic testing I'm not sure how familiar you are with kind of dynamometry and isokinetic testing. Whether you prefer the traditional HQ ratio, so concentric hamstring concentric or the functional ratio. Concentric quads and eccentric hamstrings to see a symmetry. And then a follow on question or an alternative question is for sprinters. Is it better to test them at a high velocity, because they're sprinters, and because that's a greater power output, or to test them at a low velocity to get maximum strength. Good luck. Yeah. It's a good question from from superior. I'm talking about isokinetic testing and what sort of ratio would would work. Obviously, if you were to read literature, it would would say to the functional ratio that's better. And here this is a big, I would say a big problem, if I may say so, or a big question that might come up is the athletes willingness to participate in the test. Because when a person participates nice kind of testing. He has his quads and his hamstrings quite loaded, especially when you test at lower velocities and lower velocities require a lot of strength and that takes out a lot of strength, a lot of movement because you have restricted movement for an athlete. And that would make it very difficult for the player to participate. So from personal experience, I did do isokinetic testing once. Sorry twice. Once when I was working for my master's thesis with semi professional club in Madrid, and they actually what happened was they lost. They, they couldn't train for one day after doing the testing, but didn't have so I wanted to do a follow up testing of regular testing with them. And the coach said, no way, my players are very tired after doing this testing we're not doing this testing again. And when I was working with a professional club, this testing was done only preseason with injured athletes. So, the problem with low velocity testing is that you would see a lot of forces, a lot of strength. You could see the maximum power develop the maximum torque that can be developed by these in these movements. But then again, and what's what's your trade off. What's your trade off. What we found is, again, and there's some research coming out from from Qatar from the aspire group, which says that, you know, I said, can you take testing may not be the best way to break hamstring injuries in soccer players. And they've tested like about 200 or 300 players that's some very good research from Nick, Nick Van der Horst, and the aspire group in Qatar, which has some interesting data. So, what we have done is we are lucky over here in Madrid, or this is where I've worked is we've looked at the strength in using using EMG. And it's not invasive. It doesn't hurt the player such these are regular strength exercise that a player does. So, that could work as an alternative, but is it going to predict injuries. I think injury prediction is very, very something that's very, very difficult to to determine to just certain in my opinion, because you never know because you might say, we do this, this works brilliantly. I got the solution for for for that's a XYZ in this XYZ thing and then the next very next day. You have three country muscle tears. That's happened. I've seen that face to face and that's how it is. Unfortunately, hope that answers your question. Yeah, thank you. I think on that. It's really important for us to remember that EMG doesn't measure muscle force, but I think getting a holistic view and adding everything in, adding in the muscle activation patterns as well as isokinetic testing and HQ ratios obviously gives a component that could be an extra little layer to the picture. And that line, I think if you're looking at those studies, I mean this again from the QUT group from from Australia from from Queensland, Steven do pick if you see his paper D you HIG do he's got some great work on on isokinetic testing and any energy. Thank you. And, and yeah, just if, if they're not already down there the all of the papers that archit mentions during his lecture will be in the description below the YouTube video as soon as possible. So check back for those and follow the links and hopefully I believe they're all open access as well. Just a last huge thank you for that archit that was brilliant. And please do go back and view the previous lectures or look out for the ones still to come, including nails later today, which on soccer kicking biomechanics will hopefully tie in quite nicely to some of the things we've already looked at. So hopefully see you soon.


And I, it's my privilege to invite on stage, Mr. Amit Vatwani, the director of Sai Estate Consultants. Thank you. Let's welcome him. News genre helps in regularizing the real estate industry. Over to you, Mr. Amit. Good evening. Had this been a real estate award function, I wouldn't have really liked somebody interrupting such an awesome award show. But I'll just try and keep, not come between the award section. And my sore throat will actually help me stay away from the awards and we'll get back to the awards very soon. I just wanted to tell you guys about what we do. We are a vanilla-broken company with offices in Delhi and Mumbai at the moment. And we have a budget of about 90 odd crore rupees, which we spend majorly in print across the western part of the country. And Mr. Rajiv Shukla spoke about whether the world prefers republic or times. I don't know about it as yet, but I'll be able to tell you in six months because I have contracts with both the news channels. But from today's evening, it seems CNBC also is one channel that I should look at as an advertiser to spend some money and spare some budgets. We've created this brand, but typically we are a vanilla-broken company. We help people identify homes. Many times people refer to me as a developer, but I'm not a developer. We help people identify homes like what many of the English and American companies do. And we are happy to be termed as the Patanjali of the Indian-broken industry. We do about 6,000 crores of sales and we aspire to come up with our IPO in 2019-20, which will be the first IPO of a real estate broker of Indian origin. Today is also a very special day because it marks my 100th day of knowing Mr. Anurag Bhattara. I'm a big fan of him and this also completes my 11 events as one of the partners or sponsors or well-wishers for media, business world and Realty Plus. And I wish to be here more often. Thank you very much and congratulations to everybody who's made it. Cheers. Amit, stay. Please. Amit, please stay.


Okay, so let's try another mechanism here or learn another mechanism So if we have a primary alcohol like butanol here And we react it with fine ill chloride. That's this SOCl2 business, okay fine ill chloride you're going to Substitute the OH group for a CO, okay? so this reaction When you react it with a primary alcohol is going to do that SN2 reaction as the last step again So let's go over the mechanism this ether here. That's just the solvent. We don't have to worry about Everybody got this written down. Can I So fine ill chloride I don't think you've seen already, but you should be able to Try to draw the structure and have a pretty reasonably good guess at it I'm going to draw it like this even though If I post this on YouTube, which I will people will be like, huh, there's not really a double bond in between that sulfur But it's easier for you to think about it. I'll still post this don't I ain't afraid of the haters Okay, and I'm going to explicitly show those electrons on my oxygen there So just to go back to what I was saying Usually when you have the sulfur oxygen double bonds the better Resonance form is that But it's easier to see the mechanism doing it this way and it's hard hard for Introductory organic students to deal with that permanent Okay, so the first step is that the nucleophile here is going to react with the electrophile The nucleophile being the alcohol the electrophile being the thionyl chloride Specifically going to react At the sulfur of the thionyl chloride. Okay, so what we're going to do is take those oxygen electrons attack the sulfur and make that double bond Electrons go up to the oxygen kind of like what it looks like in that other resonance Okay, so I want you to try to draw that on your own While I'm drawing it up here and tell me Did you get it right? Is that what you drew? Or would have drawn did you get it? No, yes Now draw the product is that what you would have drawn Remember just do what your arrows are showing and you'll get it right every time The next thing is we got to get one of these chlorines Ah Okay, I'm going to erase this Because that one of these chlorines is going to come back and do that SN2 reaction at the end So what we're going to do is take these electrons Make that double bond again, and that's going to kick off the Chlorine as a leading group So I put the chlorine up there up at the top because it's going to I want to show that back Questions on anything so far Does it make sense? Okay, so now here's the SN2 part Okay, so the chlorine is going to come And attack from the back side of this big leaving group everybody okay with that and Then we're going to actually make a Couple of other little pieces here the leaving group just doesn't leave like that We're going to make that double bond there in between the sulfur and oxygen and Doing that is going to kick off the last chlorine now the important part of our reaction is done We've made the alkyl chloride like what we were looking for I'm going to draw it like that just to emphasize that it came from the other side We've also made protonated sulfur dioxide Hopefully you wrote that And then the cl-minus as well you could think of this cl-minus as deprotonating that Hydrogen and that's like the last step Even though we already got the molecule we were looking when we do that. We get SO2 Hopefully I'm not off the video range Am I? Okay, yeah, I mean as long as the board is that yeah, that's all that matters Okay, here we could do this like I say this is the part we were really looking for questions on this mechanism Fine alkyl chloride reacting with the primary alcohol. Okay


Hello, everybody, I'm evil rabbit. That's an F1 car This is the KS wheel But not what you're expecting We're gonna go full send and we're gonna be trying to drift this car This is a drift mod from red mods. So we're gonna take a Look and see if we can drift with the KS wheel. I didn't know recommend this because this feels like this Smacking could hurt Let's go full send make sure you guys follow me on social media. I'll try on the description box below. Well, let's do it This is have a manual trans and a handbrake I'm not sure how it's gonna work. Oh boy Full send Like I said, this is not gonna be fun if this wheel smacks me in the hand Like that. Oh, okay. Yeah, definitely need to try and keep the hands on the wheel as much as possible Otherwise, this could be very bad And this could hurt extremely On this R12 Come on We may start a new series called the undrissible drift It takes some weird cars that are not meant to drift Kind of getting it. It's so weird. Whoa. I also don't know this track But you know what? No excuses. Oh my gosh This is not what goes ahead in mind when they sent me this KS wheel. I Bet but then like what is this man doing? Now there's a couple other moza guys drifters That drift with some of the GS wheels and stuff This looks like so much fun. It's not figured we do it today. You're on a zender boost.  I don't know where to grab the wheel. We're doing this, but we're actually not doing too bad. Oh As I say that we're going We're going all around. We got this this just looks super crazy to see this is up there. We're trying to drift a NASCAR or not racing. We're slowly getting it though. We kind of managed to complete Full lap but this entry is going to be something else. Nope That would have been definitely Epic if we would have made that entry and now I just want to take this car say to a An actual competition track like Irvendale and see if it's possible Getting a lot more confident, but this car is very skating I believe this car is almost a drift poor tire. So not much traction involved But we are able to drift this car Definitely not the easiest I've ever done go to grab it I don't know where to grab it because there's nothing in the middle So I think we need to go to a comp tracks and see we can run this at say Irvendale to pull scent We're an ESDA Irvendale And F1 car. I don't think this is gonna handle the bank very well We're about to find out if it does It's surprisingly better than I thought it rotated though.  Just giving a little more steering angle and seeing what we can do I thought I'd be trying this Here we go We got it. Let's get a fun part. Oh, no, I didn't transition into that that clip at all Wing tap it's these hard transitions, but I'm slightly shocked that we were able to do we do we're not in full Full control over the line, so we probably would have zeroed out, but Let's give that one more go And try getting that actual inner turn inner clip This is too much fun. We should get some of it. I'll still should be all found scripture box below on the banks at that time On our way up. Oh That is gonna be extremely hard to get That transition but we got to try it one more time and see if we can't get it to end this episode off because that is a Feet that I would like to get In this car on this wheel I know I can do with a standard wheel if we may grab one and see if we can do it anyways Oh, we wouldn't hit the wall So it's got a standard wheel RSV2 See if we can do it. There's a wall to have to go into there So I think that's gonna do it here for this episode here. I said, of course, it's something a little fun a little different With the new chaos wheel the arc well face. We just picked up the tire over there So as always, I think I should come back and watching. I'll be more rabbit. I'll see you guys on the track


Good afternoon, everybody. My name is Emil, and this is my talk title. Turn hours into seconds using flow for concurrent processing. So I was supposed to give this talk at ElixirCon to UK, but I had to cancel my travel because I felt sick. So let me take this opportunity to thank all of you to give me this wonderful opportunity to talk about something that I'm really excited about. So let's get started. I work with a small team of developers at Code Mansers where we build web applications for our clients. So this talk is based on my recent experience working on a soft real-time system that we built completely with Elixir. So we're going to look at some of the performance optimizations that we did that brought down the execution time of a critical part of the system from a little more than one hour to a few seconds, actually. So first, we look at an example that is similar to the real-world problem that we worked on. Then we'll see the first version of the code that actually had a lot of concurrency problems. Then we look at the second version of the code that fixes the concurrency problems but brings in some other problems. And finally, we'll talk about the actor pattern and the message passing concurrency model and how we use that to solve the problem using Elixir. So let's look at our example. So we are building a module that does season rankings for a multiplayer game. So after the season starts, players from all over the country can come and play this game. And there would be maybe 100 players playing a game. And until the season ends, they can play this game. And at the end of the season, there would be awards going out, like prices given to the top scorers. So there is going to be a leaderboard that will be running throughout the season. And the players will have a rank in this leaderboard. So basically, players get scores based on their actions in the game, which in turn affects their ranks in the season leaderboard. Remember that our ranks are not per game but actually for the whole season. And players can actually check their ranks whenever they want. The scoring calculation will be a function that looks like this. So these are based on the different in-game events, like kills, deaths, and assists. So if you're familiar with Counter-Strike or something like that, it's like that. So there will be kills, deaths, and assists. And then the final score will be a function of these. And these in-game events are actually stored inside a database as a game progresses. So first version of the code is something as simple as this, where we have a function that calculates the scores of all the players of a game and then reranks all the players in the system and then saves the scores and ranks in the database. So we call this function right when the game ends. And we make it asynchronous by wrapping it inside a task. So after each game, there would be a task that spawned that would run the scoring and ranking. And because the tasks run inside separate processes, they can run concurrently. But when we tested this first version, we found that the calculations were going wrong. So we would get duplicate ranks. And this would happen very randomly. So we clearly have comprehensive problems here. So let's understand what's going wrong. So the current, so let's say the current top score in the season is 100. And two games just finished and at the same time, and then two asynchronous tasks respond, which would calculate the scores and ranks for the players. So in each process or in each task, the algorithm would find one top scorer because there is one player whose score is more than 100 in each game. So when these tasks finish execution, we'll end up with two players with rank one. So how do we solve this problem? So what is the first thing that we do when we have concurrency problems or what we are taught to do? So we use locks, right? So we wrap our code inside a lock so that only one scoring can happen at a time. So this is how we write global locks in Elixir, I mean, or Erlang for that matter. So this will make sure that only one of this will run at a time on all the nodes that you have in your cluster. So we use global.trans for this. So now without concurrency, this is how the execution timeline would look because there is no concurrency, it would take a really long time for the scoring to finish, but at least we don't have any bugs right now. But wait, we have actually some other problems today. So we are still in beta. That means we are still in the process of fine tuning our scoring function. So we have some constants that we use inside the function. We have to fine tune them to remove outliers in our scoring. So there'll be somebody who will have like high score in some formula and then we have to remove outliers by adjusting the constants. So every time we do this, and we do this multiple times a day maybe. So every time we do this, we have to redo the scoring of all the players for the whole season. And yeah, so this is how the iteration would look like. So the requirements would change and we'll understand the requirements and we change the code. And then after we change the scoring function, we'll run the scoring again and we'll have to wait for about an hour because we have a lot of games happening. So we redo the scores for all of them. And then we find out that we have another bug. So the problem is that our scoring code is not item-potent. So in order to avoid recalculating a player's score with using all the in-game events of the whole season again and again, we actually calculate the score for this current game and then just add it to the existing score of that user. So this makes the calculations really fast. But this means we cannot run scoring multiple times because the scores would get added multiple times and we would end up with the wrong scores. So now the iteration looks like this. First we change the scoring function and then we delete all the scores. We now do a scoring from the blank state and then wait for an hour to verify and then we end up feeling bad for ourselves because we actually almost thought that this process is good, but it's not good. It's not all right. There has to be a better way. We have to make our scoring item-potent. But that would mean the scoring would take forever to complete. It would take a really long time because we are using all their in-game events for the whole season to calculate the scores and we have to do this for every game one after the other. And we do this every game one after the other because we have locks. But hold on. Why are we even using locks in Elixir when we have the actor model? So previous talks, the excellent talk by Brian also talked about the actor model. So I'm pretty sure you're familiar with it, but again. So the actor model of concurrency says we don't create locks and locks on shared state and change the shared state ourselves, but instead we'll let an actor own the state and we'll send a message to the actor and ask it to change it for us. So let's rethink our solution in terms of actors and message processing. So when each game ends, it will send a message to a scoring queue and the message is going to be a game ID. The scoring queue will forward a list of game IDs that it collected to an actor that fetches a list of player IDs from this list of game IDs. This actor now has a list of player IDs and yeah, it just sends it to an actor which is responsible for scoring the players. And this function is going to be item potent. That means it will use all the in-game events from the database for the whole season. Yeah, before that. So when we do this, this actor is going to be around for some time. So we can do some interesting stuff like caching and eager loading and all these things here. So that's one thing to keep in mind. And then after scoring we, this actor will send a message to another actor to trigger a re-ranking of all the players in the system. So let us look at different ways we can build this message processing system in Elixir. You could use processes. A process as you already know is an entity which executes a function and it can send and receive messages. So if you use processes, all our actors are going to be processes like this. And each process will have a loop which receives a message from a sending process and then does some computation and sends another message to a receiving process down the stream. But this received loop will have to be written by us. But we have more than processes in Elixir. We have OTP, which is a library of behaviors or rather like design patterns that we can use to quickly build solutions to common problems. So OTP is a higher level of abstraction so we don't have to write custom receive loops, but instead we'll write callback functions that the behavior requires and we're all set. In addition to that, modules that are OTP compliant can be added under a supervision tree which makes them fault tolerant. And also there are a lot of tools that OTP comes with which we can use for debugging and inspecting the systems when things go wrong. So GenStage is such a behavior that is available in Elixir. It's not there in our land. Which helps us create demand-driven message passing stages where each stage can be a producer, a consumer or a combination of both like a producer-consumer. Let's see how we can build our pipeline using GenStages. So this is how it would look like so. So here each producer emits an event or events from its queue. Whenever the consumer downstream has capacity or a demand to consume them. So in this case, let's say the second stage which can fetch players. If it can process more events from the previous stage that is the scoring queue, the scoring queue will take a bunch of game IDs from its queue and then send these events downstream. So all this sounds good, but can we create something better, something like this where we have many concurrent stages? So given my past experiences building applications with a lot of moving parts in Ruby and C++, I find building something like this in those languages non-trivial at all. But in Elixir we can build this concurrent event processing pipeline which would allow us to plug our application code inside it in less than 10 lines of code. So all this magic and heavy lifting is done by this little library called Flow which is created and maintained by the Elixir team. So let's recap and look at the levels of abstractions we're talking about. So first we talked about processes which are the building blocks of state encapsulation and message passing. Then we discussed gen stages which help us create demand-driven message streams and now we are discussing Flow which helps us create pipelines that do concurrent stream processing. So what is Flow exactly? So Flow is a module with a bunch of functions built on top of gen stages and we can use that for, developers can use that for expressing computational steps as a neat pipeline which will get executed concurrently. So let's look at an example to understand this better. So let's say our job is to count the number of occurrences of letters and strings like this. So we have a list of strings and then we have to come up with this map where we count the number of occurrences of each letter in the string. So let's see how we can build this using the enum module. So first we'll have a list of strings. Next we'll call a flat map on the strings and then split the strings into words. So we'll end up with a big list of words and then we'll do flat map again and then split these words into letters. So we'll use a function called string.graphines for this which basically does that. And finally we'll prepare a map using map.update and we'll use the reduce function. And then so the map update function actually lets us set an initial value for each letter and then if the keys collide we can actually bump up that count by one. So the code would look like this. So let's see how we can rewrite the same thing using Flow. So the first thing that we'll do is just replace all the enums with flow and nothing else. And lastly we'll insert a function flow.fromenumerable which basically takes the list of strings and hands it over to the flow pipeline. So let's understand what these flow functions do behind the scenes. So flow.fromenumerable takes an enumerable and returns a flow struct. So I think you already know what a struct is from the previous talk. So it basically sets that enumerable inside the struct and returns a struct. But it also does one thing that is smart. So it basically finds out the number of cores that are available on your computer and also sets that inside this map. So that means flow.flatmap will now receive a flow struct and then a function called string.split. So let's see what flow.flatmap does with this. So flow.flatmap takes a flow struct and the function used for mapping and pushes this function into a list of operations inside the struct and returns that struct. So that means flow.reduce will again receive a flow struct and then also receives a reduce function and let's see what flow.reduce does with these. So again, it takes this flow struct, takes a reduce function, pushes that into a list of operations again and then returns this flow struct. So that means all of these functions just keep adding operations to a list inside this struct and just keeps passing around this struct downstream. So from this we understand one important property about flow, that is flow is lazy. The flow struct that gets passed around only gets evaluated when flow is asked to run. So we can make a flow run using, by explicitly asking you to run by calling flow.run or we can enumerate the flow which forces it to run. So as you see here we can pipe the flow to map.new or enum.toolist which basically enumerates the flow which runs the flow. Basically it converts the output of flow to a list and then you can enumerate on it. The second property of flow is that flow is also concurrent. As you already saw flow knows the number of cores in your CPU and I mean in your computer and it uses this information when spawning consumer stages to achieve maximum concurrency. So when our flow pipeline runs on a machine, two cores, flow will first spawn a producer, then spawn two consumers because we have two cores. These consumers will then subscribe to the producer. So inside the consumer flow will run each operation stored in flowstruct one after the other. So the first operation in our flowstruct is a map, a flat map operation. So it basically calls string.split and then splits the string into multiple words. The next operation is another flat map which splits the words into letters. So we'll call that after the first flat map. The last operation is a reduce function which results in a map of letters and the number of occurrences. Then finally we call map.new which basically enumerates the flow and this converts the results into a list which is then given as the input to map.new. So finally we get this result. So if you look at this closer you can see that the counts are wrong. There are two F's and four O's but we get one F and two O's, right? So what happened here? This happened because the same letter goes into both stages. In each of these stages the counts are calculated separately. That means F will have one occurrence in one stage and the same thing in the other stage and when this gets merged into a single map the values of one stage will overwrite the values of the other. So in order to solve this flow provides something called partitioning. So you call this function flowed out partition which makes sure that the same message always goes to the same stage. This uses a hashing function internally. So basically how the hashing function works is you'll give it an input and then give a list of categories that are the number of outputs that are possible. So it will categorize that into one of these categories. So if you have four outputs or four stages then it'll basically give an index between zero and three for any given input. So after we called a flowed out partition flow created a set of new stages downstream and the same letter always goes to the same stage. So this way the same letter does not get repeated in multiple stages and then we get the expected result. So let's recap and look at the flow pipeline that we have created so far. So we started by passing the strings into flow.from enumerable which then gets split into words in a flat map operation. Then the next flat map operation splits the words into letters. Next we partition the letters into multiple stages and then we build the map with their columns. So here's the final code for this pipeline. So there are not many changes from the enum code if you notice. We just changed the enum calls with flow and we added flowed out from enumerable at the top. So you can see a comparison here. So we use flowed out flat map and flowed out reduce for transforming the registry but there are a bunch of other functions that flow provides like filter, map, reject, et cetera which are basically similar to functions with the same names in the enum module and you can use these functions to transform the data in your event stream. So let's go back to our original problem of ranking players. So now that we know how flow works let's try to reimplement the same thing using flow. Instead of starting with flowed out from enumerable we'll start the flow using flowed out from stage. This function is used because in our example we already have a scoring queue which is already built and it sits outside the pipeline. So we just basically want to consume or create a consumer as the starting stage of our pipeline. So we use flowed out from stage which basically sets up a subscription to a producer that sits outside the pipeline. So the events that we receive as part of this like from this producer would be game IDs, list of game IDs, et cetera. And then next we use flowed out flat map to find the player IDs using the game IDs. So if you have a list of game IDs we'll do a database query and find all the player IDs for that list of game IDs here. Next we do a partitioning using player IDs because we don't want to really score players like the same player in multiple stages and save the scores in multiple stages confidently because we would have like weird issues with concurrency if you do that. So we want to make sure that one player ID is always going to one stage. So we partition it using the flowed out partition function. Next we use flowed out map to calculate the scores of each player. And we do this in an idempotent way using all the events in the database or the in-game events that we have for the whole season. So now we pass the scores to the next operation that is another map operation and then we save the scores in the database. And after saving the scores in the database we emit events to a queue which would basically trigger a re-ranking of all the users in the system. So this process that does re-ranking is again not inside the pipe when it sits somewhere outside. So basically it has a queue where it receives events that trigger re-ranking and it may choose to run, let's say once in five minutes or once in 10 minutes or maybe once in an hour. And that logic is not really part of this pipeline. So it sits outside the pipeline and then receives these triggers and then it may choose to do the re-ranking whenever it chooses to. So here is the final code that we have. So we created the flow pipeline using the flow APIs and then we can use flowed out start link. So if you've seen the start link you know that it's something that can be used to establish links between processes. So that means you can use flowed out start link to create this flow pipeline and put it under a supervision tree. So that'll make it fault all the time. So if at all there is any edge case that we have not handled in any of these stages or any of these functions that, so basically playerscorer.scoreplayer is application code, right? It's not flow code. So if you have any bugs there it doesn't crash the whole, I mean crashes it, it crashes the whole flow pipeline but it restarts it again because it's under a supervision tree. So as I mentioned before it took less than 10 lines of code to actually build this topology of message passing that does concurrent processing. We'll actually see some code to compare the first version which had locks and the second version which had flow. I can't see the mirroring option. Can you guys see this in the back? It's a font already. It's okay, I have a lot of time. I have a plan for this. This is going to, okay so, so this is a, what do you say? I just scaffolded a project so it doesn't have anything else. So we have C Okay so, so this is the function that we already saw, right? So there is a, there is a run function which basically does the scoring and everything. So we wrap this inside a task and then we call this function score players with a game ID which scores the game and ignore these functions. I mean this function is basically for benchmarking because I wanted to count the number of games which are scored. So I put a call back. So if you look at score players you'll notice that we accept the game ID and then we do all this reading from the database and calculating total scores. So yeah, so this is the part where it is not idempotent. So we have existing scores and then we merge the new scores. Can you guys see it on the back? So we have existing scores and then we merge the new scores on it and then we sort the scores and then we save it in one shot so that we can save the ranks and scores in one query basically. So okay, so this is the last version where we have the third version where we have used flow and so there is a new file here which is called scorer which is yeah, so which is a file which basically contains only the flow pipeline. So everything else remains in the player scorer dot score player. So we have a scoring queue here which could be a producer like a GenStage producer. So I'll just open score. Yeah, so here I've used GenStage again. So the scoring queue is a producer. So you can see in the innate callback of the GenStage we specify what kind of producer it is. So I mean what kind of stage it is. So here it is a producer. So it will have a push interface where you can push game IDs to it and then it will basically add those game IDs to a queue and then when there's demand from the flow pipeline the pipeline will ask for some game IDs from this queue. So it never just sends game IDs unless there is a demand. So if there is only, let's say there are only two game IDs and then we basically say that okay the max demand is one. So the consumer will ask for one item instead of like bunch of 500. The default I think is 500 or something. So I just ask for one game at a time. So you can specify what demand the consumer should deal with. So yeah, so these are basically the callbacks that we'll write for GenStage. We'll have handle demand which has the logic of how the demand should be handled and the events should be dispatched to the consumer. Okay, so I'll come back to, I mean this is not the focus of the stocks are not really going into details but we'll actually look at the flow pipeline here. Okay, sorry guys, I cannot mirror this for some reason. So let's start with this. Okay, we'll write for this. GameScore. Yeah, so this is the pipeline. We already saw this. And so one interesting thing to notice that so we already had this player-scorer module but if I open this now, so earlier we used to score games. Now we have started scoring players, right? So earlier we used to do scoring one game after the other but now we are doing like each player one after the other.  So that means we'll look at all the games that the player has played and then look at all the in-game actions and then fetch them, do some caching and I'm not doing all those here. We'll do some eager loading and then score a player. So that's a difference here. So we have score player instead of score game and so here I'm using a small flow here. So whenever you have a need for, if you wanna do a map but you want to do concurrent mapping, then you can always use flow because it's very lightweight to spawn processes and then do things concurrently. So you can make something concurrent just by doing this. You have a list and then you have to concurrently map over it. Okay, so let's come back to slide. So we're gonna do some benchmarking on top of this code and the code is on GitHub. It's there if you want to let's check out how this is written. So when we try to score 100 games with 10 players in a game, it took 48 seconds using the version with locks. This means the games will be scored one after the other and then using flow it took three seconds and when we increase the load four times when the number of games became 400 from 100, it took six minutes to execute the scoring and ranking whereas it took only 15 seconds using flow. Now when we bumped it up to 1500 games it took 1140 minutes to complete the whole scoring and using flow it took only 55 seconds. So this is not just because we made it concurrent but it's also because we made it into a flow pipeline. We can do some interesting things like caching and eager loading as I mentioned. So what are the takeaways from the stock? So let's, so if you're using Elixir or Lang and if you ever reach out for locks then probably you should stop and think and you should think if you can rewrite your algorithm using actors and message passing. Think of event streams when you have to do computations continuously and partition these streams into multiple stages for achieving maximum concurrency. Finally, don't be afraid of concurrency. Elixir makes it easy so use it to your advantage. Thank you. Do you have time for questions? I can take a few questions if you have. I guess no questions. Swaran, you promised you'll ask a question. I have it. So you asked what happens when the number of players increases, right? Okay, so for 100, I don't have it for 1500 games because it would take too long, certain that I call it. So for 100 games, when we start with five players it took 1.3 seconds using flow and with 10 players it took 2.3 and then you can see here. So with 40 players, so okay, we'll compare this. So we have 10 players and it took 2.3. When we increase it four times, it basically increased four times. I'm not doing any caching or anything, so a lot of things can be improved in this demo because the sample code is kind of naive. Won't done anything actually. All right, I think that's it. So one thing is using logs, everything would happen one after the other, right? So here we have, so basically we have made everything concurrent, so all these computations would happen concurrently. We fetch from the database, we do everything concurrently and then we do re-ranking only once. So there we did ranking of all the players after each game, but here you're doing ranking in a separate system and we would trigger the ranking maybe once in five minutes or something. So we have that flexibility here because we don't have to do it after every game and ranking takes a lot of time because you basically load all the players from the whole season and then re-order and then basically save the rank, right? So yeah, so the way we test this is a little tricky because we are passing messages around. So what we do is we have some mock producers and consumers just for testing and we produce these events from the mock producer and then the consumer we would assert that we got these messages. Yeah, so we basically pass the message through the whole thing and then we'll assert that the messages are received as expected, okay? Okay, thanks guys. Thanks everybody.


Welcome back to titanium man garage and if you're new to the channel feel free to subscribe and hit the bell if you want notifications So today I'm breaking out of my shell. I normally do 500s and 402 strokes Today I'm gonna be working on a 700. So this video is gonna be about How to fix your four-wheel drive and it's not working now with these 700s. There's a couple different things that can go wrong The first one they're notorious for the The shift or shifting hard when you push on the brake pedal and you shift it These will get a little sloppy a little warren out. There's a spring inside of here Sometimes that rusts and it's corroded in there So that's gonna put some wear and tear on your shift indicator.  This is actually a buddy of mine Doing them a favor and I'm helping mode so he's having issues with it shifting hard and When he turns on the key nothing lights up Nothing I got nothing So if you catch that quick enough, that's usually a ground issue and if you follow your wires up here a lot of times it's these wires will turn green on you and Your speedo won't light up If you waited too long, there's a good chance that the ground issue Could have shorted out the speedometer. So if the speedometer doesn't work It doesn't know what gear to shift into and it also Will not allow the four-wheel drive to work So I'm gonna try a couple things first sometimes you could take that shift indicator off and Move with your finger. You can't get the four-wheel drive to engage that that could tell me that That's the issue with the shift indicator unless you have a voltmeter. The next thing I'm gonna do is I'm gonna take these out Inspect them make sure it's not green corrosion in there Maybe I can get that speedo to work If I'm lucky the guy didn't ride it too much. So Maybe I'll get lucky. I'll get that thing to work Now if that doesn't work There's a shortcut under the hood and I'm gonna show you It'll bypass all your headaches and get rid of the reverse override button. So it's win-win either way you do this So I got them wires disconnected.  These are looking pretty clean. I'm gonna put a little dielectric grease on it And plug them back in. There's one other quick trick I can try is Try to put an extra grown wire on that speedo. They're good. It's a to work That doesn't work. This thing's probably shot and if that doesn't work I'll show you my little trick on how to get that four-wheel drive Shift indicator light lit up and your four-wheel drive work. So check the wires coming up here. They're good It said take the speedo cover off and disconnect the speedometer and find out what's going on. I pop the cover this thing It's pretty grainy and dirty probably needs a good cleaning probably all the connectors need to be recleaned but as I was looking I noticed Some wear right here And I was rubbing up against here And I saw broken wire check that out That goes right up to that plug where the speedometer goes so little tip If you got the same issue going on see if you can get that speedometer working first You might have Like I said, you might have like what I got going on here wires rubbed broke If you get that speedometer working The four-wheel drive will work so I'm gonna try that first and I'll let you know how it goes got all my wires soldered and taped and Guess what? Yeah, this is pretty awesome. I got power Turn the key And go flip the four by four switch and look at that four-wheel drive. I Don't see it lighting up here But I do see it lighting up here So I'm gonna jack the back end up in the air and check this bad boy out See if we got four-wheel drive.  That's pretty frickin sweet Fix the speedometer and the four-wheel drive works. So now I'm gonna show you the the quick tip If your speedo is shot, there's a way to bypass everything and get rid of that reverse override button Which I forgot to push when I wasn't going in reverse before So if your speedo isn't working you want to look for your four by four Connection this goes down to the differential Try to move that out of the way. It's got a white plug on it and there is a brown wire and A gray wire so brown is always ground on the four-wheel drive gray is usually a hot so you take a Little wire put an end on it so you can ground it somewhere And you put this end in with this ground wire, right? So I took this and I hooked it up to my my lead my new ground And it's going to the brown And what you want to do is you want to take this and you want to bolt it to a ground on the frame somewhere You can use a pre-existing screw or there's a couple holes down here You can just Put a screw in there and it'll be grounded on Now me personally I wouldn't use this type of connector because water will get in there and then you might have the same issue In a couple years, I'd probably try to solder it Do it the right way keep it clean and Wrap it up on a watertight seal So if you do it this way You will bypass the override switch So when you're in reverse you won't have to worry about that Your four-wheel drive will work if you flip your switch it'll go to two-wheel drive and four-wheel drive It's basically what you're just doing is you're turning on off the power of the four-wheel drive So all out of work And that's my little quick tip of the day I had seen this done on play with 500s the 500s have about two of these and you just Loop them together grown both together and grown it's the frame and that fixed four-wheel drive I learned something new today, and I just wanted to share it with you guys I didn't know the the 700s were like that I just always thought of the speedo shot your four-wheel drive isn't gonna work. I Was pretty stoked.  I've got plenty of players repairs and like always till next time


August 23rd, 2023, we'll go down that the day that NVIDIA single-handedly saved precious. Welcome to Access to Trader, the number one community for those who are committed to taking control of their trading in order to achieve success, profitability, and longevity. Thank you for joining us. Here's Dan Shapiro to help you find your edge, master your process, and own your future. Hey guys, good evening everybody. Welcome to another edition of the Access to Trader.com nightly update show. Hope everybody is doing well. If you are brand new to the channel, like, share, subscribe. Welcome. Welcome. Thank you very much for tuning in, spending a few minutes with us and trying to figure out what this market wants to do next. And today we'll go down August 23rd, 2023, we'll go down that the day that NVIDIA single-handedly saved Christmas. Now, before we think eating paint chips again, I'll explain in a second. So we had this really, really aggressive rally today out of nowhere, right? We'll get to the pivots in a second. Had this really aggressive rally today ahead of NVIDIA's numbers, why it was completely out of left field. If you look at the last three days, the last three days we had a big gap up, major pull, and yesterday we gave back everything we had at the opening, at the opening bell. And the whole world, again, if you watched last night's video, the whole world, or at least the financial world was watching NVIDIA on its earnings report, right? And the reason why I'm saying that this is the day August 23rd, NVIDIA single-handedly saved Christmas, let me explain. And we'll get to the numbers in a second here. So if you look at the QQQs, right, if you look at the QQQs, today we rallied back, we turned into a dead cat bounce, we traded right to the 50-day moving average. So you see that, guys? On today's big rally, we traded right to the 50-day moving average and got rejected. So it was basically like we talked about, you know, we talked about in previous videos, the last bullet that the bulls had was NVIDIA's earnings, okay? And say what you want about NVIDIA. Some people believe it's like the ultimate scam stock. They're always, you know, they're always, you know, the forefront of any new hot technology. First it was Bitcoin, then it was, now it's AI. I'm sure they did something with COVID if you have to look back. So, you know, a lot of people have a very negative opinion on this, and that's how a cold stock becomes a cult. That's exactly what happened with Tesla. Tesla's a fraud. Tesla's the best. Tesla's the worst. And now we're seeing that with NVIDIA. And the reason why it saved Christmas, and the reason why I'm saying that now is going into its earnings report, two things were either going to happen, okay? As we saw here right before the close, we already got rejected back in the 50-day. So if NVIDIA had bad numbers, we would have went right back down to the bottom of the range here. So the fact that they came out, and these are, you know, if you look at what's going on right now with NVIDIA, NVIDIA right now is surging about 9% after hours, including, that's excluding another 3%, it had prior to today's session, also an extra 212% prior into today's date. Here are the numbers, okay? 88%, they saw a revenue jump of 88% driven by, you guessed it, AI, right? And you can hear AI on their conference calls 650 times. Here's the hard numbers. NVIDIA did $2.70 versus 209 estimates, the revenues went $13.5 billion versus $11.2 billion. And additionally, they confirmed and they authorized an additional $25 billion stock repurchase or 2.1% of their market cap. And the guidance was good as well. They guided $15.7 to $16.3 billion versus $12.3 billion that was on the table. So yeah, NVIDIA did really, really well. But more important or as important is the cues on this move, on this report are surging as well. And guess what? They reclaimed back the 50-day moving average, right? And what looked like it was dismal, what looked like it was going to be the end of the world, what looked like it was going to be Christmas, it was going to be canceled, this three-day dead cab bounced. They got basically confirmed with NVIDIA's earnings. And now everything is absolutely surging after the close. And there was a lot of earnings tonight. All positives and all positives are Splunk. You can see in every group yet Splunk going crazy. You got snow, which was up and down, up and down initially is of about $7, $8. Guest jeans, for God's sake, raise your hand if you who I remember having guest jeans when it was like 14. Guest jeans surging, right? You got Autodesk surging as well. So yeah, the NASDAQ 100 is on fire. We reclaimed the 50-day moving average. This is a very, very huge day for the Bulls. And again, we don't want to now talk about what would have happened if they missed. It's not in the cards now. So it's a great job for the Bulls. Again, this whole move when we lost the 20-day moving average and we lost the 50-day moving average, we were just playing the ranges. I wasn't rooting for the market to go to zero. I trade both sides of the market. Again, like I've been saying for years and years and years, I always prefer a bull market. It's just easier, right? You could get a lot more liquidity. You have people feeling good, looking good, smelling good, food tastes better, the air fresh, the air smells better. It's just a good feeling. Everybody's much more happier. And now that we're about above the 50-day moving average, the Bulls have to hold it, right? They have to hold and they continue to build. Now the key is the longer we stay above 270, 271, the higher probability that we do rally into the fourth quarter. The key is tomorrow, right? The last thing we want to see tomorrow is a close below the 50-day moving average. We don't want that. So hopefully by the time you watch this video, because right now it's 10 minutes before five o'clock Eastern time, I believe their conference call starts at five o'clock Eastern time. Who knows where the stock is going to be right now? Right now, the stock is trading roughly at 5.10, about 9% up after hours. And as of right now, the world is in a better place. So that's that. So good job Bulls. Everything is surging. Our job for tomorrow is to try to find setups that are still relatively within the orbit, right? And when you look for tomorrow, you know, you got names, for example, like Google, right? Google potentially could take out. It's not there yet. So that's why I'm actually looking at Google for tomorrow. Google could potentially take out yearly highs. Tesla is waking up, maybe Tesla reclaims back the 20-day moving average meta. I think since I, yeah, I think meta just reclaimed the 50-day moving average already after the close. You know, you got a lot of stuff going on. So we're going to try to find value tomorrow. Let's see how the market handles its first retracement, reverse retracement trap maybe goes higher. But right now, as of right now, as of 4.53 p.m. Eastern time, we are back above the 50-day moving average, and the world is all good again. So hopefully everybody did all right during the three weeks of selling. Hope everybody everybody did all right today. And hopefully everybody will have a fruitful, peaceful, and prosperous fourth quarter now that we're back above the 50-day. And again, the whole job for the bulls don't give it back, right? That's the whole job. I don't care if it's tomorrow, the next day, do not give back the 50-day moving average. So as you can imagine, things went ballistic, right? Things went ballistic from the pivots. Here is a pivot we had earlier.  I accidentally sold it and then watched the stock go up a dollar and a half. I don't ask me how I sold it. I sold it.  And that was the pivot here. 1.3205 got rejected three times. Stock went to like 3340s. It needs to confirm above, it needs to confirm above the yearly highest, obviously get this thing going. Here is where the bulls woke up this morning. $367. $367.15 needs to put in a new base on the Q's. As you can imagine, the Q's right now at $373. But a nice move on the Q's traded all the way up to $370 and change. And again, nice move on Tesla here as well. $3720s rejected three times in the 60-minute. Ran up about $239, a little cash flow in the afternoon. But here's where the after-hours session got very, very explosive. And that's kind of where we are now. For all you guys who are playing earnings after hours, $482 needs to confirm. We're at $510, right? And here was the big one on the Q's. Here was the big one on the Q's. $170.5, $171 reclaims the 50-day in case the market is good. Q's right now are trading roughly around $373. So for all you guys who traded after hours, great job. Again, let's see how the market plays out tomorrow. There's gonna be a lot of noise. There's gonna be a lot of emotion. There's gonna be a lot of testosterone, estrogen and everything else in between. Don't want to leave anybody out. Stop politically correct. So the most important part is come in with a level head tomorrow. I know some of you guys are long in the video. Congratulations. But again, the key is take a breath, right? Like we do every single day. Take a deep breath. Make sure that you are looking at the market from a rational point of view. If this is going to be the fire starter that confirmed a 50-day moving average, you don't need to rush. If we're the longer we build above, the higher probability we continue to move in that direction. So believe me, your day will not be over tomorrow if you don't have 38 positions on by 931. I promise you. So stay calm. Have a level head.  Let's see how the market opens up its opening range, its highs, and then we'll see where we are after the 10 o'clock confirmation. Guys, God bless. Great job, Bulls. Just a reminder, there is no video tomorrow night. It is my normal Thursday night off. But with God's help, I'll see the rest of you guys on the weekend video. Have a great night, everybody. Take care.


There was a person named Sid Saxon, right? Who is the person who designed the game Acquire, which you may have heard of. He was a famous legendary figure in the gaming world. I think we mentioned him on Geek Nights when his massive lifelong game collection was broken up and sold. 18,000 individual games in this collection. Yeah, and all of his papers collected, were put into the Strong Museum, right? So if you have your papers put in a museum, you know that you are a significant figure in whatever field your field is. His field was games. This was the guy, Sid Saxon was like his old dude. He was just all in on games his whole life, right? He would write books about games and, you know- I wanna point out, he was born in 1920. His most famous game is probably Acquire. That was published in 1964. So, he was older than us when he published his first like super notable game, like the one that if you didn't know Acquire was from the 60s and we just got a modern copy of it and brought it to the table, you would probably assume it was made more recently than 1964. It's a solid game.  If you buy one of the Sid Saxon books, it's like it's just page after page and like every couple pages has another game. They're all games, most of them are just using like standard pieces. Like, you know, here's another game you can play with a deck of cards.    Yup. But anyway, we played two of his games that we had not played previously, even though the first of which is like a game that like everyone's played and that game is Can't Stop. Which I had actually, while I was aware of it, I had never played it until... Right, I knew of it for many, many years. I just hadn't played it actually, for reals. I knew how to play it. And basically Can't Stop is almost the purest form of Push Your Luck game there is. That's all there is to it, right? It's first is Push Your Luck. Yeah, and the thing about Can't Stop that separates it for I think from the other Push Your Luck games is that in other Push Your Luck games, there's like this steady sort of reduction of the odds, right? When you can feel yourself getting squeezed and you're like, okay, I got like 100% chance to still be in. I got a 90% chance to still be in. I got a 50% chance to still be in. All right, I got a less than 50 and I'm out, right?  And now that same thing still holds true and Can't Stop. But in Can't Stop, the odds never really squeeze you so tightly. Oh, it was notable, both me and Scott, despite being, I would say, very good at statistical heuristics in games like this, we pushed our luck to failure way more often than anyone would expect either of us to. But I felt good about those decisions, which means this game has got something going on. Right, it's like it never squeezes you so tightly, numbers-wise, that you feel like you're gonna lose, you have to stop now, right? And the way it works is you roll what, 46, right? Yeah, small number dice, yeah, 46. You roll 46 and you can combine them any which way into two sets of two dice each, right? So if you're rolling 46, it's like, you know, what are the odds that a seven is gonna be in there somewhere among two dice? Really, it feels, I've never done the math, that feels like you can't miss, right? Yeah, you know what else it feels like that? Craps tables. Of course, it's like, but you know what? What are the odds of four ones coming up? It could happen. What are the odds of four sixes coming up? It can happen, right? It's like you're not gonna get, it's not, nothing is guaranteed. But to make it feel even better, it's not two independent 2D6s, it's 4D6 because the next step of the game is you look at the four numbers you rolled and you arrange them into an arbitrary combination of 2, 2D6. Yeah, it's any which way, right? So you're like, you feel like even when, you know, you need a particular, you just need like to hit one of the numbers, right? Of that are possible between two and 12. It's like, I just need to hit one of these numbers between two and 12.  And I think that's feels like, yeah, my chances are good. I'm going for it. I'm going, you can't stop, right? You had to, you feel like you're gonna make it.  And I feel like that is the brilliant of this game. We didn't even get into the specific mechanics, but the brilliance is, you are more likely to be fine than get fucked most of the time. But what that causes is this let it ride feeling where I got an 80% chance. That's fine. 80% chance. That's fine. And yeah, 80% chance is fine. As long as you, as soon as you try eight times, it's like, you're gonna miss one of those times. Can you really, right? It's like, it's gonna, you know. Even if you only try five times, it's like, okay, one of them is gonna miss. You've already tried, you've already got four in a row. You really want to try the fifth time on the 80% chance. So mechanically, like the specifics, the way this works is you've got this big pattern. I gotta, if you're on the live stream, I got a board up you can look at. But basically- It's just a racetrack. Yep, just a racetrack, but there's a, it's a square, but you're approaching it diagonally. So you're trying to get all your pips all the way to the end. So if I roll two sevens, I can move a pip up to on the seven track. The seven tracks in the center, corner to corner, it's the longest path. But, so I gotta get one- It's easy to get numbers or have a long path, right?  Or at the very edges, if I just roll two three times, I get to the end of the two track. And if- Right, now it's like, two is pretty hard, you need to get two ones, but it's like two ones on four D six. It's like, hmm. Yeah, it's a hmm. It's not a, like calculate the strict odds in your head situation.  Yeah. But on four D six, it's like, I'll eventually make it three times, right? Feels good to like, advance that if it comes up because that's a nice safety. Yeah. But, so even if you got something on seven, you gotta keep rolling seven. Once you've got all your pips moving on the board. Right, you have three pips. So you eventually assign your pips to three different numbers on the board. And once they're all out there, right? If they're not out there yet, you can sort of assign them to any number that you've rolled and put together from two D six out of your four. But once all three of your pips are out there, let's say I got it on seven, eight and 10, right? I roll my four D six among the four dice, I have to put together at least one seven or one eight or one 10 and advance one of my pips at least one space. If I can't, with any combination of the dice, make a seven and eight or a 10 and I can't move any of my pips, I bust it. And all my pips gotta go back to where they started before I started my turn. But that's the key. If you stop, but you don't wanna stop. If you have the guts to stop, then they lot that it's like a save point. They can't, wherever they are, they're set and they can't be pushed any further back and you can make some progress. I gotta tell you, locking in a good run is really, really, really powerful. But even me and Scott, you look at it, you've rolled 11 times in a row when things are going great and you got something on seven so you know you're safe. You just look at it. How can I not get a seven? I'll just keep going till I win the whole seven track. Yeah, good job. I think I busted back to zero like four times in a row and I consider myself a smart person. So I think that this is a model that some other push your luck games should try is don't squeeze, keep all the rest of your game is just fine. There's a lot of good push your luck games out there. Like, we like to play no thanks, right? We put the tokens on the card, right? That game's all about the squeeze. Eventually the card has so many tokens on it, you're like, of course I'm just gonna take the card, right? But imagine if no thanks, never squeezed hard enough and it's like, you just always like didn't wanna take the card even when there was a mountain of tokens, you know? And you just kept pushing it. I don't know. It would be more exciting. And that's the game's so simple like poking around in board game geek. People just make this game by drawing it or printing it on a piece of paper. Yeah, all you need is four, all you need is four D six and a piece of paper, right? And some number of objects to put on this piece of paper. You really, yeah. I mean, like I said, you know, but what's the rating on board game geek, I think? Oh, let me, let's go back to can't stop. Oh, it's low. People don't, people don't like it. Oh, wouldn't like this game. This game, you talk about fun economy. This game. I give board game geek gives can't stop from 1980, a 6.9. I give it like a nine. I was gonna say nine as well because this game, unless you're playing with an intolerable spiders York type person, this game takes maybe 15 minutes to play and it feels real good the entire time. Yeah. Like this game is so fun for how simple it is. It takes so little time to teach this game. So, yeah, play this game. There's no reason not to play this game. It would be an A plus omega thon game that packs unplugged like S here. Oh yeah.