7 Majestic Days of Code Search
Early last week, I started a Twitter thread storm with the hashtag #7DaysOfSearch.
For seven days, I showed the beaming developer community how to search for code via the premier code search engine, sourcegraph.com.
It was a fantastic experience. I became aware of developers' hunger for better code search tools, so I decided to put all my tweets about #7DaysOfSearch in one place. A one-page reference for the #7DaysofSearch tweetstorm.
What is Sourcegraph?
Sourcegraph is a software tool that enables developers and anyone to search, explore and better understand code faster, with contextual code intelligence to improve developer productivity and automate large-scale code change management.
On sourcegraph.com, you can search for code from open source repositories.
With an account on sourcegraph.com, you can add private and public open-source repositories and search for code within those repositories.
#7DaysOfSearch Recap
Here's a full rundown:
Day 1: How to add open source repositories to Sourcegraph
With OSS projects indexed by @sourcegraph, you'll be able to use code libraries and dependencies more effectively.
It's also a faster way to summon code examples while building 😁.
Here’s how to add open-source software projects to Sourcegraph Cloud. #thread #7daysofsearch08:42 AM - 24 Aug 2021
Day 2: How to find error messages with Sourcegraph
Have you ever been faced with an error message while building software and spent a really long time trying to figure out where it was coming from? 🤔
What if you could paste the error message in a code search engine that'll show you where to look? #7DaysOfSearch17:46 PM - 25 Aug 2021
Day 3: How to add private code repositories to Sourcegraph
Searching code across your personal & organization private repositories is a very common activity. We all do it, but do we enjoy it?
The larger the codebase, the harder it is to search for code seamlessly.
I'll show how you can do that easily with @sourcegraph #7DaysOfSearch18:27 PM - 26 Aug 2021
Day 4: How to search code with Sourcegraph using literal patterns
Sourcegraph supports three kinds of search patterns: literal, regular expression, & structural.
By default, all search queries on @sourcegraph are treated as literal patterns.
If you know the exact string that you’re looking for in a codebase such as... #7DaysOfSearch14:40 PM - 27 Aug 2021
Day 5: How to search code with Sourcegraph using regular expression
When it comes to search, regex is not a stranger. It's well known for its pattern-matching features.
With @sourcegraph, you can search for code using regular expressions. Yup, you can do that! 😎 #7DaysOfSearch19:07 PM - 28 Aug 2021
Day 6: How to search code with Sourcegraph using structural search patterns
In previous episodes of #7DaysOfSearch, I covered literal and regular expression searches on @sourcegraph.
I'll show you how to perform a structural code search on sourcegraph.com. It's breathtaking and amazing! 🔥🚀06:59 AM - 30 Aug 2021
Day 7: Code search tips and tricks with Sourcegraph
To round up #7DaysOfSearch, I'll cover some of the search tricks you can use to search code on @sourcegraph. Let's go! 🔥🚀
1. Search code within an organization’s repository.
Let's search for how Carbon::now & Auth::guard is used in all of @laravelphp's repositories.13:28 PM - 31 Aug 2021
Quick Code Search Challenge
Sourcegraph has already indexed more than 1 million reports and is committed to indexing by the end of this year every project on GitHub or GitLab with one or more stars (~5.5 million repositories). So, armed with this information, I'll present a quick challenge!
Challenge: You need to get the top 5 GitHub OSS code repositories that use the navigator.sendBeacon Web API. How would you go about it?
Feel free to post your answer in the comment section or tweet at me (@unicodeveloper with the hashtag #7DaysOfSearch #SourcegraphCodeSearchChallenge
Wrapping Up
There's a lot to learn about code search. I just scratched the surface of what's possible with code search using Sourcegraph.
As a developer, designer and educational researcher, Sourcegraph provides enough flexibility and power to find code and resources to build your projects quickly!
Now, I have a few questions for you:
- What tools do you currently use for code search?
- What would you like to learn about code search?
- If you already use Sourcegraph, what would you like to see or know?
Furthermore, if you found any of the tips from the seven days useful, feel free to like & RT on Twitter. Would you mind dropping your best tip in the comment section?