From the course: Practical GitHub Code Search

Finding code to learn from - GitHub Tutorial

From the course: Practical GitHub Code Search

Finding code to learn from

- [Narrator] Let's go ahead and try another type of search. Now, this time I'm going to look for something, that I want to learn from. So I want to write a Dockerfile for one of my projects. I want to make sure that it is for a codespace's project that I'll be creating. So usually those go in the dev container and I want to learn from what other people have done. So I'm going to start by always resetting everything by hitting the GitHub icon. This will take you back to github.com and if you are already in a repository, it'll kind of clear out the previous search. Sometimes you'll find that even though you click on things in the interface, when you just go to another page, it'll reset things or leave some things in the search. So I find that I always love starting by clicking on this icon and it just clears everything out. So after that, then I hit the slash of course. And let's start off by looking for a Dockerfile and see what we get. All right, so when I do this, notice that it's assuming that I'm looking for repositories. That's not exactly what I'm looking for. In this case, I'm looking for code. It is smart and tries to make a decision about what you're looking for but sometimes it gets it wrong. So I'm just going to hit Code right here and it's going to show me some Dockerfiles. Now I noticed that some of these are in different places, right? So here's a circleci, which is a platform for continuous integration. I'm really interested in something for a codespace. So what I'll do next is I'll look over here on the left to see what's available. And first I'm going to choose the language to be Dockerfile, 'cause I did notice that sometimes it's picking up things like this DockerTests. This is just a markdown document talking about Dockerfiles. So I want to make sure that I hit Dockerfile here. That'll just give me the Dockerfile. Now some of these are in different places than I said, that I only won things in the dev container 'cause I'm assuming that it's related to how codespaces are put together. So I'll click on this path and you can see everything changing up here. And then I can take a look through this and I'm going to add a keyword to make sure that I'm only getting Python paths or Python Dockerfiles. So that gives me only Python Dockerfiles in the dev container with a language of Dockerfile to make sure that it's a Dockerfile that I'm talking about. So that's getting pretty good. I can look for some things down here that might be helpful. Let's see if we can sort of take a look at the Dockerfiles that my organization has done. So I'm going to look for org and as I look for that, it's showing me the orgs that I am subscribed to. So I'm going to click on LinkedInLearning and that's really going to narrow things down to like nine files. Now, occasionally you will make a search that it doesn't like. So let me show you what that's like. So I'm going to type in is, and I'm going to hit the colon here. So notice that it's saying that I can choose either archived or forked. So that's kind of cool. It lets you look for archived repos, which is something that you do when you don't really want to delete a repo, but you can archive it so that you can get to it later but it doesn't come up normally under search. What I really wanted though is to make sure that what I'm looking for is a public repo. So let's go ahead and type that in, is:public and it gives me this error. You've probably run into this already. This is what happens when you make a mistake. It tells you that this didn't match any code. Sometimes it gives you a warning and it's taken into consideration, the context of the type of search that you're trying to do. So it's telling you here that searching for this term literally is not going to work, right? And really the problem is this is public section right here. It's going to try to give you some suggestions on the type of things that you can do and you know, some hints about some of the other things that you can try but this is what you get if you try to do something that's not making sense for it. Now, I personally think that I should be able to look for is:public in this context but the current version of the search isn't liking that. So I'm going to have to back out and go back just to my regular search that I was doing for what I need, this is great. It's taken me right to some code that I can take a peek at to see how people in my organization have been creating docker containers to take a look at starting up a codespace. So this works for me. You may want to try this yourself and try to see, when you are trying to learn from a piece of code, what kind of searches work really well. And I think a combination of using, you know, qualifiers as well as using the interface is the best way to find things when you are learning from code.

Contents