BlogPost_303
- 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?
- 409. The HTTP 409 Conflict response status code indicates a request conflict with current state of the server. ... For example, you may get a 409 response when uploading a file which is older than the one already on the server resulting in a version control conflict.
- 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?
- Have a set of sizes available on your server (say 350px, 700px, 1000px, 1500px, 2000px, 4000px) and use srcset attribute of image tag. Your browser will automatically load the best one.
- If you need find grained control over what screen size loads what, you can also use media queries in CSS and put image in background of a full length placeholder div instead of using an img ray
- When should you npm and when yarn?
- Yarn when you want to want to lock dependencies to their specific versions. Yarn has the power to perform multiple installation steps at once, which speeds up the process. Npm goes sequencially. Yarn is normally faster to install. Yarn only installs dependencies from your yarn.lock so it's considered more secure. Since Yarn is supported by some of the world's largest tech companies, bugs are identified and taken care of fairly quickly. Using npm and yarn together can create some problems. Yarn is slowly overtaking npm.
- How can you make sure your dependencies are safe?
- When writing Node.js applications, ending up with hundreds or even thousands of dependencies can easily happen. For example, if you depend on Express, you depend on 27 other modules directly, and of course on those dependencies' as well, so manually checking all of them is not an option!The only option is to automate the update / security audit of your dependencies. For that there are free and paid options:
- npm outdated
- Trace by RisingStack
- NSP
- GreenKeeper
- Snyk
- First, it's important to do our homework before installing a package.Read the package's page on npmjs.com and look at who published the package, the number of versions and the number of weekly downloads. If these numbers are very low, I would pass or definitely inspect the source code.Another thing, to pay attention is when you type the package name. Typo squatting is possible and there are published packages which have names close to popular packages.In terms of how secure is NPM (the registry), they do periodic penetration testing and outgoing code reviews. Also, they report vulnerabilities to package authors and handle vulnerabilities reports from other users. But, it's a continuous fight against spammers, malware, etc.
- What are the differences between CHAR and VARCHAR data types? (MySQL)
- A CHAR field is a fixed length, and VARCHAR is a variable length field.This means that the storage requirements are different - a CHAR always takes the same amount of space regardless of what you store, whereas the storage requirements for a VARCHAR vary depending on the specific string stored.
- How else can the JavaScript code below be written using Node.Js to produce the same output?
console.log("first"); setTimeout(function() { console.log("second"); }, 0); console.log("third"); // Output: // first // third // secondconsole.log("first"); setImmediate(function(){ console.log("second"); }); console.log("third");

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home