Hey what's up everyone welcome to another video my name is Dylan and I'm a cycling coach at CTS and today we're going to be talking about whether or not going vegan could improve your cycling performance. This video is going to be chocked full of science going over performance, weight loss, recovery, and whether or not protein and other nutrient deficiencies are a concern on a vegan diet. At the end of the video I'll talk about my own experience with veganism so be sure to stick around for that. If you're new to this channel I make weekly training, racing, and gear related videos going over tips and tricks that I've learned in my 12 years of racing and training experience that have gotten me to the top of the ultra endurance mountain bike game in the US and as a cycling coach at CTS. If you want to learn how to get faster or just more about the science of training in general then be sure to subscribe and if you have a training question or a topic you'd like to see me cover in a future video be sure to leave it down in the comment section below. I do my best to get to all the questions in the comments. People have many different reasons for going vegan ranging from ethical to environmental to personal health but in this video we're going to gloss over that because today we're going to be talking about how going vegan will affect your cycling performance. I will touch a little bit on the health side of veganism but only as it pertains to your cycling performance. Now the first question we need to ask is can you even be a high-level athlete on a vegan diet or will you constantly be struggling to meet your nutritional needs and therefore experience a decrease in performance? The position of the academy of nutrition and dietetics on vegetarian and vegan diets states that appropriately planned vegetarian including vegan diets are helpful nutritionally adequate and may provide health benefits for prevention and treatment of certain diseases. These diets are appropriate for all stages of the life cycle including pregnancy, lactation, infancy, childhood, adolescence, older adulthood and for athletes. Sure a vegan diet may be adequate for athletes but is it optimal? Adequate? Bro I'm the four-time Tuesday night ride stop sign sprint champion in the C group adequate is not going to cut it. Can you perform just as well on a vegan diet or better yet can you improve your performance? One study testing the difference in maximal oxygen uptake between subjects on a traditional or vegetarian diet had subjects perform a treadmill test on their normal diet and then tested again after four days of not eating meat. They found no significant difference in maximal oxygen uptake but the vegetarians did show superior time to exhaustion. However the study admits that there may be confounding factors like test familiarity or carbohydrate loading. This makes it hard to draw any clear conclusion from a study like this. Another study assessing the fitness of vegetarian and omnivorous athletes took 27 vegetarians and 43 omnivorous athletes and tested VO2 max strength using a dynamometer. The results showed that the vegetarians had greater cardio respiratory fitness however strength was not different between the groups. However again this could be because of confounding factors like the fact that the physical activity level was 20 percent higher for the vegetarians. Looking at many studies the performance gains from not eating meat or other animal products seems to be less clear. A review article on physical fitness and vegetarian diets stated that the available evidence supports neither a beneficial nor detrimental effect of a vegetarian diet on physical performance capacity. For those concerned with deficiency on a plant-based diet it is important to note that there is no convincing evidence that vegetarian athletes suffer impaired nutrient status. So it seems like a wash. If you enjoy eating meat it doesn't seem like it'll affect your performance. But what if we're not taking into account the whole picture here? For starters these studies I just mentioned looked at vegetarians. What could the effects of going fully plant-based be? And second what about the potential long-term effects of a diet influencing performance as we age? A vegan diet has been shown to have clear benefits to cardiovascular health even going as far as reversing heart disease. In this particular trial those who adhered the most to a plant-based diet saw regressions in their arterial plaque. In this study on how to reverse coronary artery disease 198 CAD patients were counseled on plant-based nutrition. Of those 198, 177 actually stuck to a plant-based diet. Of these subjects 0.6 percent experienced adverse cardiovascular events and of the patients that didn't adhere to the diet 62 percent had cardiovascular events like a heart attack or stroke. That's a 100-fold difference. It doesn't get more clear than that.  What does this have to do with me getting faster and finally taking that KOM on the bike path? Your cardiovascular system not only keeps you alive but is also the main limiting factor in aerobic sports like cycling. It stands to reason that a healthy cardiovascular system would equal increased performance especially as we age and our arteries slowly start to clog. A study on plant-based diets for cardiovascular safety and performance in endurance sports stated that surprisingly endurance athletes may have more advanced atherosclerosis and more myocardial damage compared with sedentary individuals particularly as they age. However plant-based diets address key contributors to atherosclerosis. Dislipidemia, elevated blood pressure, elevated body weight and diabetes. It's also worth noting that a key factor in oxygen delivery to the muscles is blood viscosity and individuals excluding meat entirely had significantly lower blood viscosity than those who ate meat occasionally. Reduced blood viscosity also improves tissue oxygenation potentially improving athletic performance. So potentially as we age a vegan diet may keep our cardiovascular system healthier leading to better performance. On top of that a vegan diet does have peripheral benefits such as weight loss. In a study on diet and weight loss with almost 38,000 subjects meat eaters had the highest BMI and vegetarians and pescatarians were lower but then vegans had significantly lower BMI. In this study on a whole food plant-based diet for the treatment of obesity heart disease and diabetes they took obese and overweight subjects and put them on a whole food plant-based diet. They concluded that to the best of our knowledge this research has achieved greater weight loss at 6 and 12 months than any other trial that does not limit energy intake or mandate regular exercise. This shouldn't come as too much of a surprise because a lot of what vegans eat is lower in calorie density meaning for the same amount of food you're getting less calories. As we can see from this calorie density graph cutting out animal products means cutting out foods that are higher in calorie density and the calorie density method to losing weight has a lot of science to back up its effectiveness. A systematic review on dietary energy density and body weight looking at many studies concluded that their findings highlight the growing body of scientific evidence suggesting a relationship between energy density and body weight and that consuming diets low in energy density may be an effective strategy for managing body weight. I made a whole video on losing weight by lowering the calorie density of your diet and I'll link that in the description below if you're interested. Another potential benefit of a vegan diet is improved recovery by reducing oxidative stress. Whole plant foods are high in antioxidants which reduce oxidative stress. A study on lemon juice and exercise-induced oxidative stress concluded that the lemon did not block the cellular adaptive response but also reduced cellular oxidative damage. Cherry juice has been shown to increase antioxidant capacity after a marathon leading to aided recovery and in another study reduced symptoms of exercise-induced muscle damage. That study showed that strength loss after eccentric exercise was 22% with a placebo but only 4% when subjects consume cherry juice. Blueberries are another rich source of antioxidants and have been shown to reduce inflammation after two and a half hours of running and similar results have been found with tomato juice. If most of what you're eating consists of these high antioxidant plant foods you better believe that you're getting a boost in recovery. Going back to the study on plant-based diets for endurance athletes they stated that compared with omnivores people following vegan and vegetarian diets have increased antioxidant activity due to their higher intakes of vitamin C, vitamin E, beta-carotene, and other antioxidants. Now it's important to note here that you don't have to be vegan to consume high antioxidant fruits and vegetables and on the same note just because you're a vegan doesn't mean you're actually consuming these foods either. Yeah man I just went vegan but you know I'm not really a big fan of vegetables so I've been sticking mostly to potato chips and fake meat. More on that in a bit. Alright let's touch on the topic of protein. This is one of the biggest concerns when going vegan. After all don't you need protein to recover? The studies that I mentioned earlier in this video talking about vegan athletes did address this topic. One stated that although there has been some concern about protein intake for vegetarian athletes data indicates that all essential and non-essential amino acids can be supplied by plant food sources alone as long as a variety of foods is consumed and another stated that while protein adequacy is a frequently raised question surveys show that virtually all endurance athletes meet recommended protein intakes and a varied diet of plant foods easily provides adequate amounts of all essential amino acids for athletes. From this review article on fueling a vegan athlete they stated that supplemental protein is an option but not needed for most athletes who carefully construct their diet paying attention to higher protein plant foods. Alright that was a lot of information so let's break down the important bits. First will you see a noticeable difference in performance after going vegan? Probably not especially if your diet already consists of high amounts of whole plant foods. However in the long term the cardio respiratory benefits of a vegan diet may lead to better performance and protect you from adverse cardiovascular events that you may be putting yourself at increased risk for by being an endurance athlete. Vegans do tend to be lighter than their omnivore counterparts so if weight loss is a struggle for you this may be worth trying. Vegans also tend to have higher antioxidant levels which has been shown to aid in recovery. Protein isn't an issue on a vegan diet as long as you're eating a variety of unprocessed plant foods. Now an important point to make here is that even though vegans do tend to be healthier veganism isn't synonymous with health. You could eat nothing but french fries and coca-cola and technically be a vegan. Wait so you're saying that dairy-free ice cream isn't healthy just because it's vegan? What's important is that your diet consists primarily of whole plant foods and this goes for whether you follow a vegan diet or not. From the article on how to fuel a vegan athlete to maximize performance recovery endurance and resistance to illness enhance intake of beans grains seeds nuts whole grains and other colorful plant products are recommended. These same suggestions are also important for non-vegan athletes and omnivorous diet that is 90% whole plant foods with small portions of meat is vastly better than a junk food vegan diet. One doesn't have to be fully vegan to experience some of the benefits I mentioned in this video but if there's one thing that we can learn from vegans and the studies done on them it's this. The more we center our diet around whole plant foods the better. Your recovery will improve your weight will likely go down and you'll be overall healthier. I myself have been vegan for coming up on four years now and in the beginning I did it mainly to find a performance edge. Did I see a noticeable difference in performance after I went vegan? I can't say that I did probably because my diet already consisted of high amounts of whole plant foods. I've always been a healthy eater. I stayed vegan though because of the long list of reasons to go vegan and because I'd gotten used to it and I preferred it. Hey man it's not a diet it's a lifestyle okay. If you've seen my videos you know the amount of research that I put into training for cycling. I don't just accept something to be true because my buddy told me or because everyone else does it. I research and come to my own conclusion based on evidence. I would say that just as much research went into my decision to go vegan.  That must have been pretty hard considering as well you know you're a vegan. Thanks for watching and I hope you guys found this information helpful. Have you ever tried going on a vegetarian or vegan diet? What was your experience? Let me know down in the comments section below. If you like this video be sure to give it a like, share with a friend, and subscribe. If you want to see more training and racing content be sure to follow me on Instagram, Twitter, and Facebook. If you want to check out my training be sure to follow me on Strava. And finally if you're looking for a coach shoot me an email at djohnsonatrainright.com


That's sick Good luck everybody. Good luck everybody on the Sinatra 101. Oh my god. Oh Man, that's I can't believe I'm holding When once I'm done showing it you got it you got to hold it as well Joe just to say you can hold this Sinatra


Last session of WordCamp Toronto 2018. Guaranteed. This is Fast and Furious. My name is Doug Shepherd. Before I start, first, I'd like to thank the organizers of WordCamp Toronto putting on an event. Even one that's just one day is a lot of work and there's a lot of unexpected surprises and they have done such a great job handling all of them. And I'd like to thank our sponsors because without them, we would not have pop, we would not have snacks, we would probably not have an event at all. And there isn't a slide for it, but I would also like to thank the volunteers because without them, there also is no event. So the next time you see a volunteer, give them a high five. So, away we go. Who am I and why am I here? Well, as I said, my name is Doug Shepherd. I am a full stack developer. I've been using, for most of my life, the various P languages. PHP, Python, Perl and JavaScript. I have, in fact, been coding for money since 1983 when a classmate asked me to write a baseball card catalog for him on his Commodore VIC-20.  These days, I do full stack development at a company here in Toronto called Biblio Commons. We do software as a service for public libraries in Canada, the US, Australia and New Zealand. I'm part of a team that works on the Biblio web product, which is a WordPress-based CMS. And today, I'm going to be talking about these four items. Object caching, WordPress transients, Redis, and the Redis Object Cache plugin, and that time that everything just sort of fell over. So first, what is a cache? We all know what a cache is. It's a thing you clear while you're debugging. But what is a cache? What it is is just a way of storing results from work that you've done so that you don't have to do the work again. It might be stuff that's frequently accessed, or it might be stuff that's very slow to generate. It's a way of trading space for time. And why do we need to trade space for time?  Hard drives are slow. Even solid-state drives are slow compared to RAM. Networks are slow compared to RAM. Humans are the worst. So it makes everything that isn't RAM slow by comparison. What we do is we use RAM, and admittedly, we're still going to be using networks because we need to get the information from point A to point B, and there's still going to be humans involved, but that's for another presentation. So what do you cache? Well, for the purposes of this talk, we're going to be talking about, for example, database queries because some queries are extremely slow and they don't update very often. Some queries, we may be fast, but we use them all the time, multiple times in displaying even one page. And since a cache that is only half full is a cache that is half wasted, we also cache anything else that we actually have space left for. Another great thing to cache, external network requests. The Biblio Web product talks to internal Biblio common services for things like staff lists from libraries. It talks to third-party services like syndetics for book cover images. And these requests are usually quite fast. But remember, compared to RAM, everything is slow. This is quick, but it is never quick enough, especially if that network request will block page render. So why wouldn't you cache? I think that you need some reasons not to. And the first one, remember, cache is trade space for time. If you're space constrained, then a cache is not going to help you. The worst possible case will be that your cache server doesn't have enough RAM, your physical box doesn't have enough DDR4 in it, and it starts to swap. And now you have the worst of both worlds. You have all the benefits of that slow, slow disk, and the RAM is not as useful as it could be. If your database isn't under high load, caching may not make much of a difference. It won't hurt, but it won't help so much. And finally, things that change all the time. You don't want to put them in cache because they're changing all the time. You would not, for example, cache the current time of day because that changes literally every second. It makes no point to cache it. You're just going to get it when you need it at that second. So how does WordPress implement cache? WordPress cache is just a key value pair store. The keys are strings, and the values are just PHP objects. Anything that can be serialized can be put in as a cache value. The API will take care of serializing and un-serializing for you. You don't have to JSON encode it. You don't have to call serialize or anything like that. You just throw it in an object, and it will throw you back that object. The first function that you use with the API is wpCacheSet. You pass it the key name, the data you want to put into it, an optional group name, and an optional expiration. The group is so that you can reuse the same key in multiple contexts. Instead of having to artificially manufacture keys called userEmailOne, customerEmailOne, just put one set in the user group and the other in the customer group, what have you. The expiration time is measured in seconds, and that's when this key will go away. If you don't pass an expiration time, it just means cache this forever, for as long as you possibly can. There's also wpCacheAdd, which does the same thing, but only if the key isn't already there. There's also another function wpCacheReplace that will only set if the key already exists.  Then to get the key, to get your data, you use wpCacheGet. Key, group, force, reference to found. The key and group we already know. Force, we don't care about in this context. Found is a reference because wpCacheGet will return the value of the key or false if the key doesn't exist in the cache or false if the key exists in the cache, but you set it to the value false. If that matters to you, then you need to pass that reference to found and triple equals false that to see if that matters. Deleting a key on your own instead of letting it expire, you use wpCacheDelete. It will return true if the key existed and now is gone. It will return false if the key never existed. Therefore, it's already gone. Either way, the key is gone. We use all these in what is called the getSetPattern. What you want to do is first, when you want to look up something, check if it's already in the cache. If it is, use it. If it's not, calculate it. Then set it in the cache, then use that value. That way, it will be in cache for the next request. It looks something like this. For example, this is one way that you might implement staff lists for a library. We want to store our lists in a cache key called lists in the lib group. We wbcache get. If lists triple equals false, I don't care about the false thing here because I know I'm never going to put false in there. If it's false, then it doesn't exist. So do the slow network request to retrieve the staff lists. Then set the key. And now it is there for the next time. One thing that is kind of a problem, and is going to be the next two thirds of this talk, is that the default WordPress cache is just an array. It is just an array. So the moment your page finishes rendering, it goes away. Poof, it's gone. It's still kind of useful because there's a lot of things you refer to multiple times in the course of a page. But it's not as useful as it could be. One way to fix this is transients. Transients are a special type of cache item. They always persist even if you haven't set up a separate object cache plugin. By default, they get stored in the options table for the blog. Do you do that? They're great for short-term persistent storage, like maintaining data across page loads instead of sticking it into hidden HTML fields that you have to parse that an attacker can manipulate and all that sort of thing. And best of all, since all of you are running WordPress 4.8 or later, they clean up after themselves. It used to be that you would have to install a special transient cleaner plugin or a cron job or whatever that would occasionally sweep out expired transient. Now it just happens when a transient is looked for. It just does the house cleaning for you. How do they work? They're really, really similar to the object cache API. Set transient, get transient, delete transient. They don't have groups. They just have key names. If you want to do network-wide storage, there's a similar set of functions. Get site transient, delete site transient, and so forth. One difference is that the key length for a transient is 172 characters because it's an option. And options.optionName is a varchar191 in MySQL. So end of transient is stored by prepending its name with underscore transient underscore and the expiration it might have with underscore transient underscore timeout underscore. 191 minus the length of transient timeout is 172. And that is how you accidentally build dependencies between your database and your cache layer. So this is what it looks like. So what I have here, the first thing I want to do, I want to get featured item and set a transient that will stay around as long as possible in the key feature. Or you can give it an expiration period, featured item, get featured item, set transient feature, featured item, day in seconds. This is a constant that WordPress gives you so you don't have to multiply 24 times 60 times 60. You also have hour in seconds, week in seconds, month in seconds, year in seconds. Always use these because it's much easier to think just read day in seconds and think, oh, this is a day measured in seconds. Then to look at 24 times 60 times 60 and remember why you're doing some math. Get transient right here. Again, very similar. And delete transient to delete a transient, whether or not it's about to expire. And you use the same get set pattern here that we did with WP cache get WP cache set. If you remember one slide, this is it. Transients, when you give them an expiration, they have a maximum lifetime. They don't have a minimum lifetime. Don't treat them like they do. The API guarantees that at time X, your transient with an expiration at time X is gone. It guarantees nothing at all about any time before X. So I am about to show you an excerpt from the world's most technically compliant cache. There is nothing about this that is a lie. The transient API doesn't promise a minimum lifetime. If you write something that throws away the value, the moment it gets it, that just assumes that every value doesn't exist, that's fine. That is perfectly acceptable. Transients don't have to exist. They just have to go away when you told them to. So now let's talk about Redis. We have reasons that we've seen for using external cache. First, object persistence. We want objects that continue to exist even after the page finishes loading. And we don't want to keep everything in transients because by default transients are stored in the options table. You set 5,000 transients. You have 5,000 users. You have one transient, indeed. Congratulations. You now have somewhere between 5,000 and 10,000 extra rows in the options table, just for that. There is, for database queries, MySQL's internal cache, which is okay, but we don't want to depend on MySQL being fast because every query is a chance to hit the disk, disk slow, and every query has the potential to be computationally intensive. Computationally intensive is slow. At Biblio Commons, out of the options that are available to us, we are using an external cache server called Redis. It runs just a giant pool of RAM that you can pour stuff into. You run it on the same box as Apache or on another box. It is extremely fast. Just on this thing, which is not a server, it's just a standard little Mac book. I can do 50,000 operations a second on the benchmark. Redis is also super highly reliable. That is the website, redis.io. Yes. Compared to MySQL, this thing benchmarks about 8,000 ops per second on MySQL. On an actual server, you can get up like 250k or so. It was properly provisioned with Redis. To install it, I'm not going to walk through the whole thing because you all have different ways of installing things. You can compile it from source. You can use your package manager, apt-get or yum or port install or whatever to get it from your operating system. Or you can do what we do is use Docker Hub because we run all of our services as Docker containers. That right there, help.doctor.com slash underscore slash redis is where you can get a Redis container pre-built for you. Redis is again another key value pair, except the key can be up to 512 megabytes and the value can be up to 512 megabytes of binary safe strings. For example, you can store an image as a value. If you want to build some sort of image caching server, just store the raw image. You could even use the image as a key. Redis doesn't have namespaces, but the tradition is just to fake them by using paths separated by colon. So two colon, user meta, colon, email. This is blog number two, user meta table, email. That sort of thing. Redis also, of course, lets you expire keys. All keys are given in expiration in seconds and they just go away magically at the right time. And by default, every other key, anything that doesn't have an expiration is kept around forever. This is fine because memory is infinite and never runs out. Let's try that again. This is not fine because memory can run out. What you can do instead is tell Redis how much space you wanted to use. 32-bit, if you're running on a 30-bit system, it's limited to 4 gigs. If you're running on a 64-bit system, it's limited to practically no limits because it's 64-bit. And then when you start running low on storage, Redis will start evicting keys, deleting them even though they're not right now due to expire or due to expire at all. There's a setting called maximum memory policy that tells Redis what to evict. And you have two decisions to make there. What type of key do you want to evict and what subset of those keys do you want to evict? For what type of key? All keys versus volatile. The key is volatile if it has an expiration. All keys is all keys. And then the strategy it can use, random or LRU or TTL. It can just pick keys randomly. Like all keys randomly will pick just from the entire name space. Or you can delete the key that is least recently used. It's the oldest one that hasn't been touched. It's probably not that useful anymore. Get rid of it. Or you can go with the one that has the shortest time to live, the shortest expiration, the next earliest expiration time. Because it's going to go away anyway in two seconds. Let's just get rid of it now. If it needs to exist again, we will be able to bring it back. For recent reads? Yes. So it actually tracks reads? Yeah. Yeah, timestamps is the most recent read on each key. Yeah. What we do is volatile LRU. Keys that have an expiration that have the least recently used timestamp. We also in our plugin set every key to expire in day and seconds, just in case as kind of a belt and suspenders thing. All keys least recently used will work fine and ignore that last bullet point. So Redis, I mean, so now we're going to do a third version of the same dance. I just want to make sure that you see that this really, that these cash services really do have a pattern. So the Redis server exposes a command line interface. The command is called Redis CLI. And here's an example of its usage. Redis CLI minus H, our host name, minus A, the password you set on the Redis server, and then a command. Or if you run it without a command, it will just pop up an interactive prompt for you. The same one that you get when you run PHP minus A. How many of you knew the PHP minus A does a thing? Give it a shot. So let's just do a quick little walk through the commands. Set key value, similar to the key cache set. The key and value are both strings. They need to be quoted if they contain white space. It just is the standard command line parsing. Set X key expiration time value. The expiration time is in seconds, just like in WordPress. You can also add an expiration to an existing key with a command called expire. Set X is just a convenient shorthand for it. Get key, TTL key, time to live. It tells you the number of seconds until a key goes away. Or it returns minus one if the key will never go away because it has no expiration time or minus two if the key doesn't exist. And then there's, this is actually somewhat really useful. Inker and Decker takes the value of the key and increases it or decreases it by one. Except what it really does is, Redis doesn't really have any internal number data type. So it takes a key, which is a string, interprets it as a number, adds one to that number and stores the string. You don't care about this, but this is a great way to impress people at really lame parties. And finally, keys and a pattern will return a list of all the key names that match the pattern. It just uses normal regular expression syntax. You can do keys star. It works, but it's not a great idea, especially on a huge production system. If you need to do something like that, then there is a set of commands based around the scan command, which I'm not going to get into right now. Now, so we have our Redis process up and running. And this is better than the WordPress cache, which is just an array that goes away at the end of page load. And as far as the transients, which are rows in your option table, but it's still not actually that much better because we also need to persist to disk. Because if we don't, then the moment our Redis server goes down, we have lost our entire cache. So we need some way of saving. And there's two formats that Redis uses. The simple one is called RDB. It's just a binary dump of the contents of the entire cache to a file. And the second one is called AOF, which is not as simple, but it's still really simple. It stands for append only file. It is a list of every command the Redis has received since the server started up. If you save that to a file and then you start up the server again and read and do every command from that file, then by definition you will have recreated the exact state of the cache at the time you save the file. There's commands save and bg save for RDB files. Save will block incoming server connections, so you don't want to use that almost certainly. You want to use bg save, which will fork a child process which performs a save. You might want to do this overnight. The thing about this, it's a binary dump, so if it gets really scrambled, it might be unrecoverable. AOF, it just saves every x seconds by default, just automatically does it. It also can do a save after some percentage of your cache has changed, so that even if it hasn't been 60 seconds yet, but half the cache is different, you definitely want to save that. It just happens in the background automatically. And because it's just a log of commands, if this gets screwed up, you still have everything in the cache right up to the point where the disk failed. And every command after that is lost, but you still have your first part. So which do you use? AOF is general persistence and short-term recovery. RDB is backup. A lot of people use AOF only. We, in fact, use AOF only because it has been remarkably robust for us, and since we're using it as a cache, we're not going to have any data loss, even if Redis goes away. We're just going to have to give back all that time we traded away for space. Things will get slow for a while. There's a whole bunch of other stuff, by the way, that Redis does. It's got all sorts of other data types with lists and sets and hashes. There's a lot more commands that you can use with it, and if those commands aren't enough, it even has a built-in Lua interpreter so you can write your own Redis commands that run internally on the server. I'm not going to talk about those right now because we're not using them yet, but they're available for you. Now, I just said what happens when our Redis server goes down is that everything just gets slow, but let's say that you care about keeping things up. Remember that I called Redis highly reliable, which is a code word for fails. Not very often, but often enough. You need to turn highly reliable and sometimes fails into never fails, and the way you do that is multiple instances of Redis. Run one Redis server that has a master, and another Redis server that has a replication server. All it does is listens to changes that come in from the master server and stores them. If the master crashes, then your replication server can just fall into place and take over. Just remember that never fails is also a code word. Never fails means if you don't do something dumb, like run both of your Redis servers on the same box so that taking that one box down kills both of them, then it never fails. Be sure to do that. What would cause Redis failure? Use our error, which will come up. Your server hardware fails. You have a hard drive crash, or a raccoon eats a fiber at your colo. We live in Toronto. You know that either this has already happened, or it will happen and be on BlogTO tomorrow. What you use for this is a package called Redis Sentinel. This does monitoring and failover. I'm going to be very brief about this. You can look it up yourself. It's not too complex. Basically, you set up your two Redis servers, one master and one to replicate, and you set up three instances of the Redis Sentinel, ideally in a fault tolerant way so that they're on three different boxes. Your client no longer connects to the Redis server. That minus H argument from the Redis CLI command earlier. You connect to a Sentinel, and the Sentinel will tell you what server to connect to. In the background, as far as you know, as a user, everything will just continue to work. You need three Sentinels, by the way, because if you only have one, you don't have high availability anymore. If you have two and they lose their connection, then things will get confused, or one can die and now you're back to, and you're back to the low availability situation. With three or more, you're guaranteed to have a quorum. It never fails. So we've done a deep dive into a whole bunch of stuff running on another box. We have Sentinels and all that. Let's get back to WordPress. How can we use this? And the answer is plug-ins and drop-ins. Drop-ins are the other WordPress extension mechanisms, the one that you may not have heard of. All sorts of functions in the WordPress core are able to be overridden by you. Core functions like the Cache API, for example. WordPress will look for a drop-in that may contain definitions of all the functions in that API, and then it will fall back to setting up these functions if they haven't already been defined. The file that is the Object Cache drop-in is, of course, Object Cache.php. It'll just be in the root of your site. So we use a plugin called Redis Object Cache. This is its URL. It is really well supported. The last time it checked, the last change to it had been two days earlier. It is actively maintained. And it works with Redis servers and Sentinels and Redis clusters. To set it up, you network install it. Just install it on your site if you're not running a network. Network install it if you have more than one blog going. And in your WP config, you set up these constants, the Redis host, port, password, if you've got a password on the server, maxTTL, which will be the time to live that will be given to every key where you don't set one. Like I said, we use day and seconds by default. And if you're using Sentinel and replication and all that, Sentinel and servers. Then you just activate the plugin, go to its control panel and tap enable. And now it's going. It will cache nearly everything for you. It will cache most tables in your WordPress instance. Users, posts, psych meta, options, and transients will go from using the options table to using Redis automatically instead. There's a few tables that it ignores like plugins, for example, because you have a chicken and egg situation. How do you know if the Redis plugin is installed if you can't get to the plugins table because it's on the Redis server that has gone down? Also, remember, options.optionName is varchar191, and the Redis key is 512 megabytes. That 172 I mentioned earlier, that no longer applies. So what does it do? Why does it work? It's a get set pattern. The thing that I showed you before with the cache API and with the transient API, WordPress internally uses it all the time. Every chance WordPress has to avoid using the database, it takes. And this is slide number two that is important. This is the other thing that will bite you. It has bitten me. So I'm giving you the warning that it will bite you. WordPress prefers cache over database, fast over slow. So if you want to make database changes, it can no longer just cowboy into a MySQL prompt and do a select insert update there. Because if you do that, Redis won't see it. And if Redis doesn't see it, your site won't see it. You will be serving whatever was in the cache, whatever was in the cache at the time you did the changes. WPCLI, the WordPress command line, gives you a whole bunch of cool ways to update your database that are guaranteed to also update the cache as well. Really look right into it. Now, Gutenberg. Here's the thing. You know that this has been a heavily Gutenberg-oriented WordCamp. And a lot of stuff that I've talked about doesn't seem to really apply, or does it? First, what you know, if you've seen some discussion of the internals Gutenberg, is that what it stores, it stores block directives as HTML comments in your posts. Posts are stored in the post table. Metadata for those posts is stored in post meta. And Redis object cache automatically caches those tables. You don't need to do anything. You are already caching everything. This is Gutenberg ready, and has been for several years before Gutenberg even existed. So how good is it? So I took a raw WordPress image from Docker Hub, spun it up, did nothing but run WP install, and looked at the page welcoming you to the Gutenberg editor with the debug bar on. And rendering that page took 24 MySQL queries. I installed and enabled Redis object cache, reloaded the same page, and it took six queries. We have seen our MySQL load drop by about 80%, since we have started using Redis and Redis object cache. And this is what that looks like. I can read the statements on the left. None of you can, but we can all read the statements on the right. On the left, 24. On the right, 6. And how fast is it? I'm no, I'm no scientist. I barely graduated from Bovine University. But I am able to give you a rough benchmark. I added an init action to this stock WordPress site that just sets 500 random transient keys and values, then retrieves them, then deletes them. This is what it looks like if you're curious. And this is what it looks like in table form. How much time do I spend in MySQL? Either 1,890 milliseconds or 6.8. How many queries do I send to MySQL? Either 2,530 or 6. In fact, the same 6 that we just saw. And how much time does the entire request take? 2.5 seconds versus 1.14. This is inflated a little so that there is a measurable difference, but even 1% a million times over is still a lot. In fact, one thing I forgot so that you can learn from my pain. The first time I did this, like the default stock WordPress was 1,000 times faster than Redis, which made no sense. And then I remembered that I was using the default cache, which is just an array that goes away. And that's why it was 1,000 times faster and that's why I had to use transients. So now let's run through a few quick ways to monitor the server and monitor your plug-in. For this, we want to use Redis CLI. It is a definitive source of Redis truth and accessible to anyone who can tell that to that port on your server, which means you don't put it on the open internet. Don't! Just don't! If it has to be accessible over the open internet, at least set a strong password on it. We don't do that, but we do have a very... We do have a VPN that you can't access at all from the outside world and Redis is only available to servers inside that subnet. So some commands are really useful. Info memory. Info sits out a whole lot of stuff. Memory is just the memory block from it. Memory usage, key volume, expiration rate. The three interesting values there, used memory, how much memory Redis is currently using, used memory peak, the maximum instead of the reached, and your max memory policy. Persistence is about AOF enabled, which should always be enabled. AOF rewrite in progress and AOF rewrite scheduled. These will all be Booleans that are either 0 or 1 for false or true. And then you also have, I mentioned WPCLI earlier. When you install the plugin, you'll have an added command in WPCLI called WP Redis. WP Redis status from the fan line will tell you the current status of the object cache, whether it's enabled or disabled. It'll tell you the implementation detail of what Redis PHP library you happen to be using. And WP Redis enable will turn Redis object cache on, enable the caching. There's similarly a WP Redis disable. So what we do is we have a very simple daemon that runs in the server crontab. Not the WordPress cron, but the server crontab. And every five minutes, this just runs WP Redis enable. And this way, if something temporarily breaks the connection to the Redis server and the plugin sees that the connection's gone and disables itself, it'll turn itself back on in five minutes. More serious outages that actually happen to the Redis server, we get a ping from our site monitoring. Don't worry, you'll know if it goes down. Because if you're using it for permanent storage, things are gone. And even if, like us, you're using it as cache storage, you no longer have a cache and now everything is slow again. How does that happen? These are two things that actually happened to us. Learn from my pain. First, you might fill up the disk. This doesn't seem like it's very likely, but it can happen if you are using a network storage and you don't allocate enough space. Redis requires disk space to write the AOF file and to occasionally compress it and rewrite it to reduce how much space it uses. It needs space for the existing AOF and the new one that's writing alongside it. As your backlog diff grows and grows and grows, if there's a lot of activity or you're starting to run low on disk space, so does the time that it takes to keep up and rewrite it. And if it gets too far behind, it will not catch up and it will fall over. In fact, this did happen to us once. And then, if you run out of memory, because you'll remember that we carefully stroke through the word infinite memory, what happens is that Redis is pretty reliable. Sets will fail because it can't add a new key to the database, but gets will continue to work. It'll do what it can, but if it keeps growing too big, like for instance, if you have set to never expire keys, eventually the Linux out of memory killer will introduce itself to you. The OOM killer is a process that kernel runs to save you from yourself. When a system is so badly overloaded that it's either going to crash completely or some processes are going to die, the OOM killer says, I volunteer with the gun and it will see your Redis server, which is several gigabytes in size, and it will say, oh, that has freed up a lot of memory. And now you have no more memory problems. This is how we fix those problems. It really is that simple. Just have about two times as much RAM in the server as you have set your max memory directive, and just in case, keep three times as much disk space. Redis has not complained since, even though its current uptime is at least 400 days straight without a restart, without a reboot. And I will now take any questions you might have. It's a plug-in that I have on my server that I use on something. Memcache D. That might be it. So that's what the settings are, the right ones. But you're not aware of how to work through all that. You would not configure Lightspeed. You would configure the Redis server itself to change those settings. Not many. But what you're offering here is this is a plug-in that we can pull out through the repository? Yeah. A WordPress site or it can install somewhere else? You install the plug-in on your WordPress site. And it points out a Redis server that you set up separately. It might be, it might not be. If it's been working for you, then it sounds like they've done the setup on your behalf. They've probably made sure that it has enough space that keys expire, that it's doing backups and all that. But you'd have to ask them. Yeah. Yeah. Memcache D. Memcache D is basically the Pepsi to Redis' Coke. It's pretty much, yeah. Pretty much this entire talk, I could change about 12 slides, and it would now be available to Memcache D. I turned this on. I didn't see any significant difference. So it was sort of like, is this working? I'm not sure. I don't think so. Because I, you know, rise of cache and minify, all kinds of stuff along. Yeah. So I didn't see a difference. So if I were to go this route, would I get a better, possibly, outcome? It's possible. Like, part of what's happening is that if things are already fast, they're already fast, we're running this because, Biblio Web, we have several million monthly active users. And like I said, taking 1% of one request, taking one request and making it 1% faster, you might not notice that. But if you have a million requests and all of them get 1% faster and all of them use 1% less MySQL and all that, that you'll notice. You might just not be under heavy enough load yet for the efficiencies to really kick in super-obviously. It's like cutting it here. Well, the reason I'm interested is because the site, even though I've got everything, you know, tweaked is tweaked. Yeah. How many plugins do you have? Six or 10 or 20 plugins.  Have you ever optimized your images? Yes. Yeah. How many resources are you loading? There's so many other factors. I agree. And I've been examining all of that to the point where I think, well, maybe the theme itself, are you running a shared posting environment? It's an enterprise one that shares that. Yes. Is it shared or is it taking shared? Yeah. He's probably like running this on a dedicated server. Yeah. Yeah. Some of these things are the things that you do when you have, like I say, tens of thousands, millions of active users when you're serving in petabytes per month. Some of this will be useful. All the stuff that I talked about, if you're developing plugins, you will want to use Trans, you will want to use the Cache API, even if you never run Redis. Knowing about the Get Set pattern and knowing how that works, that will still help you as a plugin developer and as a plugin user, it will help you be more aware of what happens when something breaks. It helps to know what's going on under the hood. Okay. Yeah. Yeah. Okay. Yes. How does this work with other Cache plugins like WP Cache? WP Rocket. It doesn't really. If you pick one Cache solution, then you don't need another. Like if WP Rocket is working for you and it's giving you the performance you need, then you don't need this. But if you switch over, then the other Cache plugin is not going to work. They're both going to try to put in that object Cache drop-in and whichever one wins is the one that's actually going to be used even if you have both of them activated in the control panel. So for a smaller site, like you was mentioning, is it better to go with Redis or to go with a plugin like WordPress Rocket? For a smaller site, I lean toward Redis, but that's mostly because I'm a server guy. I am the sort of person who just says, well, I'll just drop a Docker image of WordPress in here, start up a container and do some benchmarking. If you're not there, then look at other Cache plugins. They will all work on the same principle of trading space for time. And if you find one that works for you and you feel like you've got your head around it, then that's fine. I'm not advocating for this product specifically. I'm advocating for if things are slow, this will help a lot. Yeah. Yeah, but it won't matter. It's just whatever HTTPD. Nginx talks to WordPress, WordPress talks to Redis. There's no connection. We've got a lot of moving pieces in our application stack right now, so we don't really have the ability to really do an isolated experiment like that. We've got Redis, we've got MySQL, we've got Varnish, we've got a load balancer, et cetera, et cetera, et cetera. We might do that experiment someday, but we'd have to be set up to actually give us something useful. Anything else?


Alright, hey everybody this is Dr. O. In this video we're going to talk about the pH and its effects on growth. We've already covered oxygen and temperature, these kind of things. So just real quickly the pH scale goes from 0 to 14, 7 is neutral, anything with a pH under 7 would be acidic, anything with a pH above 7 would be alkaline or basic. So an acid file is going to love an acidic environment, a neutral file is going to love that neutral pH area around 7 give or take, and an alkaline file is going to like more alkaline temperature.  But we only care about the ones that like to grow in us and on our food, right? So most bacteria are going to grow at a pH between 6.5 and 7.5, makes sense, you know that's the world around us is like that, our bodies are like that, so make sure you note that, most bacteria like to grow between a pH of 6.5 and 7.5 hovering right around a neutral. There are very few microorganisms, very few bacteria that can grow under a pH of 4. So there are some acid files, there are some organisms that can grow at a pH of 1, but they're not going to grow in you or your food so we don't really care about them. The reason that we love the fact that a low pH will inhibit almost all microbial growth and especially pathogens, this is why fermenting your food is such a powerful food preservation method. So when you turn cabbage into sauerkraut or you make kimchi or make yogurt, these kind of things, fermenting things lowers the pH greatly because of all the lactic acid added to the food and that's what makes it a preservation method. I don't know how long a cabbage would keep sitting out or even in the refrigerator, but I've had sauerkraut that I keep in the fridge just to see how long it goes before it turns and it hasn't after years. So the fact that most microbes don't like a lower pH is the reason fermentation is such a great food preservation method. Right, just you know, molds and yeast, they generally can grow along a larger pH range but they generally like a pH closer to 5 to 6, so bacteria like 6.5 to 7.5 molds and yeast a little more acidic. One last really important thing, so whether you're trying to keep microbes alive in a lab or hoping they don't survive, remember that just like us, microorganisms produce acidic byproducts or acidic products or compounds as a byproduct of their own metabolism. So we generate acids that have to be dealt with, we have buffers, but then we have urinary and respiratory mechanisms to deal with those acids. Microbes basically spew them into environments. So as microbes are growing, they basically poison their own environment by spewing out acids which lowers the pH, which they don't like, so this is one of the main reasons that we don't live on a planet just a mile deep with bacteria. They poison their own environment by releasing these acidic byproducts that lower the pH. All right, so that is the effect that pH is going to have on microbial growth. Have a wonderful day. Be blessed.


Thank you very much. I'll quickly introduce myself. I'm Daniele Perotida. That's me. My favourite portrait of me. As you can see it says I am Python software. I work at Divio, a Swiss Django company and I'm a developer of Django CMS. I'm a core developer of the Django project and a member of the Django software foundation board. You can find me in the usual places online as evild MP on IRC and GitHub and Twitter and there's my email address there so feel free to contact me about anything. So firstly, thank you. Thank you for inviting me to be here, for being here to listen to me speak. Thank you especially to the organisers and volunteers of this conference because if you're enjoying yourself here it's because of them. I know how much work it is to run a conference and to run a conference of one and a half thousand or so people is a pretty big deal. Things will go wrong. If things go wrong it's not because they didn't care or didn't think, it's just because stuff happened. So if you see any of the volunteers or organisers just say to them personally, oh thanks by the way I'm enjoying the conference because I can tell you as somebody who has done this that actually it means a great deal. So thank you to those people who are making this happen. And of course to the sponsors who make it happen, make it possible financially, the speakers who have put a lot of time in and all the participants who have come here to get together. As I said I work on Django CMS. We're sponsoring so we are also very busy this week. We've got a Django CMS help desk on Thursday. We're doing a docker workshop on Friday and we're sponsoring so. I got all excited that this is a great marketing opportunity and the best that came up with is Django CMS, We're Around Your Neck. So I don't know maybe Twitter will come alive with... No I'm going to go into the office and get lots of congratulations from the team when that makes a big splash on Twitter because I think We're Around Your Neck actually works really well as a marketing thing. So I want to talk about mines and machines and python. I'll have a tiny amount of python code in this and it's not very impressive. This is Alan Turing, the great Alan Turing in a rare photograph of him smiling and in his paper Computing Machinery and Intelligence in 1950 he turned the question of whether machines can think onto its head. In fact he said the question can machines think is too meaningless to deserve discussion and instead of asking whether thought can occur inside a computer he wanted us to consider whether instead whether a machine could in principle be indistinguishable from a human in those respects that allow us to say a human thinks or has intelligence. So he turned the question about machine intelligence upside down and he was applying insights from the philosophy of mind that emerged in the early 20th century which also moved away, moved the questions of mind and intelligence away from a concern with the metaphysics of thought and the intrinsic nature of consciousness towards questions like what constitutes an interaction with intelligence or how do we recognize other minds. So in other words he was very much in line with or following the footsteps if that's the right word of thinkers like Gilbert Ryle or Ludwig Wittgenstein who argued the search for mind was not a search in a mysteries but a matter of recognizing what was in front of us all along. So we could say that this represents a kind of fork in the study of artificial intelligence and Turing's argument in a way freed researchers from having to clamber into these kind of opaque mysteries of what goes on inside of consciousness and thought and instead concentrate on producing for example interactions that seem like encounters with intelligence and that's been the dominant fork if you like in artificial intelligence since then and its fruits are all around us I mean literally in our pockets so you've got your phone you can say do I need to carry an umbrella today or what's happening what events are on in Bilbao this week and the power of machines to recognize stuff like languages, faces, text or road traffic or not if you're in a Tesla sometime and to respond appropriately has certainly taken me by surprise and I think it's taken many people by surprise just how good machines have become at doing this and by Turing's account I really do think that we're living at the beginning of an age of machine intelligence but what about that other fork that lonely a furrow which fewer people have worked on and we hear less about that people have been working there and have been trying to unpick these mysteries of thought itself so Turing was a very intelligent thinker but just because he dismissed something as too meaningless to deserve discussion doesn't necessarily mean that that is so here are two people who thought otherwise who disagreed with Turing Joseph Weisenbaum in computer intelligence research she was the author of Eliza, the program Eliza which was his attempt to demonstrate in a concrete way what was unsatisfactory about Turing's analysis or the philosopher John Sol so in this talk I want to go back to that fork because I also think that Turing's analysis however brilliant and powerful it was is a bit flawed and inadequate and I think that the incredible advances of the series and the chatbots and the self-driving cars as far as we're actually concerned with intelligence I think those represent a dead end so those things like Turing's approach begin from the outside not really I think concerned with the nature of intelligence itself but with the challenge of creating an appearance of it what does intelligence look like what does it feel to be in the presence of intelligence and in narrow limited spheres this appearance can be extremely successful and the more successful the appearance the more easily we fall into using the language of intelligence around that behaviour so forgetting that I mean some people might actually find this contentious but I think that we're dealing there with a simulacrum of intelligence that's really in the case of say Siri no or a Tesla car is no closer to consciousness than a stone and I think the more interesting question is the neglected one that begins from the inside that asks what lies at the heart of intelligence how and where does consciousness arise and as programmers I think we have the concepts and tools to investigate this in useful and interesting ways and I want to argue two things in this talk firstly that programming concepts give us the most that the programming concepts that give us the most interesting insights are in fact the most basic programming concepts and that we can find their counterparts in the work of artists, poets and writers and that this helps us understand so for this we'll turn to the concept of poesis a Greek word it's where the word poetry come from and it means to make or to produce and it doesn't mean making or production in the sense of manufacture think of French or Italian verbs like fare or fare which they mean at the same time make and do or think in English about the way we would say things like making friends or making love that's the kind of making perhaps that is involved in poesis Poesis is not concerned with material or technical construction but with rendering a transformation in the world an act through which or a process through which something new is brought forth in poesis something becomes another kind of thing altogether a new thing emerges out of something something that wasn't there before so poetry can be considered a kind of poesis and I think that programming also represents poesis and that poets and programmers because their work is poesis this kind of making can help us understand usefully some quite deep questions about ourselves and particularly about the nature of our human consciousness our thoughts or the mind straight into the work of programmers and artists programmers seem to be particularly fascinated by ruled governed play when they find it and they respond to it strongly especially in poetry and art for example and there are some poets and artists and writers whose work and ideas speak very strongly to programmers because of this and I think that there's something in programming no, I think there's something in the way that programmers think that make them especially ready to understand and appreciate the intersection of these things these work and ideas so there are certain things you know that a programmer is just going to get a certain idea or a certain work or something like that I think part of the answer is that ruled governed play takes place in systems which of course programmers are also very fascinated by and three other things that programmers love best in systems are interesting outside programming loops, self reference and hierarchies and these are also the things that make ruled governed play very interesting and of course there are also some of the most basic structures and concepts in programming itself ones that determine the way programming works so let's start with loops even the simplest loop represents power it doesn't matter how trivial it is you can still unleash something infinite and the computer will try to realise it so there are many constructs in computing this is kind of the most basic but also the most beautiful and powerful I love loops, all of them but still the fascination of go to 10 is quite limited the only thing interesting about that particular loop is that it's infinite not because of anything that comes out of it so that's not very interesting but when we apply loops to other things then they get more intriguing does anybody know or remember the website textarc.org I used to spend a lot of time there 15 years or so ago what it does, it loops over a text and represents it visually and I can't show it to you on a real website because it's so old that it's Java and I have to load a virtual machine running Internet Explorer to do that so I'll just have to show this is the text of Alice's adventures in Wonderland right round the edge and then the words in the middle are in their place depending on where and how many times they appear around the end so look, here's the word and therefore the character Alice in relation to the entire text or in relation to the story Alice is literally at the centre of the story of Alice's adventures in Wonderland here's the griffin so you can see a peripheral character here's a linear sequence through the actual text in Textarc go and find Textarc it's wonderful if you can get it working on your machine if you can find it working on a Macbook on a Macintosh tell me how because I'd love to get it working again so in Textarc we no longer have a sense of the content of the work but instead we get its structure exposed by a loop presented as metadata and structure metadata matter we've lost something, the content but we've gained something else because it lets us see new meaning that perhaps was previously obscured in the loop of Textarc we can see who is associated with whom or what we can see who appears when and with whom we can see who dominates the story and when I say see we literally visually can see it so don't be distracted that Textarc is amusing in literary what it does is powerful and significant a fact that's not lost on large corporations and governments who understand the power of this stuff too Google and Facebook know all about structure and metadata and right now in various countries governments are anxious to have legislation enacted that will help them look more closely at metadata data of course they'd never do anything like eavesdrop on their citizens because that would be wrong they just want to know some of the metadata surrounding those conversations so I don't know if you can see that from up there so storing metadata is not an invasion of privacy it's a tool that keeps America safe no one is listening to your calls congressman I see here last Friday you talked to your wife then immediately called an escort service then a hotel of course we don't know the content of those calls so that's your wife now so this stuff is powerful Microsoft I came across this by chance we use the cloud to visualise information so we can track down the criminals yeah I bet you do so on Textarc the first text you get is Hamlet it's not there by coincidence programmers and people who are doing stuff with language always go for Hamlet or Alice or Hamlet these are the two texts they always go for there's something special about these two texts here's Hamlet and here's Ulises Carrion he was a Mexican artist and I'm going to play you a part of his Hamlet for two voices so I've got to bend this down and we don't have direct audio so I'll just do this here Penado Penado Penado Penado Penado Horatio Marcellos Marcellos ok so I think this is hilarious I think this is very funny but I also think it's not just funny it's a new interpretation of Hamlet it's a Hamlet for two voices left and right it's the whole of Hamlet about 15 minutes like that without any content whatsoever all we have is the structure so what have we lost and what are we left with well it's true that you won't know from this that Hamlet is about revenge or murder or desire and you won't know that Hamlet is a prince or the story set in Denmark but there's still a lot to learn we know who's there at the beginning we know who's there at the end if you're there at the end and a Shakespeare tragedy that's a big deal you know not everybody gets to be at the end we can discover whom the story revolves around who dominates the conversations who hangs around with whom who answers whom so we've lost something we've deliberately thrown some information away but we've exposed perhaps some previously hidden information at the same time now when I play this to other people everyone at first says what is this and then it divides the world up into programmers and non-programmers because non-programmers say what's the point and they're baffled or even irritated and I've had people really annoyed by that but programmers love it now you may all be programmers if you didn't love that then maybe you just don't have the soul of a programmer because also some people who are not programmers love that so maybe they are non-programmers who have the soul of programmers but anyway the point is that programmers get this kind of thing they understand loops they understand what's important about metadata and they know how to recognise a key value pair when they see one so you know you show me some key value pairs and well I'll show you some code actually so let me quickly jump into here so I've got a little program a little python program and it just jumps onto the internet this is a very useful soup this is a very useful library for exploring structured texts like HTML it loops through the text drags things out in pairs and then passes them to the say command so I'm going to this is my little tribute to Ulysses, carry on Francisco Bernardo Francisco Francisco Horatio Marcellus Marcellus so computers are perfect tools for this kind of thing for the exploration, the analysis, the discovery of texts and language and if you're interested in doing that it's very easy and accessible stuff to do what could you discover with a simple program like text arc or something like this could you extract the punctuation from a text maybe and recognise the author by the punctuation or by the white space I spent a lot of time with a raspberry pie and an array of LEDs visualising the characters in the hamlet as kind of spiralling outward different coloured lights so it's fun to do even if you're a lousy programmer like me there's a massive amount of this stuff going on in the world of literature there's a whole field of experimental literature that analyses text synthesises them, deconstructs them there's the Ulipo, the Auvoire de Literature Potentielle the workshop of potential literature French mostly French writers, mathematicians and artists I don't really have time to talk too much about that but I recommend having a look at that and you don't have to go to experimental literature hear a couple of pages from Douglas Couplin's Microsurfs the vowels on one page and the consonants on the other and we can play endless games, fun games illuminating games with text like this and I'm talking about games and playing and some of it's fun but it's also serious because play doesn't just refer to having fun play means the looseness in a mechanical connection you say it has a lot of play in this connection when the connection is not tight the extent to which one side of a connection is free and undetermined by the other and play is only possible where you have a linkage where you have a connection, a constraint if there were no constraint at all then there would be nothing you wouldn't have any play, you just have no connection and on the other hand if the connection was so tight that it were lock solid there would be no play either so you only find it where there's a connection and where the joints permit some movement and the rules and connections in language are just open and enough and open and loose enough for both rigorous meaning and play within the same system which is quite remarkable and this kind of play is something that's enjoyed and exploited by artists and writers and programmers so we've seen some examples of looping in text art and Hamlet but this kind of play becomes even more interesting when the looping becomes self-referential so his Ulises carry on again with his first Spanish lesson I know some of you already know Spanish but let me play you his first Spanish lesson so this is Fiendish Espanol Espanol Espanol Si Espanol Es Espanol Si Es Espanol Es Espanol Espanol Si Es Espanol Es Espanol Es Es Espanol Espanol Si Es Es Espanol Es Espanol Es Si Es Espanol Espanol Sî, sî esespanol esespanol. Es, sî, esespanol esespanol? Sî, sî esespanol esespanol. Es, sî esespanol? No, sî esesno esespanol. Es, esesno esespanol esespanol? Sî, esesnol... Okay, so I mean, this is language about language. this is language looping over its own structures, recursing on itself, its language-eating language. And now, again, I have played this to people and I have watched people get angrier and angrier as this goes on, you know, definitely not people with the souls of programmers.  So, er... I love this. Look up Ulises Carrion, bless him. He died young. This is so fascinating. Now usually when something consumes itself in this way, it reduces itself to nothingness. But in this case, something new, something other seems to be coming out. Something new and almost magical. Something slightly maddening about it. And it's a perfect example of playing with rules and processes. So it's a programmer.  In a way this is a program that follows its own internal logic, obeys its own rules. And it makes me think, you know, could we make a first Python lesson in the same way? And you know, we have the technology. We could get Python to consume itself and regenerate itself like this. But I got distracted by my Raspberry Pi and the colour LEDs. So I never really got much, much further than that. But, you know, maybe somebody's a... a better programmer and less easily distracted could come and talk to me about that. So it's kind of impossible magic when you make something eat itself. But it's a very old, a very ancient concept. So here's the uroboros, the snake that eats its own tail. And it's very important. It's chemists in their dreams. As you'll know, if you've studied chemistry. So Augusta Cicules had a dream of the snake eating its tail and provided him with the solution to the puzzle of the benzene molecule after many years of studying carbon-carbon bonding. It's an ancient symbol of renewal and regeneration in many cultures. And programmers as much as artists are fascinated by what happens when a self-reflecting process loops. And as programmers we're particularly lucky because we've got the perfect tools with which to explore it. And I've mentioned magic. It's a kind of impossible magic.  The magic lies when something eats itself and then somehow sustains itself and then something new emerges, something that wasn't there before. And I think it happens in Ulises Carrion. Something new comes out of the loop that wasn't in it when we started. A new thing altogether. And this is the poesist that we're in search of. Or maybe I'm in search of. Here's another representation of the uroboros. This time back the artist MC Esher who's also fascinated by loops and self-reference. It's a woodblock print with some very interesting things going on. Where does this loop begin? Is it a loop? Well, is it one loop or is it several loops? Was there four bands going on? Is that five loops? Is it four loops? Is it one loop? It's looping on different levels. You have to choose the level at which you see it looping. You have to make a decision to hold in your mind when you look at it. There's a hierarchy of looping going on. And this is where things get really interesting. Here's Douglas Hofstadd. I think he's possibly one of the most interesting thinkers you could ever hope to read a book by. He's interested in hierarchies. In multiple tangled hierarchies of self-referential loops. His best known book is Gerdl Esher Bach. Which explores art, music, logic and consciousness. And it's an utterly remarkable book driven by this fascination with loops and self-reflecting processes. And he's in search of the ultimate in self-reflection which is our own human self-consciousness. Subjectivity itself. And the book itself loops and recurses and reflects itself at different levels in its own structure. And he's interested in what could emerge from this kind of process. And it's a work, a book whose humor and sense of aesthetics will appeal very naturally to programmers. Here's Hofstaddder's law. It always takes longer than you expect even when you take into account Hofstaddder's law. Programmers love this kind of stuff. So, we've talked about emergence where something new and unexpected comes out of a process at some other level. Hofstaddder's interested in these emergent properties of systems. An emergent property is one that arises in a system but can't be found in its components. So, sometimes the property might be geometrical order. These are rocks in a river where water erosion has produced this remarkable effect. You know, the rocks aren't shaped like that because of some structure of the rocks. It's an inter... It's nothing in the rocks that represents that structure. That's only an interaction between the rocks and the water. And the water doing something to the rocks and the rocks in turn doing something to the water. So, the rocks themselves don't have that structure at all. Another example might be an ant column where column organisation is nowhere to be found in the behaviour of individual ants. You know, you don't see ants doing that. You can't predict it and yet a column, a new system emerges that didn't exist before. Or in art, in the work of Bridget Riley where the procedure she follows align down a page and it produces through the natural free play of this activity something that's not in any of its components. Or Google's deep dream that uses iterated pattern searching and generation algorithms that starts to holes and crosses levels of hierarchy and new levels of significance emerge. Or evolution, natural selection in nature itself can be considered an emergent property, something that comes out of basic chemical or biological processes. And there are multiple levels of hierarchy in these systems. Other properties in nature themselves are the emergent features of evolution. So this property that came out in turn feeds back into the system. So there are numerous behaviours in nature whose explanations have been sought in emergence, like cooperative behaviour which is hard to explain sometimes. Why is there cooperation within or even between species when it would seem that at the level of individuals there's no such benefit. So this graph is from a python library, Axelrod Axelrod and it shows the successes over time of different strategies in a tournament of the iterated prisoners dilemma which was set up as a search for the secret of cooperation in evolution. First by Robert Axelrod who was a political scientist in the 1980 in the first tournament selfish strategies did poorly. You know the prison I don't have time to explain the prisoners dilemma but I think probably most programmers are aware look up the prisoners dilemma selfish strategies did poorly and last year my friend Vincent Knight at Cardiff University implemented this as a python library and it's you can play you can develop your own strategy and put it into the tournament it's been wildly successful and has reignited interesting in Axelrod and the prisoners dilemma very interesting so have a look at Axelrod so those are all examples of emergent properties of different kinds not all of them have anything to do with consciousness of course but Hofstadda argues that consciousness intelligence is an emergent property that arises from systems in the brain and we discussed loops first of all and the magic that seems to follow in loops becomes self-referential and something new springs out of them and then Hofstadda is also interested in hierarchy so that we have loops within loops and loops at different levels in the system and his thesis is that hierarchies of self-reflecting or self-similar loops that repeat themselves at different levels lie at the heart of cognition and consciousness that the brain's neurological processes are themselves based on loops and self-reference and logic and play consciousness he says it is an emergent property it doesn't exist in the neurons of the brain if you're intelligent it's not because you have really intelligent neurons you won't find intelligence or consciousness by looking in to the brain and looking more closely at its neurons if we're going to find something there it will be by studying the system what happens in and to and between its loops so this here we are again this is the impossible magic where something emerges reflects on itself feeds back into itself crossing these levels of hierarchy Hofstadda thinks that this is the origin of consciousness that self-refering hierarchies of loops lie at the secret of thinking of cognition in these merely physical processes in which absolutely no consciousness resides because they're merely physical processes consciousness belongs at a different dimension so could consciousness be a system that nourishes itself like the snake eating its tail apparently impossibly and Hofstadda thinks so in fact one of his later books is called I am a strange loop and the eye of our consciousness of subjectivity is this process of looping and self-refering across hierarchies so now we're talking about intelligence and programming in a very different way from the one that followed Turing we're talking in ways that I think do make it possible to ask meaningful questions about whether machines could think and it raises the possibility of an approach into cognition research and artificial intelligence that's quite unlike some of the ones we see at the moment that are premised maybe on big data and huge ontologies brute force is unkind but I'm an unkind person on vast computing power and instead we begin with the simplest of things like the simplest concepts and tools that we as programmers enjoy playing with play itself we enjoy playing with play with rules with poesys, with analogy making, with processes so this approach comes into the question of consciousness of intelligence as poesys as a process that is at the same time transformative that brings forth something new out of the world or into the world and I think it's very intellectually compelling and I think at the same time however philosophically profound it might be the opportunities for exploring it are right at the hand of even the most novice python programmer which is also a fascinating thing and it gives us a way into this quest that seems very rich and valuable and illuminating and rich for exploration especially by us, by programmers but it's more than that because I think it does something even more important it gives us a way to look for not just an insight into artificial intelligence but just into intelligence itself and I think the kind of posturing way of doing this doesn't give us any of those insights you know, I don't think that Microsoft, you know, Mike Tay the Microsoft Hitler-loving sex maniac chat bot on Twitter that I don't think that tells us anything about the nature of intelligence however clever it might be and the question of whether Hofstadder in the end is right or wrong, I don't think it's that important it doesn't matter whether he's on the right track about the nature of consciousness and cognition his ideas are so beautiful and powerful and compelling that we should wrestle with them anyway I think certainly more elegant than Tay or Siri or all these other things that people are doing very clever things with and my background is not in programming but in philosophy I've been wrestling with Hofstadder and these ideas for a long time so a long time and it's really wonderful it delights me that I'm happy it delights me that I'm able to be in the company of programmers who find this stuff because they've got the right souls they find this stuff so fascinating immediately and are also fascinated by the poets and writers and artists that fascinate me and these things that I've found in programming in a way it's come back in a circle for me because it's another pleasing circle or something going back to the beginning these philosophical questions that have been with me for decades so it's like a snake eating its tail again there are some references for you if you want to follow up any of these things I've got my Douglas Hofstadder in that bag it's just falling apart it's been with me for a long time and I'm very grateful to Douglas Hofstadder so I haven't really I haven't really taken you anywhere but I hope I've given you something to think about and I hope that somebody will come up to me who's a better programmer and give me some better code that I can maybe develop this talk in something that does a bit more Python and a little less talking so thank you very much I think we've got time for a few questions have we thank you I should say a colleague of mine had to wasn't able to come so I'm doing another talk in case you didn't get sick of hearing me already on Thursday on documentation driven development so please if you've got any questions I'm happy to talk to you now or later let's go here so I heard some critique of this sort of big data approach to building intelligent systems and perhaps you can say that you cannot really call them fully intelligent in the moment but imagine they succeeded and they made like a talking and thinking robot that you can have a conversation with I guess you would still say that this is just a simulation of intelligence so I wonder in your view what is the difference between a real intelligence and a simulated intelligence if Hofstadr is right we could have an artificial intelligence and I'm not sure that he is right but I'd be much more prepared to admit of a Hofstadr like artificial intelligence than one that is based on you know this as you say the brute force big data mining and machine learning because I don't think a simulation is good enough something that's artificial something that's a simulation just because something is artificial doesn't mean it's not real it just means that it's been made so we could have a real intelligence a real intelligence that's artificial but a real intelligence that's simulated it sounds like a contradiction in terms of it's merely a simulation however good it gets because what's going on I think the question of what's going on inside actually does matter or this is Turing's argument it just seems unsatisfactory to me we do care what's inside are there any questions? one could take even a more recursive point of view about that question that is we saw the the Spanish lesson the Spanish lesson basically points to the idea of an infinite string of Spanish, Spanish, Spanish you get what I mean the thing is that that concept exists linguistically still is infinite is like the fixed point of an infinite sequence so through language we can even represent that sort of thing fixed points of infinite sequences that sort of thing sometimes don't exist so we have signifiers without signified and the thing is that intelligence itself maybe is something without a signified also the first Spanish lesson I'm afraid is a bit of a trick it's not just folding entirely by itself there's actually the director the artist who makes it go in the right directions it's not simply putting a Spanish at the beginning of everything it's choosing the right things and it's playing with them for example the fact that some things are homophones in that the same sounds can be rendered differently so it can keep asking the question so it would actually be less interesting if it weren't directed so there is some energy going into that system from outside and that I think is if there's something wrong with Hofstadder that's probably where it lies Eddie Yeah we got time for one more question Hello and good talk Do you think that maybe neural nets combine the two approaches to artificial intelligence in neural nets have maybe this emergent feature to them which might be described as emergent conscience? I mean that seems to be very promising and interesting because they one of the things that we've learned from neural networks is that they sometimes do unexpected things and not just unexpected things that it was left instead of right but new orders of things sometimes where a neural network will have an answer or have a response that seems to have stepped out and be looking at the thing from a different level so that might be a very I don't know enough about neural networks actually to say anything that useful but what I've understood is that actually that is a promising possibility that is the kind of thing I think that might just be the start of the kind of thing and we'll find more surprising things still I'm sure we can take more questions offline but I have to cut you off here, thank you again Thank you very much


Hello and welcome to this session. In this session we discussed the following question which says find a unit vector in the direction of vector a equal to 3i cap minus 2j cap plus 6k cap. Now let's move on to the solution where given vector a equal to 3i cap minus 2j cap plus 6k cap. Now the unit vector in the direction of vector a is given by a cap is equal to 1 upon magnitude of vector a into vector a. Now we are given vector a is equal to this so we find out magnitude of vector a now this would be equal to square root of 3 square plus minus 2 square plus 6 square that is that is this is equal to square root of 9 plus 4 plus 36 which further is equal to square root of 49 thus we get magnitude of vector a is equal to 7 therefore we have that a cap is equal to 1 upon magnitude of vector a that is 7 into vector a that is 3i cap minus 2j cap plus 6k cap. So we get a cap is equal to 3 upon 7i cap minus 2 upon 7j cap plus 6 upon 7k cap. So this is the unit vector in the direction of vector a. Hence a final answer is the unit vector in the direction of vector a equal to 3i cap minus 2j cap plus 6k cap is a cap equal to 3 upon 7i cap minus 2 upon 7j cap plus 6 upon 7k cap. So this completes the session. Hope you have understood the solution for this question.


Hello everybody, welcome back to my channel Now this is just a quick continuation of yesterday, and I just wanted to show that One that I didn't kill this device when it went into our lunch and just overheated to about 86 degrees I believe it would have been hotter if I got the probe on that straight away Now nothing's changed on this circuit The other thing I've done is tried to just get this probe tip to sit in the back of the heatsink here So you can keep an arm that on this meter at the back. It's currently 21 degrees in here So the best area for this working is 25C Tops otherwise just start losing its capabilities now I'm gonna tell you a bit of shortfall of a circuit like this is One if we are now putting in let's say up to 17 volts Let's reduce that down to about sort of 14 and a half volts into this When we take away, you know what we're losing on the diode We're losing here because it needs to have some power and some some voltage to actually work When when we take that away and we have got five volts coming out and we've got 14 volts going in that means we've got nine volts and If we are pulling one amp through this We've got to calculate our nine volts being lost across is that we're trying to get rid of to have five volts out At one amp is nine watts. So this thing is going to be heating up from the get-go Nine watts of power and that's going to go warmer warmer and warmer So really you'd probably want to transform a little bit less power on it or have this running something like a nine-volt Device here instead of this LM 7805 Well, what I wanted to actually show you is if I now put on using that same capacity difference change But I've just adjusted this to pretty much one amp to show you what the signal looks like over here And as you can see, it's ghastly and we've got one up there around 445 So I'm just going to tap that out straight away and all I want to show you is that we can go a step further And just put in now This is just what's on the bench at the moment and I've got a 200 2200 micro farads capacity and sure and then we get these things the right way round of course Was they are polarity the polaritise and then want to be in the right polarity. So now I'm going to put this back down again we can We can see as that's going up. I mean, we're very hot over here Did you see what this? This is saying here, but we got a nice Couldn't we've got a nice Straight line there, which means it's nice and clean. It's very hot on this side. It's probably not showing this very well just because It takes a bit for me to get it onto this. Oh, that's not very good Itself I think Not quite sure what's going on But for some reason why that's going that's putting up a right hole first. Did you notice that? Let me just put that down again and look at the look of the meat a lot Take that off again Now that's strange behavior But I suppose that could be because I've got these plugged in like a silly Billy and Really, I should just be having one thing plugged in when I'm doing this. Let's just see if that makes this any Any easier to read if I just put that on there And we are T1 so we just want to switch this over to T2 there we go 55 C My mistake by leaving those in I'm sure let's just see what happens when I put that down Yeah, that's a lot happier And we're at 54 and you can see oh How that is rising? That just goes to show how quickly things get warmer and warmer and warmer And of course we know that once it gets all into the 80s It tends to shut out at least over that 80, but that's all we're going to do for now I just wanted to show you that if you put a bigger reservoir capacitor on again You're gonna get a better signal, especially when it's running to its absolute maximum This is maximum one watt and that is normally at 25 C and of course the The problem with running a linear type Voltage regulator is whatever the voltage it is the difference Times by whatever current you're putting through and that's the wattage you're gonna have to be dissipating out of this thing At all times at that current Okay, right. Thanks for watching and I'll catch you in the next one