I’ve Cracked the Code, Please Call Tech Support- Episode 18, The Last Command Line (But Not Really)
The database studies continue! That said, other than a couple of bumps in the road it has been a fun experience to learn. SQL is a very semantic code, which makes life a lot easier.
- If a user attempts to create a resource that already exists — for example, an email address that’s already registered — what HTTP status code would you return?
HTTP status codes are a way to communicate to the user that something either works (yay!) or doesn’t work (less yay.) with the website or resource that they are trying to access. Ever seen a 404 error? That’s an HTTP code that tells that the resource you want to access isn’t available.
If you’re trying to create or add a resource that already exists, like the email address in this case, it would return 409.
2. Consider a responsive site design that requires a full-width image in all responsive states. What would be the correct way to code this to ensure the page loads the smallest image required to fill the space?
In my experience, one of the best ways to make an image The best way to make an image reactive is to use a combination of media queries and minmax() in your CSS for the image.
Media queries allow the page to check what the size of the device’s screen is, and we can make adjustments appropriately (changing image size, font, etc.).
In addition, we can also use minmax() for our images width and height. This allows us to make many specific adjustments to our image, while also setting a range, thus allowing for flexibility. If you want your image to always be full width, you can set the width to be 100%, and you can either adjust your height manually, or let it be determined by the screen size.
3. When should you npm and when should you yarn?
Well, this was a bit of a rabbit hole. Let’s do this.
From what I’ve researched, Yarn is quite similar to NPM, which makes sense given that it was inspired by NPM. And by similar, I mean very, very similar at this point. When it first released it was built to make up for some shortcomings of NPM, including providing a lock file that provides entries for all of the dependencies a project has, including version number.
Nowadays, NPM has been updated to include most of the features that Yarn was going for, and even though there is a Yarn 2, most developers (including Facebook, who invented it) don’t seem to use it. So, given the choice between NPM and Yarn, it’s really up to you and your design team. I prefer NPM because it’s what I’ve been learning on.
4. How can you make sure your dependencies are safe?
When installing a node package that creates a dependency, it’s important to know that it’s secure. It’s 2020 and, unfortunately, people can try to use code for not so good purposes.
There are a few things you can do to protect yourself. When you npm install, it automatically runs an npm audit. This scopes out the package, and makes sure everything is up-to-date. If it’s been a while since you installed the package, you can also just run npm audit.
If it turns out there is an issue, the audit will let you know. From there you generally just need to run npm audit fix. This will get everything updated to the latest and greatest version.
5. What are the differences between CHAR and VARCHAR data types (MySQL)?
Much to my disappointment, this has nothing to do with Charmander.
Instead, these terms relate to string data types in SQL. CHAR is a string with a fixed length- the computer knows exactly how many characters there should be. VARCHAR is, naturally, a string without a fixed length. This adds processing time, takes up more space, and makes things more messy to sort out in general.
If you can, go for CHAR.
This looks complicated at first, but it’s actually a lot of extraneous code. See where it says setTimeout? Normally, when used, this will delay a function. So, if you want a function to wait a bit before it executes, you can set a timeout (usually for a few seconds).
But, no time has been chosen. So, really, there’s no reason for this timeout to be here. We can get the same result by doing this: