Hello, welcome to WordCamp 2023 and my talk on easy updates for old content. Thank you so much for coming. I appreciate seeing you all here. My name is Ken Gagney, pronouns he, him, his. I am a technical account manager at NewsPak, which is a division of automatic. I've been at automatic for six years. I've been using WordPress for 17 years. My talk is based on both of those experience. It will be both slide-based and live demo. There will be a link at the end of the talk to download all the tools that I'm going to be demoing for you. So if you miss something, don't worry about it. It's all online. I'd like to start by asking who here has their own personal website? Not one for a client, but one for themselves. Okay, cool. This is me making sure I'm in the right room. Good. How many of you have three of your own WordPress websites? Three, five, three, four, three. So three is the most here. Okay. How many of those sites have you posted new content to in the last month? None. None? None. How old is your oldest of the three sites? Six years. Six years. Okay, cool, cool. So we might have slightly different definitions of old content. I have a lot of websites, a lot of WordPress websites. They've been around for a while. But before I was a webmaster, if we're even using that term anymore, I was a sysop. I was a sysop on CompuServe, and Genie, and Delphi. And then I went to this small service called CyndiCom Online. And I was tired of each one getting shut down to me having to be shuffled off to a new home. I was tired of playing in other people's sandboxes. So after this happened four times, I was like, I need to build my own sandbox and play in that. So I started looking around, and I saw some different CMSs. One of them was called WordPress. The other one, I've already forgotten the name. It used to be really popular, and then they decided to go commercial and everybody jumped ship and went to WordPress. So I was glad I didn't choose that one. So I launched my first WordPress website. I used to have a movie forum on some of those online services. So I started a movie blog, and it was called ShowBits. And I would write reviews of movies, just for fun, just for myself. And it launched in December of 2006. That is when my first WordPress website went live. So in 2006, I was running WordPress version 2.0, which was the latest version, on a server running PHP 5.2. And I kept the site up and running for a long time. It's still up and running. So let's skip ahead 14 years in the lifespan of ShowBits. It's now the year 2020. A lot has changed in web standards, in the technology, in the design, in the user interface, in the expectations. So in the tech side, we're now running WordPress version 5.3. We're running PHP 7.4. And 16 years, or 14 years of all these changes. This is what my website now looks like. The same. It hasn't changed. It's running the same theme that I launched it with 14 years ago. I've been posting new content to it, but I've never redesigned it. Because it still works. Why would I go through all the trouble redesigning it when it works? There's been some other changes though, that I might want to take into account in those 14 years. So again, my site launched in December of 2006. Does anybody know what happened in the world of technology just one month later, January 2007? She's holding it in her hand. The iPhone, I launched my website before there were mobile devices to speak of. Before there were responsive websites. So this is what my website looked like on an iPhone in 2020. You have to pinch and zoom to see the sidebar, to scroll around. We all remember those days. Those days should have expired long ago. But not on my website. Nope, I was still running a non-responsive theme in 2020. And there was another big change in December of 2018. Does anybody know what that was? WordPress 5.0, Gutenberg. Big change. Maybe not to the end user reading the content, but certainly to us on the backend. Some of us installed the classic editor plug-in and held onto that for a long time. Some of you may still be running classic editor.  Gutenberg is really good now. So, I have this website, 14 years old, still works. If it ain't broke, why would I update it? Well, I can give you five good reasons. One, we just went over, it wasn't mobile friendly. I want to be able to reference my own site on my own iPhone. I want other people to be able to see it. I want to send them the link and not be embarrassed about it. So I want to update my site with a new theme that's mobile friendly. I want to avoid a PHP incompatibility. And my site, when I launched it, was running on PHP 5.2. WordPress 6.3 just came out last month, now requires PHP 7.0 as a minimum. And even PHP 7 is already at end of life. This is another website that I recently inherited that I had to update from PHP 5.2 to 7.0. I just did a lift and shift and it broke because the theme was again from 2006. This is a different site, not show bits, but this is what happened when I tried to update it on a new server, just tons of fatal crashes because that theme was never written with new versions of PHP in mind and some of its calls have been deprecated. Dream host is where I have some of my sites and it is requiring people to update to PHP 8. It is saying right here that we no longer support PHP 7.4 and older and if you want to continue running it, we will charge you an extra $5 a month. So I need to update the PHP 8 and I need to make sure my site built 15 years ago, works in PHP 8. So just because it is working today in my site does not mean it will tomorrow as these upgrades become relentless and required. Reputation, show bits is my very first WordPress website. It has been around a long time, which means it has had a lot of time to be indexed by Google. People who search my name might come across this site and I don't want people finding this site and saying, this guy works at automatic. That's embarrassing. No, I want them to see a site that I'm proud of. Content, so that's not just me, okay. That's fun. I don't know why that's doing that. I mean, if you just blink really fast you can read it. So the slide says, okay, let's see if it goes back to that same point if it happens again. Great, okay. Content has a long tail. So again, my posts have been around for a while and if you Google search some of this stuff it might still come up. I might still be getting traffic to this site. I might still be generating revenue or page clicks or contacts or inbound leads from an old website and I want it to look good. It might be generating even more inbound leads if it looks better. And also maybe I'm, okay, I think it's my Bluetooth clicker. That's interesting. Maybe I'm still blogging on this website. Maybe there's a reason I've kept it up. Maybe I'm still watching movies and still writing reviews. Or maybe I want to get back into it. Maybe this is an interest I had once upon a time. The reason it's running such an old theme is because I neglected it and now I want to show it some love. Maybe I want to start writing content for it again. And I'm used to higher standards now in my technology and I want to update this site to those modern standards. So I'm going to show you how to update old sites, the content specifically in the design, for modern aesthetics. And before we begin, I've already done this. If you're following along at home watching this video on WordPress TV, there are three things I want you to do first. Take a backup of your site. Make sure the backup works and that you know how to restore it. And then take another backup. Not just one. Always have multiple backups. I had an incident two years ago where my internal hard drive and my external backup drive failed simultaneously. Thank goodness for cloud backups. Thank goodness for backblaze. So always have multiple backups. Now at this point I'm going to switch to a live demo and show you some of what I've been talking about. Just need to switch my display for a moment. There we go. So here is show bits today and I want to change it. WordPress makes it really easy to change the theme for a site. Just install it, activate it, brings all your content over. That's great. So I need to choose a new theme. So there's another site I have developed more recently which uses a nice theme that I like. This is my Star Trek podcast. It's called Transporter Lock and it has a featured image for each new episode of my podcast. It has a little teaser, some text that I wrote. Then you can click to read more and listen to the episode. And you can just very quickly scroll down a single page and see all the episodes. You know compare this to my old blog which was truly a blog that shows the entirety of every post in Reverse Chron. I'm sure we've all had that standard once upon a time. Very popular in live journal which I was never on.  So I want this site to look more like this. Very visual, lots of images, short amounts of text. Grab people, pull them into the episode they want. Let's start there. So for this demo I'm going to use the same theme from Transporter Lock on show bits. I want to switch show bits to look just like my Star Trek podcast. So I'm going to go into the back end. I've already installed that theme. It's called bloggable right here. So I'm going to click activate and it's activated. Great. So this should be done like we're going to end the presentation right because now I've installed the new theme. Yeah, right he says. Well okay. So clearly I'm going to customize the header image at some point. That's fine. But this doesn't look as good as my Star Trek podcast. So there's no images and all the text has these ellipses at the end. Like they're incomplete thoughts, sentences just cut off, mid predicate. This is not that great. So when you switch a theme it brings all your content over but it doesn't magically generate content for you. And my old site did not have featured images or manual excerpts and that's what this Star Trek podcast is using. Each of these images is a featured image on the post and I wrote a manual excerpt at the bottom of each story. So we need to fill in those gaps on my 14 or 16 year old blog over here. So the way we're going to do that, well the reason there are no featured images on my movie blog is because, again I launched my movie blog in December 2006 using WordPress 2.0. That's when it launched. And three years later, to the month, December 2009, WordPress 2.9 came out and introduced featured images. They weren't in WordPress until 2009. So my theme didn't support featured images because they didn't exist yet. And so I already had three years of writing without featured images. I never upgraded my theme, never had the opportunity to go back and add featured images. So now I have to do that now. I have 14 years of content I have to add featured images to. The best way to do that is programmatically. And I don't mean AI. I'm sure AI could do some of the things I'm going to be talking about today. But AI usually has a premium upsell. So even Jetpack, which one person mentioned earlier talk, has, you get 20 credits free and they need to pay for more. Other plugins are similar where you have to pay for them. So I'm not using AI today, I'm just showing you some scripts, some plugins that can help you do this stuff. So I'm going to install a plugin called Code Snippets. This allows you to execute PHP on your site. You don't have to use the command line. You don't have to install other plugins, just this one. So let's go ahead and do that. WP Admin plugin install. There we go. And there are other plugins like Code Snippets. I'm not saying one is better than the other. This is just one that I know works well and works with what I'm demoing today. So here's Code Snippets. I'm going to install it and I'm going to activate it. I'm also very glad that the WordPress.org plugin repository is not blocked by this school's Wi-Fi. And now we have this new menu item called Snippets. And there are no Snippets at this moment. But I'm going to go ahead and click Import at the top. And I'm going to choose a file. And this is a script that I will make available at the end of this talk that I'm importing right now. And it says your Snippet has been imported. Go ahead and have fun with it. It's like, thanks, I will. And there it is. It's called Fix Featured Images. And I'm just going to, it's the type single use. So there are some Snippets that run all the time. And then there are some Snippets that you just run once. And that's all we want to do. It's just run this one once. So I'm going to click the Play button. And great, it's run. And now I'm going to go to my home page. And now I got some images. It's added images to six years of posts. There are some that are missing. It didn't get all of them. But this is a really good start. You know, even if I go back to previous posts, to even older posts, it's not just the first page of them. I got quite a few here. So what it did was it went through all my old posts, looked for images that I had attached to those posts and probably used in the body. And it took the first one and it assigned it as Featured Image. And there's a small but important distinction I want to make here. It didn't look in the body of the post to find the first embedded image. It looked for the first attached image. When you are writing a post in the Post Editor and you upload a post, it saves some metadata in the media library. You can see right here that the second image on the list take care of yourself. It says attached to a post called take care of yourself for Christmas. That means I was writing that post and I clicked Insert Image and I dragged that file in and I uploaded it. And it got attached to that post. It might not have appeared in the body at all. I might have decided later I'm not going to use that. I kept it in the media library but I didn't insert it into the post. It's still saved in the media library as being attached to that post. And so it got added as the Featured Image. Similarly, I might have written a post and used only media I had already uploaded from previous posts. I'm just reusing, repurposing old media. And if I had done that, the script I just ran would have found no media attached to that post because there was nothing uploaded to that post. It was all previously uploaded to other posts. You can actually, in the media library, when you're in list view, not grid view, you can go to Filter and search just by unattached media. This is media that's not attached to any post. Either the post got deleted or the media got uploaded directly to the media library, not in the post editor. And you can actually go back and you can attach these images to posts later. Just by clicking Attach right there. You choose which post it goes with. So this script goes through your post, finds the media that was uploaded to that post, and assigns the first one as the Featured Image. Now, as you saw, there were some posts that didn't have any media. It didn't get a Featured Image assigned. So what I would do in that case is I would add one more plugin. It's called Add Featured Image Column. Hasn't been updated in a few years. I normally don't recommend older plugins on your site. But this one, it's simple enough that it still works. And I don't see any risks associated with it. Doesn't mean there aren't any. I'm just saying I don't see them. And I activate that. And now when I go to my post bulk editor, there's an additional column on the far left. And it shows the Featured Image for that post. And I can very quickly, visually, manually scroll down and see which posts are missing Featured Images. And I can go in and I can manually adjust those. So since there are so many years of old posts on this site, I would focus on the ones that are on the home page. The ones that are most likely to be seen first. And I would check my Google Analytics and see which old posts are getting a lot of traffic. And I would prioritize those as the ones most likely to be seen and needing Featured Images associated with them. So we've now added Featured Images, great. Let's take another look at the home page again, see how that looks. This is a good start, I got some photos there. But I still have these excerpts down here that I'm not thrilled with. Now you may remember my old site, it was just the entirety of every post, one after the other. It wasn't using excerpts. This wasn't a theme compatibility issue, though. Does anybody know what version of WordPress introduced the concept of the excerpt? Three, it was version 0.7 released in May of 2003. And despite being called version 0.7, it was the first version of WordPress. When we celebrated WordPress's 20th birthday this past May, we were celebrating the release of version 0.7. And it had excerpts. It's always had excerpts. So even though my theme supported it, it didn't use them. On the front end, you would just see the entire post. So I always just left that field blank. And I knew that if someday, if I needed it to, it would just automatically generate them from the first 50 words or so, which is what you're seeing here. But this doesn't look intentional. It looks, as I said, like a thought cut-off mid-sentence. And I think we can do better than that. So even though I wasn't filling in that field, there was a similar field I did care about in which I was filling in. I'm going to go to the back end of one of these posts on our very fast Wi-Fi. I'm going to scroll all the way down and right here. This is my SEO description. Most of you are using a plugin like Yoast. This site happens to be using another one called the All-in-one SEO pack, or A-I-O-S-E-O-P. And this is what shows up when somebody links to my posts on Facebook, Twitter, X, Slack, etc., also very often on search engines, hence the SEO description. And so I was always filling that in because I knew that was something people were going to see. I was always sharing my content on social media. And I was making sure I was getting indexed by Google using the Google Webmaster Tools and the Search Console. So I have this information and it's very similar to an excerpt. I just need to get it over to this excerpt field on the far right. How do I do that for 14 years of posts quickly? Again, we use a script. So I'm going to go back into code snippets. I'm going to import yet another script. This is another one that I will make available at the end of this talk. Let's see. Choose the file. There it is. And what this script will do is it will check every one of your posts to see if there is a SEO description by Yoast. And if there is, it will copy it to the excerpt. If there isn't, it will check to see if you're using All-in-one SEO pack. And if that has an SEO description, it will copy that to the excerpt. And if it doesn't, then it stops. And in the event that you've already written a manual excerpt, it will not overwrite it. It will skip those posts. Just like the featured image script I showed earlier, if you have already assigned a featured image, it will skip that post. It won't overwrite that. So I'm going to go to my snippets. And there is one called SEO to excerpt. I click the Play button. I let it run once. You can also, what I will make available after this presentation is you can also run these scripts from the command line. If you are comfortable with doing that and have access to that, there's a version of the script specifically for that environment. And if you're not comfortable with either the command line or code snippets, you can actually run these as plugins. I don't recommend that because plugins are something you generally want running and operating on your site all the time, like a permanent modification. And this is just something that needs to be done once. I actually was testing the plugin version of the featured images just to make sure it worked, and it did. And then I was continuing to use my site, and I was like, okay, let's delete this featured image, and I deleted it. And then I refreshed the screen and it was there again. I was like, I thought I deleted it. Is it a caching issue? And I deleted it again and it was still there. And what happened was that the plugin was still running and every time it found a post with no featured image, it assigned one to it. And so that was not ideal. That was suboptimal, as we would say. But I wanted to make sure that you can run the script that way if you prefer. Okay, so that script is done running. It took a little bit longer than the previous one. Again, let's go to the site, visit site, and those cutoff sentences are now gone. Now we have complete thoughts. They're keyword rich. They're effective teasers, or so I hope. That's how they were written to be effective teasers. And now we have excerpts for all the posts that had SEO descriptions. So this is a dramatic improvement.  Some featured images are missing and the layout might need some custom CSS to align everything neatly. But I no longer need to go back and assign featured images and write manual excerpts for 14 years of content, just thanks to those two scripts. So from a front end perspective, this is a dramatic improvement. We've come a long way just in the last 20 minutes. But there's still one more thing that we wanna take a look at. One more thing we wanna consider. Let's go back to some of my older posts. Let's see, here's one, let's see. So when I go into the back end of one of my older posts and I try to edit it, oh, wait a minute. Let's see here, just one moment here. Yeah, just needed, I had a plugin running that I didn't want. Let's try that one more time. Here we go. So when I go into an older post that was written pre WordPress 5.0 or with the classic editor plugin installed, it all shows up as a classic block. And I can click convert to blocks and it'll break it out into paragraphs and YouTube embeds, et cetera. Ideally, it doesn't change how the post appears on the front end. If I go back to edit this post, I may want to go ahead and click convert to blocks because then I have access to all the tools of the block editor. But in this case, I want to go back and convert to blocks all 14 years of old posts. Whether or not I'm ever gonna edit them again, I wanna convert them all to blocks. And this isn't just a preemptive strike against posts that I think I might want to edit in the future. This has a real potentially financial impact on your site because there are plugins out there like OptinMonster or Newspack Campaigns or even Google Ad Manager that you can use to programmatically insert content onto your site like ads. And you may be placing those ads on every third paragraph of your story. It automatically gets inserted after every third paragraph block. Well, in this post that's on the screen right now, the entire post is a single block. And if I'm telling my ads to show up after every third paragraph, it's gonna show up once at the end of the post because all it sees, despite there being four or five paragraphs here, since they're not blocks, it can't tell where to insert itself. So it's just going to insert itself at the end, at the end of the only block that it sees. So I wanna convert all my content to blocks so that all those other plugins that I have running know where they go in the content. So I'm gonna install one more plugin. This plugin is developed by my team at work. It is open source. It's called the Newspack Content Converter. It is not in the .org repository. And in fact, I wanna give you a little warning here. This is a screenshot from the GitHub repo. It says it's at version 0.0.14 alpha. So it's very rudimentary in some ways and also comes with this warning. This plugin is presently in alpha and used primarily as a developers tool. So remember my instructions at the beginning. Take a backup, make sure your backup works and then take another backup. So I'm going to install this plugin and since it's not in the .org repository, I need to upload the zip file. Just right there. Click activate. Latest version of this plugin is only two weeks old so it is still being used and being developed. And now I have a new menu item down here called Newspack Content Converter. It says there are 512 posts that need to be converted. At 100 posts each it'll take six batches. So I'm just gonna click run conversion. And what this plugin does, on one hand I don't consider it very elegant but on the other hand I think this is the only way that Gutenberg will allow it to run. I have not found a better way to do it. And what it does is it's actually opening each post one by one in the background, clicking convert to blocks and clicking save. So the more posts you have the longer it's gonna take and it does it as I said one by one. So 512 posts is just gonna run in the background. After it's gotten started for a while it also says you may carefully open an additional tab and it'll start doing another 100 post batch concurrently. So it goes twice as fast. Now the more tabs you have open the more processes you're running on your website. So if you have a high traffic site and you're doing this on production maybe just let the one tab run and let it take as long as it needs to and it'll eventually complete. Anecdotally I have found that it works better in Chrome. Right now I'm running it in Safari but it should be fine. But and when it's done all of my posts will be blocks. You might wanna double check for example if you're using short codes which really shouldn't be a thing anymore we should be using custom blocks but if you have some old short codes you might wanna make sure that those are still loading correctly. Again take a backup first.  But when it is done 512 posts all put into blocks and all my programmatic ads, ads and insertions and house ads and et cetera will all know where to slot themselves because everything is blocks. And so when that's done that will be the end of my programmatic efforts on this site. I will have added featured images to 512 posts or many of them. I will have added manual excerpts, custom excerpts that look good on the front end and in SEO. And speaking of which if you are using Yoast you can make the SEO description in the future automatically be the same as the excerpt. So you can say the default SEO description is the excerpt that way you don't need to write the same content and paste it into two places. You just write the excerpt and that would be your SEO description in the future. And you can override this on a per post basis because they do serve slightly different functions. The manual excerpt in the SEO description. But this is how I updated a whole bunch of sites because I was asking you earlier how many sites you each have that are built in WordPress that are for you yourself and not for clients. I have 16 and I had to update about eight of them last year. Didn't have to. I just had some free time and I wanted to. And I figured that the best way to do that would to not do it manually. So this is the little toolkit that I've put together. And I will share the link to that with you now. If you go to kengagni.com slash Rochester that is a link to my GitHub repo. And it has the read me file that describes how to do everything I just did. It has links to the fixed featured images script and the SEO description to excerpt script as well as instructions on how to install them and run them. Whether you're using code snippets, the command line or a plugin. And then finally it has a link to the Newspack content converter, which is its own repo. It also has credits for where some of this came from. A lot of these scripts were adapted from other sources. One was from StackExchange and then expanded with some help from ChatGPT. Another comes from Newspack, my team, and expanded with their permission and made available to the public. And then Newspack content converter was already out there in the wild. So those three things together are sort of a toolkit. I am not a developer. It'll be awesome if these were all rolled into one Swiss Army knife that users could just install and click buttons to make things happen. But in the meantime, this is as user friendly as I can make it. And I think it's fairly user friendly because you don't need to be a developer. You don't need to be a programmer. You don't need command line access. This is just a very quick way to update 14 plus years of content on your WordPress website. So that is my talk. Thank you very much. Any questions? Thank you. The convert to Gutenberg thing is amazing. So that was written by my coworker, Ivan. He is a brilliant developer. There is a plugin very similar to it by TenUp that is in the .org repository. And what I have found it does is when you go into the post editor of a single post it will automatically convert to blocks for you so you don't need to click convert to blocks. The screenshots imply that there is a command line method to bulk convert posts. But two caveats to that. One, I couldn't get it working. I'm willing to blame pilot error. But also based on what I read it does the same thing Ivan's plugin does which is go through each post one by one and convert them. And so that's why I think this must be the only way to do it. There must, hmm? Does it use the REST API? That's a good question and I do not have the answer. I can tell you that the News Pack Content Converter what it does is when you activate it it duplicates your WP post table and it runs all the conversions on that duplicate. And when it's done it writes it back to the WP post table. Hmm. As opposed to duplicating just the post content field? As far as I know it duplicates the entire post table and then runs the conversion on that table. I think. Or maybe it just duplicates the table as a backup and then runs it on live. Not quite sure. But this is, as I mentioned, an alpha tool made primarily for development. We do use it on our customer sites because when customers migrate to our platform very often they are coming from aging platforms.  Yeah. So when we encounter an environment like that we very gingerly bring it all over to our platform. We update it to the latest of everything and that includes updating the content to blocks. So we run this script on those environments to make sure that everybody launches on our platform with the latest and greatest, which includes Gutenberg. Any other questions? Yes. A really basic question. Yes. A really basic question, how do you do a backup? So that's a great question. I will give you an answer right now but I will also say that that is potentially the topic of an entirely additional talk. So there are lots of plugins out there. Two that I have used with some success, well with great success are Updraft Plus and Jetpack, which again, full disclosure is made by automatic. WP Migrate. WP Migrate, okay. This is another recommendation coming from the audience. I haven't used it, but you look trustworthy. So there you go. I appreciate it. Anytime. And there are really like two kinds of updates you can make. One is of your SQL database. So that's all the content that you've written. And the other backup includes the actual files on your site, which is all the media you've uploaded, all the plugins you've installed, all the themes you've installed. Of the two, they're both very important. The database is potentially more valuable because you can always reinstall plugins. You can always reinstall themes, but the database has your plugin configurations, your theme configurations.  So make a backup of at least your SQL database. Nothing that I have shown here today modifies anything outside your database. It doesn't modify your media, the files that you've uploaded. It doesn't change your plugins or your themes. It's solely making changes in the database. Also, database backups tend to be relatively small. If you've been uploading media to your site for decades, and that includes potentially video files, which are huge, your WP content slash uploads directory can be gigabytes. And those downloads and backups can take a while. It's worth it, but in this case, it's not necessary. So use updraft plus or WP migrate or Jetpack or check your hosting provider. I have some sites on WP Engine and they do either hourly or daily backups.  And it'll say, do you want to restore just the database or everything? And you tell it and it'll email you when it's done making the backup or when it's done restoring it. So that's a good hosting platform. We'll do that for you and you won't need a plugin. But there are lots of options out there and they all generally work. In my case, I was using backup buddy. And I think I then migrated my site to a platform that didn't support backup buddy. So I had the backup, but I could no longer use the plugin to import it. So I had to get into some shenanigans and it got a little messy, but it worked in the end. That's not a reflection on the backup buddy plugin which is made by iThemes, which is, are they owned by Liquid Web too? Yeah. Thank you, yes. That's generally a safe bet nowadays, but. Or automatic. Any other questions? Yes, you may add one thing to that. If you are using your hosting platform to make your backups, download the backup so that if your hosting platform doesn't go down it doesn't take your backups with you or with it. That's the same reason why I also use cloud backups in addition to an external backup drive that is sitting right next to my computer because if somebody breaks into my house and grabs my computer, they're gonna grab the drive that goes with it. My house burns down, it's taking both of them with it. So always have an off-site backup. An off-site can mean a couple of different things in this case. In this case, off-site from your hosting provider is your computer. So yes, definitely do that. Updraft Plus allows you to, and backup buddy and some other plugins, let you designate an external destination for your backups and that can be Dropbox or Amazon S3. So that's what I did in this case. I need to find, I had already done all these conversions to my movie site a year or two ago and I want to kind of undo them for the purpose of this demonstration. So I went into my S3 bucket and I found an old backup that had been sent there years ago and was still there. I pulled that and recreated my old site. So was there another hand up over here? If you're relying on a hosting backup, depending on the host, you may not have immediate access to it and they may charge you for it. So that's a good point. I believe Amazon S3 charge is not only based on storage but also traffic. So uploading and downloading files to your bucket. A dream host, at least on the virtual private server that I use, which is one of the, I guess not the highest end tier of service that they offer. They say like, do you want a backup from a few hours ago, a few days ago, or a few weeks ago? You can't designate a specific date or time. It'll try to get a backup within that window and it'll tell you if it succeeded or not.  I'm glad that this has become a talk about backups but it's important. I'm glad the topic came up. Any other questions about backups or easy updates for old content? Obviously I didn't go over things like making sure old plugins still work and making sure that everything else is working the way it's supposed to. I recently inherited a site that nothing had been updated since 2006 or so and I ran a security scan on it and it found 140 threats. So I just removed all the plugins and themes, reinstalled everything from scratch, got it up and running and then I realized that those threats have been used to infiltrate the site and inject spam content into the posts. So I had prevented additional injections from occurring but now I had to go through all these posts and look for like opacity equals 0.1 so that's almost blank and there's a link to various pharmaceuticals and they were very clever about these things so a lot of search for places were being done to remove all that. So yeah, there are lots of other kinds of updates for old content you need to be aware of based especially on how old the software was but as far as an aesthetic view goes if your site has been secure you just want it to look good in a new theme, fixing the featured images, featuring the excerpts and converting to blocks is a good way to start. Again, I suspect that AI can do some of this especially writing the excerpts but probably not for free and as you saw from the talks this morning we are always going to want to manually review the results of AI because it may sometimes be inaccurate or untruthful without realizing it. So in this case we're just repurposing things we've already written SEO descriptions to be your excerpts. Any other questions? Great, thank you so much for your time.


Have you ever wondered if you can make a program with Godot? Well, actually you can. It's very very easy Everything you see here on the editor is actually built with nodes that you can actually use for creating a program with Godot So let's just start and I have here an empty project we're gonna Create a user interface node for the start everything that it's green It's basically user interface elements such as the snapbar the tabs the everything that is not a game or a 3d thing so let's start with a Control node and we have our basic scene here What we're gonna do on this first video is a very simple text editor that you can open and save files Just to edit some text is gonna have covered the basics for it. So what we first want to add is Text edit node this node is basically like a code editor like dialogue You will see it here. It's gonna place it. I don't know like let's cover half of the screen With it Let's just try this. It's gonna ask us to save main. It's the main scene And as you can see here, we have a simple text editor So this is working like as you expect it to work It doesn't have anything fancy, but you can you know cut based or basic commands Okay, so let's try to make this open External files to do that. We're gonna need a button So we can start with that process. Let's see here on the control nodes Let's search for base button. Just a regular button. Yeah, nothing weird We're gonna place it here and the properties of that button here the text. Let's say open file Okay, so our open file Let's add and I'm gonna clone this one with control D you duplicate the node and Let's prepare for the save file Let's capitalize F. Okay So you have the buttons here, but of course they will not do anything. So we have to code that logic For the open file with We want to get is a file dialogue so we can select the file from our computer to do that You have to create first Popup which is Window dialogue Confirm that here. It's very hidden. It's in the depths of this pop-up menu and The file dialogue one is the one that you want for selecting as it describes it here So one thing that you will notice at first is that you don't see them by default and all the pop-ups are Invisible even if you make them visible here like they're not gonna be visible on On the game itself when you launch it on the program and you get a warning here Because you have to use the pop-up function to display it. Okay, so this is irrelevant to it Okay, that's gonna make this bigger. So yeah here in the center This is the title modes here you have like the different modes for this we want to open file with this and and access File system because you want it to be able to select anything other than the anything on the system And as you can see I'm already like here's my files and things like that and This should be Good for now.  So let's start with the code now. Okay, sorry Let's start with the code with this button. That's gonna rename it to open file and save file We can either place the logic of the entire program in the root or you can do it in Small chunks here prefer to do it here in the root because it's a fairly simple program and I don't want it to be Very complicated. So just Create the script. We're gonna call it main dot gd or better. Maybe app This is gonna be our application and now we can start extending and Creating the program Let's remove everything. We don't really need this I'm gonna keep Pass function, okay so You can make it Everything with code, but I'm gonna go over the editor stuff first for instance here Let's use this no six Signal pressed so when the button is pressed. I want to call a function and Here we have it on the control node Which is on open file pressed and we do something What do we want to do? Well, we want to make the file dialogue Pop up Which is the function that you want to call when you want to show it if I said if I try this Project now like if I press here, I can open a file and I already can Select files and open them thing is there's nothing When I use this because we still haven't get the signals from the file and The same can be done with the save file dialogue here. We have this file dialogue. Let's gonna We're gonna duplicate this one And it's gonna be save file dialogue It's gonna swap the things that we want here instead of open file. We want to use the save file and the title It's gonna be save a file. Okay, so we have it here as well And let's go do the same with this button Button press we connect the signal to the main one and And we call The pop-up function for that window dialogue thing Okay Now what we want to do is that when we open the file we want to get all that text string here on this Text edit node So how you do that? Well, if you go to the file dialogue and the nodes you have the File selected file selected or till direct directory like selection We want the file one because we are getting only text files and we're gonna connect it to control so Here this will trigger when you select that To confirm it you can for instance print the path and you will see that Once we select a file to open like for instance this app that GD we get here the full path of the File that we open so we're gonna need to search for the file Class and get more information on this this Class is for doing everything related to file opening Saving reading whatever you need to do so as you can see here, there's a function which is open and This open function which let's go to it Open it means two arguments one is the path of the file that you want to open and Another one is the flags when they say here flags you have to search on the documentation of The same class what do those flags do in this case? These are the mode flags which are read one write two read write three and write read seven Okay, so let's create a New class. Let's call it F for the file You can create a class like so and now we're gonna open the file that we want to Start doing things with which will be file open And now we use the path that we already have and we just want to read it So we will go ahead and use the number one for the flag Then When we have everything open we want to get the text from that dialogue From that file to the text edit node so for the text edit node The variable text We're gonna say it to and now you can use an inbuilt function, which is F that Get as text this will read the file that we already opened and It's gonna read it as a test string and we're gonna set the value of the text edit to That string. Let's try it out. Let's see if it works We open a file and we select for instance the same script that we are editing right now and we have it here You should be the same Same as we are opening we if we want to open another thing like the product that got out You know, you can already see how this is working. So now let's go ahead and do the same file function We're gonna you be using it as save us Just for safety reasons, but yeah, let's go for it Let's rename it to save us The difference between save and save us is basically that if you use this save us You will set the name every time you save it But if you do save we can overwrite the file and that can be a problem for this test, but you can do it as you wish It's gonna be the same here on the same file dialogue when we get the file selected Let's connect this signal and now here we have to Code the logic for saving that information into a file, which is gonna be pretty similar so we get a new file and We're gonna open it with the same path and instead of doing the reading Flag we use the writing flag. This will give us permission to write things into that file This is for security reasons most of the time if sometimes you want to just read something You know, it's better to use the proper flags Otherwise, you can use the read and write flag which will allow you to do both, but it can be tricky sometimes Now it's basically instead of Getting the text and To onto the text edit node getting the text from the node to the file so how you do you do that basically you get the Inbuilt function, which is called a store You see here a lot of different ways of storing, but we want to use a store string Which will be basically be saving that information and we get the information that we want to save Which is the text from the text edit Okay, this should be enough. So let's make the test Now if I write hello This is a super nice Text editor Okay, we have here our super nice text editor. We're gonna save it as Hello world that Super awesome Text editor This is our file extension Okay You can write whatever you like here doesn't matter for now Okay, and it should be Saved, let's see You're gonna close everything started all over again. Let's try to open it Here, it's our file the file that we created before and Yeah, we can save it. Okay Let's see that we want to modify something we delete everything we do the numbers It's gonna save it you can select here. Everything works as you intended to even like the file exists Do you want to override? Yes Okay, so Yeah, we ended up with a very basic text editor They can open files You can save them modify things now that you can even like create your own code here If you want to let's see that's gonna overwrite this code. Let's see. Yeah, you see the changes are working here So you have everything? You need for that basic purpose and you only needed a few signals a few nodes For the next episodes, we're gonna cover other stuff that are really relevant But if there's something that you want to see Please remember to leave a comment You know, you can reach me anywhere on Twitter on Reddit here on YouTube and Yeah, thank you for watching and until the next one


So we are back with another How Divers 2 video and today guys we have some very very interesting leaks to go over and talk about We have May's brand new warbond to check out while what's possibly May's warbond We have an accidental leak from arrowhead in regards to the illuminate We have interesting mentions in future subtitles in regards to Research points as well as increasing your rank. So let's go guys Now the winner of my previous How Divers 2 2100 super credits giveaway is seen on screen now If this is you hit me up on my discord link down below now Do you guys want to win 2100 super credits or this game if you're yet to own it? It's simple liberate this video very massive thumbs up Make sure you are subbed with those post notifications turned on and leave me a comment down below Winners will be picked from my comments section and announced on tomorrow's How Divers 2 videos So let's go people. Okay. So first up we'll check out the Accidental Inclination that the illuminate are eventually coming. So keen-eyed players noticed that on their website They spotted it saying that the illuminate are invading and you'll see in this image on screen now They can see the illuminate image right there guys where we are failing mantis That's how that is pronounced. Well, what this was this is actually a bug Which the devs actually owed up to because it is a little snippet from discord right here guys your site say illuminate are evading And so the guy says I was about to say and then we have a dev or a mud saying awkward and now fixed now What this obviously means is eventually guys as we all know that the illuminate are coming Placeholder symbols are already in the game. They're already making mistakes in regards to the illuminate taking advantage and taking over planets So it is just a matter of time until we actually eventually see that we will have to fight off against the how Divers 1 faction of the illuminate and we all know these guys in that leaks We have seen from the game files over the past month or so The illuminate are definitely coming and they look absolutely bad ass and I cannot wait to take them on head first Okay So we're going to move on guys and next up we have some data mined sub titles Which do for sure insinuate some interesting things to come mostly Research points how diverse classes citizenship points and your overall Rank so you're seeing these on screen now guys these are believed to be future Sub titles that will hit the game now. They ain't all here There's a few of these that are cut off But what you can see here what interests me is spend a research points to progress your desired how diverse class Missions are chock full of points of interest increase your rank to earn research points I earned a few more citizenship points the other day research points are used to progress your how divers specialization and to access certain rate and it cuts off people we see yes Bend research points to progress your desired how dive a class a game at a dark fluid research facility on Maradesh Went into emergency shutdown following what officials are describing as and then we see the super citizen Research prize for science has been awarded to the brilliant researchers who developed their revolutionary chemical We have increased your rank to earn research points Research points are used to progress your how-diver specialization and to access a certain rare that's cut off a game Now this all does fall in line with the certain new sample symbols We've already seen we've also seen many many new icons added into the game files Which do insinuate and do kind of look like? ranks and rank icons and things of this nature But I definitely do feel I think probably later rather than sooner that we will see a kind of rank system added into this game Which is pretty cool. Yes. We all know rank 50 is a match ranked right now But we don't matter things they have planned for this game if we do listen to these leaked and data-mined files There's a ton of stuff to come so adding in a rank system like a prestige system does make sense And what we are seeing here guys also makes sense to coincide with such a system now I didn't play how diverse one but as far as I am aware I do believe research points were a part of that game too So if you guys did play how diverse one and can let the rest of us know how this sort of system worked That'd be cool. Let us know down below within that comments section But yes a very very interesting things indeed Okay, so next up guys We have another major data mine by the legendary mouse TTV Now what he states is April's warbond theory, but actually this is maize We all do know what April's is going to be this is maize as well as new Models which go with which is believed to be the whole premise and theme to this new warbond And it looks pretty cool. It's believed and people are theorizing that we will get a new primitive planet as well as Primitive styled and themed weapons and from the models you will see in a quick second as well as the armor It definitely makes sense So we are seeing here guys this weapon right now Which looks like a pistol of some sort and it is just a bare basics model as it is right now We need to wait for iron sights to fully texture this but right now this is all we have In regards to this what possibly a warbond weapon But what we're seeing here guys is definitely of that primitive nature with those teeth strapped to the front of it Looking pretty cool. Now if we go on to the next weapon, we have this Sniper which again to me it's got that primitive design around obviously we ain't seen the texture of the weapon It's blank right now, but that could be completely themed and designed around I don't know bushes and things of that nature, but we also do see guys the teeth hanging from the front And if we look at the bipod, we can also see there is a length up on to teeth So yeah pretty cool We also see this new grenade to not many details on it But we see no spikes so this could be tied in with this new warbond But we also guys see this arm and this is an armor piece that we saw probably about a few days Actually saw this I think probably about a week ago now But if you look at this guys this screams to me primitive as well look at that necklace around his well around his chest His neck that chain necklace all those teeth falling while in line with what we just saw in regards to those weapons So yeah, this definitely could be a new warbond And this could be a primitive set a primitive warbond with what's been theorized as May's new warbond No, so this armor game and seeing that right here guys. It's the image I saw quite a while back And we also see now another type of new grenade whatever this is. We see this pistol right here This is a could the plash three pistol that was seen in the text Now this may not be tied to this warbond, but this is also another league dropped by mass TV all on the same post So it may as well check it out while it's here, but this is looking pretty badass, too Definitely screams arc weapon to me for all those well coils on the top But then again plasma kind of makes sense. We then see what looks to be a Nova pistol But to me, I don't know this could be the bare basics model of weapons in the game right now We just don't know guys. I mean it just looks so basic and standard. So yeah, we also then see this guys here This is a basic gun which is believed to be a weapon where you can swap in and out attachments So that's very very interesting. It does make sense again with the data in my files We have seen in regards to weapon customization and being able to swap in and out attachments And things like that. So yeah, this does make sense. We then see a couple of iron sights Which again could go along with this weapon Now these actual individual pieces in the game files. We don't just see iron sights evil We've seen mags and grips and bipods and barrels and things like that. So yeah, it isn't just iron sights We are seeing we've seen plenty of other things already But yes there we have it guys through another how diverse to a video of any more information drops in regards to future content leaks this that any other you guys know I will have you covered right here on my channel So yes, make sure you subscribe if you haven't already but I'm not know the end of the video has arrived If you enjoyed it leaving a like really helps out if you like what you see I want to see more be sure to subscribe And hopefully guys I will see you on that next one


Okay, fair market value FMV This is the price at which the property would change hands between a willing buyer and a willing seller Neither having to buy or sell and both having reasonable knowledge of all the relevant facts now This is a great idea in concept that we use all the time in practice. It's quite difficult It's impossible to know because all property is unique. This is real estate. This isn't stocks That are the same so we can't really we don't know what that is. That's the problem So if you so if you allow fair market value to to be adjusted all the time You end up with with act with it with people making appraisals and stuff that are too high or too low depending on what they're trying To do so we have to use this in concept this idea of fair market value But it's not the easiest thing to come to when you're talking about real estate, which is all unique So sale of similar property on or about the same date may be helpful to figuring the fair market value of the property Figuring the debt the basis the basis for depreciation is the lesser of the fair market value of the property on the date You changed it to rental use or your adjusted basis on the date of the change That is your original cost or other basis of the property plus the cost of permanent additions or Improvements since you acquire it minus deductions for any casualty or theft losses claimed on earlier years income Tax returns and other decreases to debt so notice that thinking about the basis of personal property like a home can be a little bit complex because Unlike with rental property, we don't have to track the basis of the home as closely Oftentimes we it'd be good to do though it because when we sell our personal home We might be subject to a gain and we have to deal with that at that point in time But with rental property, obviously we depreciate the property so we track it pretty closely With a personal home, then you've got to make sure that you're you get the whole basis in there Right so the basis you would think would be once again The cost or basis of the property what you bought the property for plus the cost of permanent additions or improvements Big big things that you improved a new roof and that kind of stuff Minus deductions for any casualty or theft losses claimed on earlier years income tax return So if you had a loss that you claimed because it went down in value or something like that Which is less usual to happen and other decreases to the basis so for increase and decreases to basis You can see adjusted basis in chapter 2 example You originally built a house for one hundred and forty thousand dollars on a lot that cost $14,000 which you used as your home for many years before changing the property to rental use this year You added twenty eight thousand dollars of permanent improvements to the house and claimed a 3500 casualty loss deduction for the damage to the house So part of the improvements qualifies for a five hundred dollar Residential energy credit which you acclaimed on a prior year tax return because land isn't depreciable You can only deduct the cost of the house when When figuring the basis for Depreciation so the adjusted basis for the house at the time of the change in its use was 164,000 so we're talking about the house here. So one hundred forty thousand You built a house for one hundred forty on a lot that cost 14,000 the lot the land isn't depreciable. So we're talking about the building here So we're not adding the 14,000 as a depreciable component before changing the property to rental use you added 28,000 so 28,000 increase because you had permanent improvements to the house and claimed a 3500 casualty loss. So because we got a benefit from the casualty loss We're subtracting the benefit decreasing the basis part of the improvements qualified for a 500 residential energy credit So we're subtracting out the credit Okay, on the date of the change in use your property had a fair market value of 168,000 of which 21,000 was for land and 147,000 was for the house so the basis for depreciation in the house is the fair market value on the date of the change 147,000 because it is less than your adjusted basis of 164,000 so we have to take the lesser of the two so we had to figure out our Adjusted basis and then we're going to figure the fair market value They didn't go into detail on how you figured the fair market value It's basically and you know you could do an assessment an appraisal Let's see what rhymes with appraisal I mean to try to get the fair market value of related properties and that kind of stuff and then we're taking The basis of property is the fair market value because it is less than the adjusted basis Corporate is if you change your corporative apartment to rental use figure your allowable depreciation as explained earlier depreciation methods are discussed in chapter 2 of this publication and publication 946 The basis of all the depreciable real property owned by the corporative housing corporation is The smaller of the following amounts the fair market value of the property on the date you change your apartment to rental use This is considered to be the same as the corporations adjusted basis minus straight-line depreciation Unless this value is unrealistic the corporations adjusted basis in the property on that date Don't subtract depreciation when figuring the corporations adjusted basis If you bought the stock after its first offering the corporations adjusted basis and the property is the amount figured and won under Depreciation earlier the fair market value of the property is considered to be the same as the corporations adjusted basis Figured and this way minus straight-line depreciation unless the value is unrealistic Alright figure in the the depreciation deduction to figure the deduction use the depreciation system in effect When you convert your residents to rental use so generally that will be makers for any conversion 1986 Depreciable property on the books usually treat the property as placed in service on the conversion date Example your converted residents see the previous example under figuring the basis earlier was available for rent on August 1st Using table 2 2d see chapter 2 the percent for year 1 beginning in August is 1.364 percent and the depreciation deduction for year 1 is 2005 so in other words Once we've determined what the the the amount is the adjusted basis to put the property on the books at and the date to put The property that was converted from personal use on the books Then it's pretty straightforward in that we're doing the same kind of thing We did as though we bought the property right because the difference between purchasing the property and Converting the property is the fact that when you purchase the property You know generally pretty well when you bought it and placed it in service And you know generally pretty well what the cost is because you just paid for it when you're converting the property You've got this basis situation that you have to deal with it because you bought it or inherited it or got it in some way


Last class, we were discussing variance and covariance. So, the covariance of two random variables is defined as expectation of x y minus expectation of x times expectation of y whenever it is well defined. And we said that the random variables x and y are said to be uncorrelated if covariance of x y equal to 0. And we were in the middle of proving a theorem saying which says that if x and y are independent then they are necessarily uncorrelated. But the converse of course is not true we gave an example uncorrelated random variables may be dependent they need not be independent. So, I will state that the theorem I think I did not state it in very precisely. So, I will state the theorem more precisely today. So, you take this statement rather than the previous one and I was in the middle of the proof, but let me state the theorem properly if x and y are independent random variables with expected absolute x is than infinity and expected absolute y is than infinity. Then expected x y exists and covariance of x y equal to 0. So, this is the statement of I did not I stated it in plain English I think yesterday. So, this is the proper statement. So, all you need here is expectation of absolute x and expectation of absolute y being finite. Then in that case you are guaranteed that expected x y exists and in particular expected x y will be equal to expected x times expectation of y. So, it is generally not the case that if x and y have well defined. So, in this sense finite expected value it is generally not the case that expected x y is well defined, but if they are independent it is automatically well defined and in fact they are uncorrelated. So, this is the statement proof we started out saying proof we did it for a simple case. If x and y are simple we wrote. So, we had this kind of a representation a i a i o i big a i and y is equal to sum over i j equals 1 to m b j i b j. Then we wrote out x y as the double sum a i b j indicator a i intersection b j and then we argued that a i and b j are independent for all i and j. That was because x and y are independent random variables and then we were able to prove that x and y are in fact uncorrelated. Now we have to extend it for any non negative random variables. So, this is previous class. So, this was done. So, next suppose x and y are non negative. Now, what do I do consider a approximating sequence? So, consider let x n and y n be simple sequences of simple random variables such that x n increases to x and y n increases to y. Such an approximation always exists we know that. We can explicitly find such an approximation from below. So, I am obviously heading towards an application of the monotone convergence theorem. So, obviously then x n y n increases to x y agreed they are all non negative and increasing. So, x n y n is also increasing and it approaches x y correct. We have expectation of x y we have expectation of x y is equal to limit n tending to infinity expectation of x n y n y m c t. But, x n and y n are so wait. So, x n y n. So, the way you can do it is x n y n in your approximation are independent also. Because in if you just specifically take the you remember the how we constructed if you given any measurable function non negative measurable function g. The way you construct g n the approximating sequence you can show that x n and y n are also the approximating sequence are also independent of each other. Since x n and y n are independent by construction right this is what I mean right. So, with the way we constructed the approximating sequence you can verify that they are in fact x n and y n are in fact independent expectation of x y equal to. So, this will be limit n tending to infinity. So, you know that for simple random variables you shown that independent random variables are uncorrelated previous lecture. So, this will become expectation of x n times expectation of y n correct. Now, so this limit. So, this limit can be this is obviously limit expectation of x n time limit expectation of y n. Because both the limit exist right. Why do both the limit exist? Well it is actually because of m c t right. So, again by. So, you apply m c t. So, this is limit this time limit that right. So, the limit of a product is the product of the limits if when all whenever all limit exist, but here all limits do exist right. So, that will be equal to. So, this is by m c t again this will be expectation of x times expectation of y any questions. So, you proved it for non negative random variables. So, I have not assumed here. So, if you notice I have proved this is a very general proof right. I have not assumed that x is discrete or y is continuous or any such thing right. I have not assumed joint density I have not assume p m f right. It could be a very any general random variable x and y whenever they are independent they are uncorrelated. Well I have proved it for the non negative case when x and y are both non negative. If I have to deal with random variables that are possibly negative then I have to use x plus x minus right.  This is there in your lecture notes. So, I am not writing that down. You explicitly compute write x is x plus minus x minus y plus y minus y minus expand the whole thing out and then you can prove that. So, when x and y are independent x plus and y plus x plus and y minus they will all be independent right. You have to that you can show easily right because in fact that is a question in your quiz right. After all what is x plus x plus is max of x comma 0. Suppose you want to show that x plus and y minus are independent y minus is minus min of y comma 0. They are both functions of x and y. So, they must be independent right. So, all these guys will turn out to be independent x plus y plus x plus y minus x minus y plus x minus y minus right and then invoke this for non negative random variables and you can get it. Just write out the whole write out this product and you will get it. That is where you have to invoke this. If this were not true then you have some infinity minus infinity problems. Any questions? So, I have next going to talk about the variance of sum of two random variables right. So, we know that. So, if you have x and y are any random variables not necessarily independent or uncorrelated or any such thing. We know that expectation is always linear. The expected x plus y is always equal to expectation of x plus expectation of y. That is just linearity of integrals right. But the variance is not necessarily always you cannot always say that the variance of a sum of two random variables is sum of variances right that is not true. So, I will just state a proposition that says x and y are random variables. Then sigma x plus y squared is equal to sigma x squared plus sigma y squared plus twice covariance of x comma y. So, if you are interested in computing the variance of a sum of two random variables. Then you have to sum the two variances and add twice the covariance. But if x and y are uncorrelated you can just add the two variances. So, if x and y are in particular independent you can add the variances and say that is the variance of the sum. Similarly, for n random variables how do you think this will generalize. If you had sum of n random variables you will first sum all the variances plus you will have all the possible covariance twice all this covariance x i h j for all i less than j right you have to sum it like that. So, it generalizes in a straight forward manner. So, this proving this is very easy right you can just write out. So, what is this this is after all expectation of. So, this is expectation of x plus y squared minus yeah. So, let me do it like this minus expectation of the expectation of x plus y the whole squared right great. Now, this is equal to this. So, this is equal to that that is equal to you can just expand this guy out right. So, expectation of x squared plus y squared plus 2 x y minus expectation of x squared minus expectation of y squared well. So, what I mean here is expectation of x plus y the whole squared. So, this is expectation of x plus expectation of y. So, then I will get minus 2 expectation of x expectation of y right. So, then I have what I want right. So, this and that will combine to give you variance of x that and that will give you variance of y.  So, this is this will be equal to that right. If x and y are uncorrelated you will have this term will cancel with that term. So, you will have just the sum of the variance. So, that is just a minor point. So, generally if you are given independent random variables or uncorrelated random variables you can add the variances and say that is the variance of the sum. But, generally you cannot do that you have to have all these covariance terms. So, if covariance of x y is something positive the variance will only be greater right. But, if it is a negative correlation the variance will actually be less than the sum of the variances. Variance of a sum will be less than the sum of the variances if they are negatively correlated. So, that is just a minor thing right. I want to make another definition the correlation coefficient between x and y between x and y or y and x it is all the same is defined as o x comma y is equal to covariance of x comma y divided by sigma x sigma y. These are the standard deviations the square root of the variances or you can take it as covariance of x y by square root of variance x square root of variance y. So, this is called correlation coefficient between x and y. So, in some sense this is a scaled version of the covariance. So, it is like saying. So, this is somewhat scale invariance. So, if x and y you are measuring x and y in let us say kilo grams are supposed to grams right you will get different answers for the covariance. But, rho x y will be the same no matter what units you measure x and y n it is like a scale free thing the most important thing about this rho x y again rho x y can be positive or negative right. So, these guys are always the denominator is always is always positive of course, assuming all this is not 0 right is not defined when the standard deviation is 0. But, if the standard deviation is 0 then the variables are themselves the random variables are themselves constant right. So, except in that case this is well defined and this is positive and covariance could be positive or negative right. So, rho x y could also be positive or negative it can in fact be 0 also right. So, the important result about this correlation coefficient is it is a number that lies between minus 1 and 1 always. So, in that sense it is a scaled down it is a very it is a nice way to represent the covariance the correlation between x and y. Because, it is a it is a kind of scale free kind of a thing theorem is Cauchy Schwartz inequality for any two random variables x and y minus 1 is less than or equal to rho x y is less than or equal to 1 further. So, this is. So, this is saying that the correlation coefficient lies between minus 1 and plus 1 both inclusive further more we can in fact say that whenever the correlation coefficient equals plus 1 or correlation coefficient equals minus 1 there is a deterministic relationship between x and y further. If rho x comma y equals 1 then there exists a greater than 0 such that there exists some real number a greater than 0 such that a y minus expectation of y equal to a times x minus expectation of x almost surely. If rho x y equal to minus 1 then there exists a less than 0 such that all that. So, the theorem clear. So, this is saying that correlation coefficient is between minus 1 and 1, but whenever it is equal to 1 then y can always be written as some a x plus b for some constants. You can think of just this as a x plus some other constant and similarly if rho is minus 1 then y is equal to a x plus b where a is negative. So, there is a deterministic relationship between x and y whenever the correlation coefficient is plus 1 or minus 1. So, when that is not case that is not the case it will be strictly between 0 and 1. So, this is called Cauchy Schwarz inequality another way of saying that is absolute covariance of x y is less than or equal to sigma x times sigma y. Another way of saying the Cauchy Schwarz inequality is to say that absolute rho x y is less than or equal to 1. In other words absolute covariance is less than or equal to sigma x times sigma y. So, this Cauchy Schwarz it has a very short proof, but you have to know it there is it is a little bit difficult to I mean you have to know how to proceed with it, because I mean I am just going to copy what I have here. So, you have to do the it comes in 2 steps, but you have to know how to do it. x tilde equal to x minus e x and y tilde. So, it is easier to work with the centered versions of these random variables I am just taking away the mean. So, that these guys are 0 in expectation 0 mean random variables and all this is a little bit easier, because then you will have y tilde equal to a times x tilde and so on. So, with 0 mean random variables all this is very easy let y tilde equal to y minus e y. Now, I want to show consider this this is what you have to start with. So, with this definition expected x tilde squared will be variance of x and similarly expected x tilde y tilde will be covariance of x y. So, you consider expectation of this big expression expectation of x tilde minus expectation of x tilde y tilde over expectation of y tilde squared times y tilde this whole squared. So, I mean. So, this is actually just a constant this whole thing is just a constant and in fact, what is this. So, this is like covariance over sigma y squared is not it. So, I am just considering this. So, I am essentially considering x tilde minus some constant times y tilde and I am considering the squared expectation of that. Now, this is certainly non negative why because what is inside is a non negative random variable. So, this is certainly non negative. Now, it turns out that if you expand this out you get course is worth in equality. So, let us expand this out well let us see. So, this is this will be like expectation of. So, this is work out. So, this will give you expectation of x tilde squared. So, if you do this you will get it. So, it is a big messy operation. So, you will have this squared times expectation of y tilde squared. So, should we just do this quickly x tilde squared plus expectation of. So, this will squared is not it will square. So, I will get expectation of x tilde y tilde squared over expectation of y tilde squared. I will have expectation of y tilde squared whole squared, but then that will cancel with expectation of y tilde squared coming from here. I am taking x square plus y square minus 2 a b if you like. So, then I will have a minus 2 a b term that is minus 2 x tilde well. So, I made a mistake here. So, finally, I think if I do that. So, far I am I think. So, then I will put an expectation here minus 2 expectation of x tilde y tilde right. So, that much times expectation of x tilde y tilde over expectation of y tilde squared. I think this is correct any mistakes fine. So, I am taking expectation of x tilde squared plus expectation of y tilde squared times this whole squared. So, that is what this is. So, you will have 1 cancellation here minus 2 expectation of x tilde y tilde times that constant. So, I have. So, I have this guy squared now right. So, this works out to be I think this works out to be what I want right this is. So, I will have. So, for 1 for 1 of this will cancel this 2 right I mean this is exactly the same as this is not it except for the 2. So, I can just get rid of I can just get rid of that guy and get rid of the 2. So, I think you will agree with that. So, I think that that is all I have that is all I want right. So, this is greater than or equal to 0 right which means I have bring this to this side you have expectation of expectation of x tilde y tilde squared is less than or equal to expectation of x tilde squared times expectation of y tilde squared correct. So, this is. So, which means the absolute. So, if you take square roots positive square roots on both sides you get absolute covariance less than or equal to sigma x times sigma y right. Because, this is sigma x squared and sigma y squared right. So, you would have prove in the inequality. Now, how would you how do you prove this bit? So, this is greater than or equal to 0 is for this. So, this is greater than or equal to 0. So, now you have. So, if you have absolute rho x y equal to 1, then which that means that this is met with equality correct which means that is met with equality eventually correct. So, I have the expectation of a squared this whole thing squared equal to 0 which means x tilde must be equal to some constant times y tilde which is what you wanted to prove correct. In fact, you can identify the constant A as that guy correct. Is that clear the second part of the theme? So, essentially we are saying that this random variable inside this squared must be 0 almost surely. So, which means almost surely y tilde x tilde must be a constant times y tilde end of story which is what we have which is what we wanted to prove right or may be I will have it the other way right. I will have x tilde equal to constant times y tilde which is same as saying y tilde square some other constant times x tilde. Are there any questions? So, I am getting to that. So, the question is in you know for. So, you know that if you have let us say vectors in Euclidean space. There is a standard definition of inner product and right inner product x y between 2 vectors and you know that for 2 vectors in Euclidean space there is this Cauchy-Schwarz inequality which says absolute inner product of x y is less than or equal to square root of norm x times square root of well norm x times norm y right yeah norm x times norm y. So, this has a very similar flavor to it right in particular what happens is that this covariance of x y plays the role of a inner product and this in some sense the sigma x and sigma y are playing the role of the norm right except these x and y are not vectors in R and they are random variables correct. So, this covariance satisfies all the properties of a inner product namely. So, what are the properties that you want of a inner product? You want symmetry right inner product x y should be equally inner product y x right. So, that is clearly true covariance x y and covariance y x are equal right by definition they are equal right and then what do you want you want bilinearity right bilinearity. So, if you have inner product x plus b y inner product with z you want to become linear which is also true for covariance right and finally you want. So, and then you want so then you can prove Cauchy Schwarz holds right Cauchy Schwarz obviously holds there is one little thing that remains you want inner product x with itself is always greater than or equal to 0 correct and equality holds only if x is equal to 0 that is a property of inner product that is one of the defining properties of an inner product correct. So, what is if I claim that covariance of x y is in fact behaving like an inner product I want to establish that covariance of x comma x is greater than or equal to 0 correct. So, what is covariance of x comma x yeah covariance of x comma x is simply the variance of x is not it. So, that is greater than or equal to 0 no problem but if the variance equal to 0 you have to show that x is equal to 0 is that true x is equal to. So, x is equal to you cannot say that x is equal to 0 you can say that x is equal to constant, but even x is equal to constant you can only say for almost surely right. So, there is a little bit of a there is a little bit of a problem here. So, for one thing you can do is you can just consider 0 mean random variables right just consider the you can think of this x and y is all 0 mean random variables. If you have non 0 mean you just subtract it off right with the finite mean as long as it is finite you just subtract it off. So, you work with only 0 mean random variables then this problem kind of goes away right. If you say that covariance of x comma x is equal to 0 that means x is equal to no 0 almost surely because you are all 0 mean random variables, but again you have to have this problem it is not really 0 random variable it is it could be non 0 in some set of probability measure 0 right. So, ultimately you have to consider the equivalence class of random variables which are which agree on except agree everywhere except perhaps on a 0 measure set right. If you are willing to consider that equivalence class as the 0 random variable right if the set of all random variables are equal to 0 almost surely as if you identify that as the 0 random variable the equivalence class of 0 random variables then you have a then everything is fine right except for this little adjustment then this is fine right. Then you will in fact have that covariance of x y place the role of a inner product in the space of 0 mean random variables correct. And these guys are like norms right and then you have a Cauchy Schwarz inequality holding and what is. So, what would you identify rho x y as. So, what is inner product x y is it the cosine or cosine square the cosine of the angle between the vectors right. So, this is like the. So, rho x y will be like the cosine of the angle between these 2 random variables you can think of this is. So, x and y are you can think of them as some vectors although they are random variables. So, this rho x y has the interpretation of cos theta in some loose sense right. So, in this can be made more precise everything I have said can be made more precise. So, if you consider the class of random variables with 0 mean and if you are willing to identify this almost surely constant random variables as simply 0 then you can prove that these 0 mean random variables with of finite all this well defined right. For example, variance should be finite and so on right whenever variance is finite this forms Hilbert space have you heard of a Hilbert space.  They are in particular they take values in R in R case right. So, you can prove that these finite second moment random variables with identifying this equivalence class to 0 right form a Hilbert space it is called L 2 L 2 random variables. They have finite second moment and in this L 2 space which is a Hilbert space this this play this row x y place the role of cos theta and cos theta equal to 0 means x and y are orthogonal right. So, uncorrelated random variables are like your orthogonal vectors. So, this interpretation is quite useful in many areas I mean in particular in estimation theory this place a this interpretation is very important. So, I did not I mean I did not make this very rigorous, but I just spoke it out, but I hope you are roughly with me on this. This can be made much more rigorous are there any questions. So, you can remember so what the take home is that there is this finite mean random finite second moment random variables these well defined this is there lie in the space called L 2 which is a Hilbert space and you can define in a product cosine all that is you can do I will stop here.


Hi, I'm Zor. Welcome to a new Zor education. Problems. That's the ultimate goal of this course, solving problems. So, today I will solve a few problems which are general systems of equations, general in sense that it's not really like linear or quadratic. There's something, basically, whatever somebody's mind is set to present them. Now, obviously, you have to really try to solve these problems yourself. That's some kind of a requirement. And I will show you my solutions to these problems. Your solutions might be different, better, worse, whatever, but I do encourage you to try to spend some time and solve these problems. All of them, as usually, are on unizord.com. So, this is in a topic which I called problem number two of general systems of equations. Okay, three problems. I'm going to present them and solve them. And then, you can compare your solutions to mine. All right, problem number one. p square root of q minus q square root of p equals 2. p square q plus q square p equals 20. Okay, as you are solving problems, you probably have to develop certain feel about what does make sense, what doesn't make sense to do with equations or systems of equations. Now, in this particular case, I just don't like the radicals. I don't like square roots.  And I do hope the solutions are nice, otherwise I wouldn't probably give this problem. So, my first thought about this particular system would be to raise the first equation to the power of two. Now, why? Because this will be square of the first, which is exactly this one. You see p square q. This is exactly the square of this one. This is exactly the square of this one. So, it might actually reduce certain things by subtracting afterwards. So, first of all, let's just raise to the power of two. It would be p square q minus two pq square root of pq, right? The product of these two. Plus square of this, which is q square p. And this is equal to four. Now, the second one, I will leave as is. Now, obviously, what actually prompts us is to subtract one from another because these will be basically deleted. So, if I subtract from this, I subtract this. I will have 16 on the right. And on the left, I will have basically two pq square root of pq. That's what I will have. Well, is it easier? Well, obviously it is easier. Why? You see, I can actually get the pq from it. Well, this is pq, this is square root of pq. So, basically, if I will square all together, I will get four pq second degree and the first degree cube is equal to square of 16 is 256, right? So, pq is equal to 64, pq cube, right? So, pq is equal to what's the four, right? Four to the cube is 64. So, I have pq is equal to four. All right, that's good. Now, what change do I have now? Well, this second equation can obviously be rewritten as this. And since pq is equal to four, pq is equal to five, right? So, this is four, so this is five. So, now I have a very familiar kind of system of two equations. p plus q is equal to five and pq is equal to four. Now, this is something which is like classical system of two equations with two variables. It's very easily converted into a quadratic equation because this is linear function of, let's say, p in terms of q, you substitute it, you will get quadratic equation. On the other hand, for every quadratic equation, you know that there are two solutions. The product of them is equal to the free member and the sum is coefficient at the first five. At the member of the first degree, so it's minus five x and x. So, this is basically a quadratic equation. Solutions of this are p and q, right? I mean, so it's basically classical theorem about quadratic equations. So, the product of roots is the free member and the sum of roots is coefficient at the first degree of unknown with an opposite sign. Well, and obviously I can guess the roots to this particular equation are kind of obvious. It's four and one, right? Two roots. The sum is indeed equal to four and sum is indeed equal to five. Well, you can use the formula. For the quadratic equation, you can use the formula. Alright, so I have four and one and obviously considering the symmetry, my solutions are either p is equal to four, q is equal to one, or p is equal to one and q is equal to four. These are two solutions to my system of two equations with two unknowns. Now, if you just look at this particular system, well, this is a multivariate polynomial of the third degree, right? Which is, you know, not obvious, and this one contains seven square roots of the unknown. So, it does look a little bit more complicated, but if you do the right thing, you basically come up with something relatively simple. That's basically what we are looking for right now, to develop certain techniques to see how you can simplify the problem from something which looks extremely complicated to more or less known problems and with no methodology to solve them.  Okay. Well, again, we have multivariate polynomial of the third degree, right? This is the first degree, this is the first, and this is the first, so together it's the third degree. Not typical. You can't really use one of the formulas or something like this. So, you have to think about what to do. Well, again, just let's look at this particular system, and well, I do see that xy is here and here. Besides these numbers, 24 and 48, they're kind of look alike, one is twice as much as another. I think, again, it's a good idea to divide one into another by another, and so what we will have? Well, if I divide one into another, now xy is here and xy is here, so it will be xy in the numerator and xy will be in the denominator, so it will be basically reduced, and it's not equal to zero, by the way, so we don't have any problem with losing any solutions. Why is it not equal to zero xy? Because otherwise, these would be zero, right? And on the right, we will have minus 48 divided by minus 24, which is 2. Well, this is much easier, right? Because this is kind of a linear thing. Again, 2x plus y is not supposed to be equal to zero, otherwise, again, this particular equation would not be equal to 24, so I can safely put 2x minus y is equal to 2 times 2x plus y, right from this, which results in 2x minus y equals 4x plus 2y, 2x equals minus 3y, right? So that's what I've got. This is good. It's simple, right? Now what I can do? Obviously, I have to substitute either x or y into this particular equation, one of those. Well, let's say I will choose y. So y is equal to minus 2 third of x, right? From this equation. And now I will substitute it to each one of those. Let's take the first equation, let's say. 2x plus y, which is minus 2 third x times x, and times y again, minus 2 third x equals 24. Well, that's easy. That's basically x to the third power times some coefficient minus 24. So let's just do it. So we have 6 minus 2, so it's 4x times x. Now this minus and this minus, so I will skip the minuses, times 2x divided by 3 times 3, which is 9, equals 24. That's right? So x to the third equals 4 times 2, 8. So I can reduce by 8 both sides. I will have 3 here and 9 here. So 9 times 3, which is 27. So x is equal to 3. x cubed is equal to 27, so x is equal to 3. And y is equal to from here, minus 2. And this is the solution. Now, I didn't do the checking in the previous problem and I'm not going to do it right now, but you have to understand that whenever you do all kinds of manipulation with these complicated systems, you always have to do the checking. All right, so I just trust that these are solutions because I actually knew it before. So just substitute and take the identities. So what was interesting here? You just notice x, y here, x, y here, so you divide it and that makes much simpler relationship. All right. And the last problem I wanted to present today is a square plus b square over a plus b equals 5. 1 over a plus 1 over b equals minus 1 half. That's the system. Well, what I suggest again is something which you really have to notice. These are symmetrical things. And symmetrical things, you remember this particular system of two equations, p plus q equals something and p times q equals something. This is kind of a typical example of a system of two equations which is very easy to solve. And if you can reduce your system into something like this, you will make your life much easier. So that's what I'm kind of aiming. I would like to do something like this. Now, what's pluses and minuses? Minuses obviously does not like this. However, there are some pluses. Consider a square plus b square, for instance. Well, this is a plus b square minus 2ab, right? a plus b square minus 2ab. It's a square plus 2ab and minus 2ab. So let's reduce plus b square. So that's what it is. So I can express this in terms of this. Now, obviously, this is already in terms of this. Now, how about this? Well, if you use the common denominator, which is ab, you will have a plus b on the top, right? b over ab plus a over ab. So it's a plus b over b. And again, we are expressing in these terms. So it looks like my life would be much easier if I will indeed do this.  And let me see what happens in this case. On the top, I will have a square plus b square and, as I said, this is p square, which is a square plus 2ab plus b square. So to get rid of 2ab, I have to subtract 2q, right? So that's on the top, right? So let me write it down. a square plus b square equals a plus b square minus 2ab, which is p square minus 2q in these terms. And that's what I can bring. On the bottom, I have plane p, which is a plus b. That's equal to 5. Here, the common denominator is ab, and ab is my q. And on the top, I have b plus a, which is p. Equals minus 1 half. Does this look simpler? Oh, absolutely. It's absolutely simpler. Now, this is basically a very simple thing because q from here minus q equals 2p. So q is equal to minus 2p, right? That's from this equation. Now, we can substitute it here. So 2q minus 2q is actually minus 2q is what? 4p, right? So minus 2 times q, that's 4p. So what I have is p square minus 4p divided by p equals 5. All right. Now, can p be equal to 0? Is this a plausible solution? Well, no. p is a plus b, so it's definitely prohibited here. However, here we have a plus b on the top, which is p. So we would never have minus 1 half if p is equal to 0. So we can definitely say that p equals 0 is not a solution. That's why we can basically reduce it by p because we will have p minus 4 equals 5. Oh, I'm sorry. It's plus 4. Minus times minus. Minus 2 times minus 2 is plus 4. So p plus 4 is equal to 0. Which is p equals 1, so p is equal to 1 and q is equal to minus 2. So that's what we have, right? Now, let's get back to what we have started with, which is this. What are p and q? So p and q are these. So what we have right now is a plus b is equal to 1 times b is equal to minus 2. And this is, again, a very, very much the same system of two equations with two variables. And, obviously, the solutions are x square minus x minus 2 equals to 0. The product of two solutions is the free member and the sum of two solutions to this equation is the coefficient at x to the minus sign. So the roots of this equation are a and b. And, well, I guess I can... So it's 2 and minus 1, right? So I just guessed. 2 and b is equal to minus 1. Or vice versa, a is equal to minus 1 and b is equal to 2. Now, both are solutions to original system of equations. Now, obviously, the symmetry between a and b is the course of this. So that's it. Yes, that's the right solutions. You can do the checking. As you saw in every system of equations which I have presented, there is something peculiar which you just have to see and use to solve the equation. Well, again, as I was saying, this is the purpose of all these exercises. And try to go through these same problems again if you didn't do it before. And good luck for any future problems. Thank you.