 Hi, can everyone hear me okay? Okay, so welcome back to The missing semester of your CS education today are having as a lecture topic property Which is it's gonna be some Miscellaneous combination of topics that we the instructors find they are interesting But none of them kind of warrant their own lecture because there are kind of like shorter topics that we just want you to know about because they can be again like really helpful and And Again since we're not going to delve into a lot of detail in the topics if you are more interested about them Just kind of feel free to come and ask us questions at the end or as we go over them in lecture So the first thing I want to talk about is keyboard remappings So and by now you'll probably realize that we have encouraged to use the keyboard as your main input method So for example when we went into the editor's lecture They one of the main ideas of BIM was using your keyboard as much as possible So you don't have to kind of rely on going to the mouse because going to the mouse is low And the thing is your keyboard as with many things in your computer is nothing kind of magical It can be configured and it's worth configuring because a lot of kind of the defaults might not be optimal They kind of the most simple modification that you can do is just remap keys So one of the things we alerted in the editor lecture is the caps lock key It's a really good key because it's kind of Drying the home row and it's kind of large and there but it's not useful Like you probably realize that you don't use your caps lock key as often is like when will you want to use that? So you can just remap your caps lock key to something more useful as we mentioned like escape If you're a BIM user or like control your emacs user Or useful remappings like a lot of the upper row like F function like the F key So like print screen you can remap them for example to your media keys So like when you type print screen that you probably don't have to do print screen that often But you probably want to play or pause your music and a lot of pretty much every Operating system has like some tools that you can use to configure this like they're likely I'm not going to go into the details But there's like some of them listed in the notes Let me check oh Yeah, the another thing that you can do with keyboard remappings are there you can do more Complex combinations you can have a combination of keys map to some action So for example, I have keyboard remappings that whenever I do Control enter I open a new terminal window because it's a thing I do fairly often and by default mag There's no key binding to do that or controls if enter will open a new browser window another Operation that I do on a daily basis. So I don't have to like kind of grab my mouse and go to Chrome do that And you can also do remapping to perform actions If you don't want to be typing your password all the sorry your personal your email or your password Or for example your MIT AD like you may not remember it by heart then you can just have like a keyboard Combination that will ex just perform the action of pasting that text Lastly there are like more like right now it looks more than like you just have to do some function of this is the keys That you press and this is the action that you happen But actually there are more complex keyboard combinations that as you go through you kind of learn So you can do kind of keyboard sequences So for example when we were dealing with team acts in team acts There was kind of this notion of oh first you press control a and then you all I control B Like you press some prefix and then some other key and that means something a lot of this software allows that So for example in my in my keyboard since I'm not using caps lock at all But every so often I have to use in my undergrad of some software that relied on caps lock for changing modes Then I have I can press shift five times in a row Quickly and then this this software that is in the middle interpreting these comments and remapping to some other we'll send a single caps lock command for that and some other examples of that is that I Mentioned that you can use your caps lock key like to map to escape or control But you actually can remap to both so in my computer when I just tap the caps lock key that is interpreted as an escape However, if I press it and hold it I can kind of this software can understand the difference between quickly pressing it and just Holding it for using in combination with some other key and then in that case is mapped to control So a lot of these kind of more advanced configuration is supported by a lot of these tools And as I mentioned we have a kind of a short list of good defaults For these programs for kind of Windows macOS and Linux Any questions on this topic? Okay, now I'm gonna cover Unrelated topic to keyboard mappings. We're gonna see a lot of these unrelated transitions in this lecture And it's the concept of demons So probably you haven't maybe if you're not familiar with the world might seem alien But the concept of demon you're probably familiar with like most computers when you are running them does like this software that you Kind of a start and run like the comments that we have been seen like you do like type LS And then you are calling the LS command the LS command executes because you ask it to execute and then it finishes But a lot of other programs are just running as background processes and they're just executing in the background and waiting for events to happen or enabling some sort of functionality in your computer and Examples of these processes might be like your network man Like the part of your computer that is managing the network or the part that your computer that is managing the display things like that and You will see that a lot of what is enabled by demons is usually programs that end with a D So for instance when you are SSH into a computer the receiving computer has to have SSH demon and the program is called SSH D And if this program is not running Then there's no way for me to SSH into the computer if the program is running then that program will be listening and when you do SSH that server The some incoming request is gonna enter the computer the computer is gonna send it to this Demon that is running in the background and then that the demon is gonna check whether you have authorization and if so is gonna start like some login cell that you can start securing from and Different OSes handle this is Somewhat differently they will use the many ideas They all have some sort of system demon that like spawns a lot of these smaller demons in Linux which is the one of the as I were choosing for a lot of the examples the tool that use your using is the System D again like for system demon There's gonna start a lot of these processes and if you use this system CTL command you can kind of check for the status of different demons You can check for which ones are running you can say you can ask the You can ask it to a start processes a stop them. This is kind of a once-off operation You can also enable it and did like disable them Which will tell the system to kind of run them at boot or like a stop running at the boot if they were enabled and Perhaps more interestingly you can configure your own system the units So so far kind of all the examples are a lot of what the computer has to do But say you want to run a web server like one solution You can just like every time you start your computer You could like open a team looks session and then execute the command But that's not really the way that kind of your computer specs demons to be run The way your computer specs demons to be run is by using some sort of system D unit It's like a configuration that tells system D how to execute this process. So an example of this is the Like here's a very simple example. So the what is happening here is we're describing To system D what needs to be done for this program to execute this example is just running a Like a simple Python app you can think of it as a web server like that can be implemented using some Python web server library And here we're saying oh, this is the description We're saying after like this is important system D has kind of a list of services that has to start like all these demons Have to be started, but maybe they are dependencies between these demons are here We're saying oh you should only start this after the network has been set up Because otherwise, how will you even try to configure a web server if I cannot listen to to a network port? And then we are defining what users will run this because you may want to run this as your user or maybe other user Or maybe the root users should be running this and then what come and to run and under what directory and Whenever you have this there's can be kind of all Small corner cases that you might have to debug But this is kind of the core idea and it can be really useful to automate the process of running processes in the background Small side note to this is the fact that if you just want to run a command every so often like on like in some periodicity like say every morning I want to do something in my computer you could write a demon that just like does something and that Sleeps for a day, but actually like Linux and macOS Has already a demon that does this that is called cron D and cron D Just will take another type of configuration file where you can say oh I want to run a Command every day at 8 a.m. Or I want to run a command every five minutes and it will just check for this event and execute them and With a lot of things you will find that there's already demons that have been configured for that any questions regarding So the the question is whether this Folder in the computer where all of these these are so yeah like Yes, I know there are some of these configuration files are in a couple of different folders depending if where there are system Demons for their user demons here. You can see at the very first line is where you will place this for the System demon to recognize that has been stalled But if you just want to list all the demons that is running in Linux For example, you can just do system CTL status and that's gonna print a tree of all the systems and which Pro which demon what was spawned by which other demon and a lot of them will be spawned directly by system D The next topic is gonna be file systems in user space So kind of a quick intro to this is the fact that whenever you're using a modern oh, yeah, sir and When you're using a modern operating system You are not tied to a specific File system, so like bonuses are fairly modular and you can for example in Linux They're like different file systems that you can use and the way this works is because the kernel which is kind of the the What is running most of the operating system has some modules that know how to interact with them With a file system. So usually when you do something like touch Fubar This is happening Are a user Level and then this is going through to the kernel level And there is some kind of layer here That is checking where this action is happening to figure out what file system is under So for example, you will have Multiple discs or the different discs have different file systems So kind of the kernel has to figure out which file system operations to use and say in This file might be in an EXT for which is the most common Linux one then whenever you do touch fubar The the kernel will hear that and then it will try to figure out like all these lips in an EXT for File system and it will perform the associated instruction for creating a file in an EXT for file system However, kind of the caveat of having a system like this is right now I cannot have user code that defines how to create a file and that might be kind of useful in some cases Say I want to have a file system that every time someone creates a file Sends me an email so I can like know the like people are creating these files here I cannot like modify the kernel to add this so the solution to this something called fuse and fuse is a Way of having file systems in user space So what fuse will do is if this file instead of being in If instead of being in EXT for if this file is in a fuse file system fuse will forward this operation to some other part of user code that will say oh Create this file and here I can have the part of the code that sends an email to me saying all this this file has been created and If in case you want to still create the file it can forward back the request to do some more kernel operations It might not seem really practical, but this is kind of just the theory in practice Why this is useful is because now you can have user level code that executes arbitrary actions when you try to perform file system operations a really interesting example of this is called SSHFS So SSHFS what does is whenever you try on an SSHFS fuse file system whenever you try to Create open read write to a file instead of trying to do that to a local file It has an SSH connection that to an remote server So if I try to create a file here It will use that SSH connection to forward their operation to the remote system and then it will perform it there so To all my local computer to the rest of the programs running in my computer There's this path the looks kind of there is here But all the operations that are performed to the path are kind of forwarded to the remote file system and with this idea you will there like some examples in the notes and you will find more online of Ways people have leverage this capability to do fairly interesting file systems So for example, if instead of having SSH, you don't care about SSH because you use like Dropbox or Google Drive It's fine. People have implemented fuse file systems that will mount locally and Every time you try to do an operation locally actually goes to one of these cloud storage providers So you can also use something like Amazon S3 or like Google cloud storage that don't have like the same kind of UI Systems that will kind of synchronize as Dropbox or Word Drive Other another application of this kind of that is not related to something remotely is something like an encrypted file system You may have a file system that every time you try to write to a file You will try to write it in plaintext, but it will capture their operation It will encrypt on the go and then it will save it as a regular file in your file system But that's actually encrypted and once you dismount the file system once you kind of remove the fuse connection all that is left in your computer are just like regular files are encrypted the last topic I want to cover is backups and how like some good practices about them and the Kind of the the the mini idea is that for every file that you care about If you don't have a backup of that file and you have like a backup story of that file You can pretty much lose it at any moment. There are like many different failure scenarios One of them is just hardware failure. So like your hard drive can fail at any moment So if you are just copying making a copy of your files in the same drive That's not useful. Like if your hard drive fails the files are gone The same goes may you have like an external drive where you are making a copy But if you're kind of storing everything in your home and your home burns down Which yes, it's unlikely, but if it happens you just lost all your data So you'll have some sort of off-site backup for having this solution Another kind of thing to take into account is that synchronization or mirroring options are not backups so Google Drive Dropbox that I was mentioning they will just kind of Propagate whatever is happening in your computer. This goes also for hardware mirroring like rate They're just making a copy if you accidentally delete a file or someone maliciously Deletes or your file or encrypts them using some front somewhere Then you might have a copy, but you have a copy of the same useless data You actually have to have a solution of how you're running your backups and you should be asking yourself What actually someone needs to know Slash half about you in order to delete all your data and we have linked different softwares in the in the notes about how to do this the The last thing I want to mention about backups is that a lot of the time when you think about backups You just think about their local files and like all my photos and all my tax return How can make a backup of that? But increasingly in the modern age there are more and more web applications and a lot of data might only live in some Cloud provider like for example, if you have webmail and are not synchronizing it to your computer it's only living in in that provider servers and If you don't have a copy for that and for some reason you lose access to that account because you forget your password You get hacked they think you have violated the terms of service all the data is gone So you should look into some tools that people have developed for kind of all like making offline copies of all the data so you can make regular backups of that and Kind of that ends the short section on backups any questions so far Any drive can fail at any moment like they like we don't like different Media have different kind of rates of failure and they're like really good statistics online So for example like it's been in hard drives have like a higher rate of failure than like SSDs for example I saw these state drives and It's not the case or like CD driver And But like for if you drop a hard drive, there's like a higher rate of failure of that failing of course but in general there's we don't really have like And all solution for saying all these media is not gonna fail like pretty much like SD cards SSDs hard drives CDs degrade with time much every data is kind of bound to this Decredition or like this fact that it could be lost at any moment and you also also know that like data can become Corrupted like your this my look that is okay But maybe some files were corrupted and something like synchronization techniques like Google Drive or Dropbox We'll propagate that corruption and by the time that you realize that things have go wrong. It's maybe too late All right, we're gonna continue this trend of jumping between random topics and talk about API So so far we've really been talking about how do you do things more efficiently locally on your computer? Like I want to accomplish this task more efficiently. How do I like configure my editor? How do I use my shell? But one thing you should realize is that very often you can integrate with the outside world as well Most services do you interact with in your day-to-day? Provide some kind of API for you to interact with the data that they store or the services that they provide and Usually those API's are pretty well documented if you look at the API's for things like Facebook or Twitter or Like Google Drive or Gmail many of these have interfaces that you can interact with in order to use those services from your local machine What's really neat is that you can often combine this with some of the stuff that we've talked about in lecture so far Like for example into the data wrangling lecture We looked at how you can create these pipelines to extract data from some source that has a different format than you expected so for instance the US government has a free service where you can request the weather forecast for any given location in the US and What you do is there is a URL that you request And if you set the right parameters in that URL and then just fetch it what you get back is Jason which is sort of a well-defined data format that you can then parse and you can extract things like your 14 14-day weather forecast and maybe you then pipe that into your shell and produce some kind of like handy alias in your terminal That's just going to print of some handy reference for the next 14 days of weather in whatever location you're in Right. These are things that you can pretty easily construct and there's some notes There's some notes in the notes about how you might go about this In general when you interact with these APIs You're going to be using URLs of one form or another and the exact format varies from service to service But in general the URL is going to contain some set of parameters But ultimately you're just going to issue a web request to them and you're going to get data back in some format One command you should be aware of for interacting with these types of things is one called curl So curl is a program that you invoke you give it a URL and it just fetches that URL and gives you back the response What you do with that response is entirely up to you. Maybe you pipe it through a program like GQ So sorry JQ so JQ is a Jason query tool that lets you take in data That's formatted as Jason and then write a query over it to extract data that you're interested in and This is one of the ways in which you can layer these tools to extract the data that you're interested in Some of these services also require that you authenticate in one way or another Like for example, if you want to interact with a Facebook API You need to have some authenticated token that proves who you are as far as Facebook is concerned Otherwise, they can't say whether you're allowed to say create a post as a given user very often these things are going to use something called OAuth although not always and You should look at the documentation for whatever service you care about in general though You will get some kind of secret token back from the service that you have to include in the request that you make to them either in the URL Or in additional sort of web headers, which you can also send with curl. Keep in mind though that these tokens are secret They are another representation of your user and anyone who gets their hand on them can basically pretend to be you They can do whatever you can do with that token So keep this in mind don't like stick them in your dot files and then like push them onto github that will land you in trouble You should think of them as a password There are also really neat tools online for integrating services. So there's a service called if this than that Which basically provides integrations with a bunch of different services and lets you chain them together And then also access them partially locally if you wish This is something that's worth looking into if there's a particular service You would like to interact with in a more efficient manner Any questions about apis? All right Switching gears entirely. Let's talk about command line arguments. So command line tools there are a lot of them and most of them take different arguments because they do different things We've talked about looking at man pages for commands and that will tell you how this particular command works what kind of flags and Options you might give to it and what it actually does when you invoke it But there are some common themes that are useful to know about in either in arguments that many programs take or just Concepts that many of them apply The first of these we already mentioned a little bit in the lecture on command line environments Which is the dash dash help flag very often you can pass this to a program and instead of running it will Just print out information about how you can run this program often in a very short condensed way A similar one is the dash dash version flag which just prints the version of the software you're using This can be really handy if you're doing something like filing a bug report Which Anish is going to talk a little bit about later and you want to report what version you're running on in case the bug has been fixed since Often you can also do dash capital V and that means the same as version, but again check the man page There's also dash dash verbose or dash lowercase v often Which is a flag that lets you increase the output of the program It makes the program print more about what it is doing and very often you can repeat this flag So you can do like dash V V V V V V V in order to get more information from that tool And this can be especially useful if you're trying to debug a problem If you're like running our sink and you want to know why did it decide to copy this file? Or why did it decide not to copy this file that kind of debug output can be useful and often there's a sort of an inverse flag Called quiet or silent which means that the tool will not print anything unless it was like an error Anything else it will stay quiet about Many tools especially those that do destructive actions or some kind of Action that you cannot undo Provide what's known as a dry run flag Exactly how this is represented in the command line varies from tool to tool But essentially what this dry run mode will do is it will run the tool But it will not actually make any changes instead It will just inform you of what it would have done if you hadn't run it with dry run Many of these tools also have an interactive mode So for example, the RM and move tools both do often just dash I although not always When you run a tool in interactive mode It will usually prompt you whenever it's about to do an action that you can't undo and it will sort of prompt you for a confirmation that it should actually go ahead When we're talking about Destructive tools many of them are non recursive by default if you try to remove a directory Or you try to operate on a full directory. They will not continue into the files inside of that directory The reason being you might accidentally like remove your entire hard drive and that seems bad Therefore for many of these tools, they have a recursed flag often dash R But again not always which lets them traverse down into the tree to go deeper But you need to opt into this behavior. So this is for example the case for RM This is also the case for copy in many tools when they ask you to give a file name or a path and we talked about this a little bit in the Data wrangling lecture instead of giving a file name. You can often just give a dash just a single dash What that means is standard input or standard output depending on whether that argument is an input file or an output file This is handy to know about if you're trying to construct those kinds of data wrangling pipelines that we've talked about before Many tools will also default to using standard in or standard out if you don't give any file name at all Sometimes you want to pass something that looks like a flag or an option to a command But you don't actually want it to be interpreted as a flag or an option Consider for example, if you wanted to remove a file called the dash I What would you do right if you write the following command? RM dash I Well dash I is a flag to RM. So RM would When you run this command would say tell me what file to remove you haven't given me a file And it's because it's interprets this as a flag similarly if you do something like SSH Some machine Some command and let's say dash R So this is saying run command foo on this machine over SSH And I want to pass dash R to foo Well, the way that both of these are gonna get interpreted is that these are flags or in this case This is a flag, but to this command Which is probably not what you expected Actually in the case of SSH it has some weird special behavior for some of these But often if you want something to not be interpreted as a flag There's a very simple way to opt out of that and that is using double dash If you use double dash what you tell the command is that everything following this You should not interpret So it will not be considered a flag or an option in the case of RM You can do this and now RM will see that the first argument is a dash dash and Then it will keep reading arguments, but it will not interpret them as flags So when it gets to dash I it will not interpret it as the dash I flag but just as an argument dash I Similarly for SSH You can do this To indicate that these are both positional arguments They are not flags or options and you should not interpret things to start with a dash No, so this is a dash dash with a space on both sides Yeah, any questions about any of this sort of command line conventions business All right, then let's talk about window managers So most of you are used to some kind of drag-and-drop window manager They they're like if you're running Windows or macOS or Ubuntu what comes with the machine is like there are windows and they overlap partially on screen and you can like drag and drop and move them around and resize them and stuff and That works fine But it is not the only way to manage windows on your computer. It turns out So what you are used to is something called a floating window manager, but not all window managers are floating Often you can opt into other types of window managers that have different behavior for how they arrange your desktop a Common alternative is a tiling window manager So in a tiling window manager rather than having floating windows Everything is set up into a tiled layout when you start a program its window is maximized If you start another program the original window Shrinks in size and then the new window takes up some subset of the total desktop space At no time is your desktop background visible unless you have no programs open All of the programs you have opened on any given desktop are gonna share that space This looks a little bit like T-Mux panes like we talked about earlier where you can sort of split them in various directions and One of the reasons why this is handy is it means you basically never need to go to your mouse Right in order to move between windows There are keyboard shortcuts to move to different windows There are keyboard shortcuts for resizing the windows or swapping them around on screen And this turns out to be a pretty efficient way to manage windows in your computer Well, I won't go into too much a detail of what kind of window managers you might use Just know that these exist out there and they're worth giving a look. They can be a lot more efficient to work with Question about window managers All right VPNs totally related to the previous topic So VPNs are like all the rage these days and this makes me really sad It's not clear the VPNs are all the rage for any good reason Because you shouldn't be aware of what a VPN does and does not get you a VPN in the best case Is really just a way for you to change your internet service provider? It's a way for you to make traffic on the internet seem like it's coming from somewhere else than when you actually are Well, that might seem attractive for certain purposes It's a little unclear what it buys you in terms of security because all you're really doing is shifting who you are trusting Rather than trusting who is providing your current internet service. You are trusting that whatever Business is giving you that VPN service. You're trusting that they first of all have set up this VPN business correctly But also that they are not tracking what you are doing Right, and it's not clear whether that change of trust is actually worth it If you're sitting at some like dodgy dodgy public Wi-Fi network, then maybe But if you're sitting at MIT, it's not clear Do you trust your VPN provider more than you trust like MIT's IS&T or maybe you do but but that is a Decision that you need to make about what you trust who you trust and why You should also know that Much of your traffic, especially stuff that's on a sensitive nature on the internet is already encrypted Whether that's sort of HTTPS or other protocols that use something like TLS a lot of the sensitive data is already sent over encrypted channels and it doesn't really matter who your network provider is if You're on a dodgy Wi-Fi network The stuff that matters is probably encrypted anyway Might not be but if it's not then your VPN provider can also see it in plaintext Just as much as whoever is hosting this dodgy Wi-Fi network and Notice that I said like in the best case above There are VPN providers who have been shown to be malicious that do logging of all your traffic That sell that traffic to third parties. There are VPN providers that have forgotten to enable encryption on the VPN All of these are real problems And so you should think very carefully about whether a VPN actually serves any good purpose for you questions about VPNs Yes So it's a very good question If you're on a public Wi-Fi network, then the traffic between you and the wireless access point is not encrypted At least it's not encrypted sort of on the outer layer But it might be encrypted in like HTTPS for example And it is totally true that people observing that Wi-Fi network will be able to see anything that is not encrypted But the solution to that is to encrypt all your traffic Rather than necessarily going through a VPN. So one way to do this for example is to use DNS over TLS or DNS over HTTPS Which gives you a way to actually encrypt even information that might otherwise leak in plain text Rather than try to sort of trust some provider to do that for you now that said like some In some cases you might have a trusted institution that provides a VPN network for you So for example MIT provides a VPN network for all MIT students and staff that you can sign up to use and in that case You probably trust MIT more than the other networks you might be on and so it might be worth it But it's something for you to think about So DNS is the way that people turn domain names or your computer turns domain names into IP addresses to know what computer to connect to And that protocol by default is play is in plain text. There's nothing encrypted about it There are various ways to encrypt your DNS traffic. Some of them are standardized and some of them are not I won't go into the exact mechanics here, but you should Google it and look at some of the ways Okay, the last thing I want to talk about is markdown So there is a high chance that some of you are going to write text over the remaining part of your life And you will want to mark up that text in various simple ways One thing you could do is start up Word or use latex or something like that to mark up your documents But that is pretty heavy-handed approach instead of be nice if we could just sort of Write things the way we feel like they should be I don't know how to describe it in a better way But sort of the natural way where if you want something if you want to put emphasis on a word You just put like stars around it or something and then it just works Markdown is essentially that it is a way to try to encode the way that we often write texts somewhat naturally Into a markup language that lets you write things like bold text links lists that sort of stuff In fact all of the lecture notes for this class have been written using markdown and markdown is really very straightforward The basic rules are in the in the notes, but the basic things you need to know is in markdown if you put Stars around a word that word is emphasized or some sequence of words if you put double stars That word is emphasized strongly also known as bold There are various other things you could do like if you put a dash before a line It is now a list and it's one list item and you can amend list items if you put one dot in front or some other number It becomes a numbered list If you put a pound sign in front of something it becomes a header Like some kind of title header if you put multiple of them they become subheadings and you can keep adding more to these If you want to write code you can put a single back tick followed by some code followed by a back tick and now that is rendered in monospace font if you want multiple lines of code you do a triple back tick and then code and Then maybe some more code and then triple back tick and In many cases like if you're on github for example You can even type the name of a language up here after the back ticks without a space And it will be syntax highlighted in the language of your choice This is a really handy thing that is supported in so many websites nowadays You might not even realize like in Facebook messenger. You can use many of these They don't actually officially say they support markdown anywhere But many of these things just like sort of happen to work and it's worth learning at least the basics and just start Using them how you can do links and stuff as well, but that's already in the notes Any questions about markdown? Right Anish You're up. It's my microphone working Is this working you guys hear me in the back the lights green. Oh, I think I can hear it. Okay Great So continuing with our theme of random topics that are all unrelated to the previous topics We've been talking about the next thing we're going to talk about is a program called hammer spoon Which is a tool for doing desktop automation on Mac OS And I think there's similar tools for windows and links So a lot of the ideas can carry over you can kind of Google it if you want to figure out how to do these things on other platforms But basically hammer spoon is a program that lets you write Lua scripts the scripts in a programming language that interact with various operating system functionality so you can write code that interacts with the keyboard and mouse and Connects that to window management to display management the file system battery and power management Wi-Fi all sorts of stuff Like basically all the things that your operating system manages this tool lets you hook into those things And so it can let you do all sorts of neat things by writing just a couple lines of code There's some examples of cool things you can do with this tool are you can bind hotkeys to move windows to specific locations So demonstration of this it's here have this window open I press in my particular setup Option command right and this window moves to the right option command left this window moves to the left And I have a couple other shortcuts for moving things to various places And so I can kind of have an effect similar to tiling window managers that John was talking about earlier I can move windows to different parts of my screen to set things up in a particular way rather than have to use the mouse to Position things where I want them to be and then like click and drag to resize windows to the right shape Just a keyboard short can do the trick But this tool is not limited to just moving windows around and binding that to particular keyboard shortcuts You can do other things like create a menu bar button with a bunch of different options You can bind those different options to do different things so in my particular case I've created this whole menu and then I have a bunch of different things that I do reasonably frequently and clicking on these things Invokes a particular lua function that I've written that interacts with this library. So for example Here this rescue windows thing is a particular thing where I often work with multiple displays And sometimes my operating system gets confused and I have some window that ends up kind of like off of my display And how do I how do I get the thing back? Well, that's what this whoops not that That's what this rescue windows thing does it brings windows that are off the screen back onto the screen Another neat thing I have set up here is I have particular layouts that I've named so like a dorm and a lab and a laptop layout So for example in my lab I have this screen and I have another screen and I have another screen besides that in a different orientation and I have this particular setup that I want where I want maybe my terminal full screen on here and my chat program over here and This screen split up into five segments with different programs in different places here I can when I show up to lab I can just go here and like click layout lab and it will invoke some code Which is not all that complicated like ten lines of code describes a particular layout and it will instantiate that layout and Put all the things where they need to go I Could even in theory automate some of these things where my computer could figure out like I plug in a display and my computer Knows, oh, this is the display that you have in your lab. Let me automatically instantiate this layout for you That's another thing you can do with Hammerspoon and also other wacky things you can do like you can do things like It can detect your Wi-Fi network that you're on so it knows kind of where you are Maybe I have a different Wi-Fi network name at home versus in lab and I can do things like when I show up To lab automatically mute my speaker so I don't have like embarrassing music play out loud in my lab Another kind of cool example is So I have a Mac it has a fancy power supply and a lot of my friends have computers that look the same as this and their Power supply bricks look the same as mine and sometimes I use their power brick because I forgot mine at home or something This tool can actually with like three or four lines of code Do neat things like show you a warning like it'll pop up a warning if you've accidentally taken your friends power supply And plug it into your computer instead of using your own so to high level this tool lets you run arbitrary Lua code and do things like bind it to menu buttons or key presses and Interacts with a large part of the operating system in order to do all sorts of cool stuff. So that is hammer spoon any questions about that Cool moving on to the next topic Completely unrelated to the previous one. It's booting and live USBs So the operating system on your computer windows or macOS or whatever you're used to is not exactly like the first thing That runs on your machine when it turns on there's something else that happens in the boot process before your operating system is loaded and There's some interesting stuff that you can do there So you might have seen when you turn on your computer It says something like press f9 to configure the bios or press f12 to enter the boot menu The particular key sequences may depend on your machine in specific configuration But this is a general pattern and you can configure all sorts of interesting hardware related stuff here So it's worth checking out and another thing you can do in this boot menu is you can have your computer start off from an alternate boot device So by default like my laptop here has a solid state driving at boots macOS when it turns on But I can also say plug in a USB flash drive that has an operating system installed on the flash drive and then at boot tell My computer to boot from that flash drive instead of the built-in solid-state disk and this is useful For example, if I've broken my operating system install And I want to do something like get the data off my computer or maybe want to fix the operating system Like maybe there's some critical file somewhere that I've deleted or I forgot my password I need to go like tweak some files in order to reset it booting from a live USB Booting from the separate operating system that's installed on a flash drive can let me do that like boot up my operating system mount the hard disk That's on my current machine I'm working on and then go make some tweaks or copy data off of that And so live USBs are really useful and in the lecture notes We've linked to a tool that can help you create them really easily Any questions about the boot processor live USBs? right next topic is Virtual machines vagrant Docker the cloud and open stack I think last year we had an entire lecture on this topic this year We're going to condense it into like one minute so at a high level virtual machines and similar tools like containers Let you emulate a whole computer system within your current machine. So like I'm running Mac OS here, but within my Mac OS Environment I can simulate a machine that's running say Ubuntu or some other operating system And this is a nice way of creating an isolated environment for testing or for development or for exploration For example doing things like running potentially malicious code that should be isolated from my current environment. I Think the most common use case for programmers is to use virtual machines or containers to create development environments So I'm using Mac OS and I have some set of services and stuff and libraries installed on my current machine But I might want for example, I'm working on some web programming project and I want it to run on a Debian machine and I need Postgres like a database server installed rather than install that all on my Mac OS machine I can instantiate this new machine just for this just for the development purposes Now virtual machines like that's a general concept. There are a bunch of programs that let you that are called virtual machine hypervisors that Support this functionality on your machine And then there are tools that let you script these hypervisors in order to specify machine configurations like operating system and like what packages you want installed and what services you want installed in plain text and so this is an example on the screen right here and This is done using a system called vagrant and You can it's linked in the lecture notes You can look into this if you're curious but basically in the short plain text file I can specify okay. I want a machine that's running Debian It should have Postgres and Redis and Python and stuff installed on it And then once I have this configuration I can just type in vagrant up and what it does is it reads this file and instantiates a new machine based on this configuration and Then after I've done that I can do vagrant SSH to SSH into this virtual machine So it's not a remote machine running on some other piece of hardware somewhere It's just simulated on my own machine But now here I have an Ubuntu box like I do I'll just be really stash a it's like or sorry Not a bunch of Debbie in here with all the things I want installed in here And I can do my development inside this isolated environment and not kind of install this junk on my macOS machine Now so that's vagrant. There's similar tools like docker that are conceptually similar But use containers instead of virtual machines. It's a distinction that we're not going to talk about in too much detail right now And so you can run VMs on your own computer But you can also rent virtual machines on the cloud and so it's a nice way to get instant access to like one example Is you might want to compute it's always on always connected to the internet and has a public IP address Like maybe you want to run a web server that's always available or you want to run some other service Like say a slack bot or something like that Well a virtual machine rented on the cloud is one nice way to get that and these are pretty cheap for like a low Capacity machine with a small CPU and small amount of disk space Another thing you might want to do is get access to a machine That's really powerful like with a lot of CPU cores or with a lot of RAM or with a whole bunch of GPUs For some specific purpose like so you're doing deep learning or so you're doing some other sorts of sensitive computation Well, that's another thing you can do with VMs on the cloud And finally you can get access to many more machines than you have physically physical access to like if I need a Thousand machines, but only for two minutes to do some very parallel task. That's something I can easily do with virtual machines and Popular services for doing this are things like Amazon AWS or Google Cloud And if you're a member of MIT C-Sale, you can also get free VMs for research purposes using the C-Sale OpenStack And so this is also linked in the lecture notes So any questions about virtual machines or a vagrant docker or anything like that? So the question is when I say I'm running Ubuntu or actually in this case is Debian When I'm running Ubuntu here, do I have like Ubuntu installed on my machine or what exactly is going on here? So basically what vagrant did for me when I typed vagrant up is Because I've specified I want Debian here it downloaded Debian from the internet like set up a disk image for this new machine Install Debian into that disk image then went to install all these programs So like yes, this is on my computer, but all of this is just in a particular file That's a disk image and then I'm emulating a machine that is basically completely isolated from my current machine This is being run as a process on my current machine Does that does that answer the question any other questions about VMs? great Next topic is also going to be a quick mention so a Lot of your programmers and you're used to writing programs and like a tool called like a tool like Vim or some other editor That you're comfortable with another thing that can be really need to use for particular tasks Is something called notebook programming environment and so this is a more interactive way of writing programs here on the screen I have a demo. This is something called Jupiter notebook and it can be used for writing Python programs I think they also support some other languages and Basically, this is a nice way of doing interactive programming So normally you're used to writing a big program in a file or a collection of files and once you're done writing it You can just run the whole program But this lets you be a little bit more flexible and run little snippets of code at a time like for example I can break my program into these little pieces It's just some random code I wrote and I can say execute this cell and I press a particular key combination to execute the cell But then I can go back and tweak my program a little bit like say I want to have this be lowercase instead and then I can execute this cell and then go and evaluate this thing and This way I can kind of run little snippets of code within a Python environment And it's a nice way of building up programs piece by piece rather than having to write everything at once This is really useful for particular research purposes like I think a lot of people use these for doing machine learning work For example, any questions about the idea of notebook programming environments? They're worth checking out Oh, so the question is this looks like it's online. Is there an offline version of Jupyter notebooks? So actually this is a thing that runs in the browser, but it's running locally So I don't know if you can see it on the screen because it's kind of small but up here. It says local host colon 888 Here I have Running on my own local machine a Jupyter notebook and it just they've just built it so it runs within the web browser That being said there are also online Jupyter notebooks that you can use where the Python colonel is actually running on some remote machine You might want to do this for example like on my laptop. I don't have a fancy GPU But in my room I have a machine with a fancy GPU and so when I'm doing machine learning work I often s s station to that machine run a Jupyter notebook on there and then open up the interface in my local web browser So I have access to that powerful GPU running on my different machine Any other questions? great The final thing we're going to talk about today is GitHub so we touched on this a little bit during the version control lecture But GitHub is one of the most popular platforms for open-source software development. It hosts source code It hosts git repositories, but they also have other tools for managing a project. So They're and like a lot of the tools we've talked about in this class are hosted on GitHub for example like camera swing the thing we just talked about is developed on GitHub and It's really easy to get started Contributing to open-source projects on GitHub to help improve the tools that you use every day and there are two primary ways You can contribute to projects on GitHub So let's open up some repository We can actually go to the GitHub repository for the class website. So this is an open-source software project and Let's zoom in a little bit So the two ways you can contribute to projects on GitHub the two main ways are through issues and pull requests So one thing that's actually really helpful to developers and also pretty lightweight and easy for users to do is to report issues With a software project like say you're using somebody's program You encounter some bug writing a high quality issues actually super helpful to developers and hopefully doesn't take you too much time And so you can go to here like find the project on GitHub go to the issues page and click on new issue And then write some high-quality bug report and then hopefully the developer will respond and fix the issue for you so for example for this class like one of the students in this class pointed out an issue with our lecture notes and After she pointed it out. I said, okay, like that looks like a reasonable thing Let's fix it and in this particular case instead of fixing it myself I actually asked this person do they just want to fix it for me And so that leads into the other thing I want to talk about so issues and pull requests so pull requests are the second way to contribute to projects on GitHub and This involves actually contributing code back to the project And so if we look at the pull request for this particular project You'll see that a bunch of people have submitted code changes and The process for doing so so this is showing the difference the patch that this person submitted Basically the process for creating pull requests is a little bit more involved in submitting issues Like you're not just submitting text You're actually going to modify their source code And so we've linked to some guides that explain the process a little bit more detail But at a high level what you do is you take the repository on github fork it and then download it locally So now if you're in local copy then you can go and work on it and do some development work and fix a bug or add a feature And then eventually you send what's called a pull request back to the original developers So you say here I've made some changes Can you please incorporate them back into the original project and after that point? What usually happens with these projects is that the maintainers will go back and forth with you giving you feedback on the changes you proposed and eventually once everybody's happy they will merge in your changes And they'll be available to everybody uses the project So that is how you can contribute to projects on github and make software better for everybody And so any questions about github cool. Okay, so that is it for the topics for today any questions about the lecture overall Great okay, so before before we finish a quick description about tomorrow's lecture So today was all the topics we thought are interesting We should talk about tomorrow's lecture is going to be about all the topics You think are interesting and that we should talk about so tomorrow's going to be a Q&A lecture and After today after the lecture we'll submit where we will email out a link where you can submit questions for us to answer And so please go and fill that out. Otherwise, we won't have too much to talk about tomorrow Great, so hopefully see you tomorrow in our Q&A lecture