DEV Community

loading...

Finding project names smartly

Saurabh Sharma
Web development React.js GraphQL Typescript JavaScript Design SEO
・3 min read

cover image

You need to write what you did before you forget it because you will eventually forget it
@wesbos didn't remember the exact words ¯_(ツ)_/¯

Long story short, I always sucked at naming projects and I used to name projects like node_mongo_react_app. Some are okay with it, but I always wanted something better.

You can still name your projects like 'random_number_generator'. they still suck, they are long and boring.

Thanks to @mpjme, I got a better way of naming my projects, "Find a codename of Intel chip and name your project based on it".

It was a great way until I thought, You know I'm a programmer and I can automate this. Now let me tell you how this whole idea came into shape.

Like all good programmers, I break the problem into many parts,

  1. I need a JSON list of Intel chip codenames
  2. I need a random number to find a random codename
  3. I need to make it available to the web.

For the first problem I tried on google to find a JSON list of Intel chips codenames, but I didn't get any. Now I had only one way to get that list, make the list by parsing Wikipedia page. So I tried to parse Wikipedia with cheerio and node.js but It didn't work for me. Then I tried python with Beautiful Soup. I need to say they were amazing I can now parse the page with ease but there was a problem still. I was getting the response something like:

<td>skyLake</td>
<td>rapid Ride</td>
<td><a href="blah blah blah">kabyLake</a><td>
Enter fullscreen mode Exit fullscreen mode

I rounded off the whole stack overflow to find the right way to extract just string from an HTML element but unfortunately, I got some answers that didn't work. The next way was to parse it using regex. but, I didn't know regex quite well. Now the hacky way was to replace the HTML tags from string and ignore those with anchor tag even after ignoring them I was left with 518 names that were more than enough for me. So I tried it.

After that, I just saved the output to a .csv file and then converted it to JSON.
Now I have JSON file and I made a python script to parse the JSON file and give a random word from the huge array list of Intel chip names.

Now, I have plans to make a web version of it.
But the dangle was, I never made a server in python and I will be a lot easier to just make a server in Nodejs. Fortunately, this was easy because I have the chip names in JSON. I have a choice to use a database or just have a file but I went for the weirdest version, use an array of words. It was really faster than database or file.

It hosted it on Heroku, here it is https://rapid-ride.herokuapp.com/. I didn't make a front end because I wanted to curl it. I made a function in PowerShell

function pr {
  Write-host (curl https://rapid-ride.herokuapp.com/).Content
}
Enter fullscreen mode Exit fullscreen mode

BASH guys you can do it too and pipe it to mkdir

Cool, it's now done. I'm happy that it will help me in finding names for backend projects of FreeCodeCamp.

Discussion (4)

Collapse
johnphamous profile image
John Pham

This is a great idea! Great job on the implementation.

Collapse
itsjzt profile image
Saurabh Sharma Author

Thanks 😁

Collapse
forsakenharmony profile image
Leah

Last time I was scraping a website I just used the chrome console, which worked well enough

Collapse
itsjzt profile image
Saurabh Sharma Author

using document.querySelectorAll('.names') 🤣😅😂