What is index.js used for in node.js projects?

When you pass a folder to Node’s require(), it will check for a package.json for an endpoint. If that isn’t defined, it checks for index.js, and finally index.node (a c++ extension format). So the index.js is most likely the entry point for requiring a module. See the official Docs here: http://nodejs.org/api/modules.html#modules_folders_as_modules. Also, you ask how to … Read more

How can I add numbers in a Bash script?

For integers: Use arithmetic expansion: $((EXPR))num=$((num1 + num2)) num=$(($num1 + $num2)) # Also works num=$((num1 + 2 + 3)) # … num=$[num1+num2] # Old, deprecated arithmetic expression syntax Using the external expr utility. Note that this is only needed for really old systems.num=`expr $num1 + $num2` # Whitespace for expr is important For floating point: Bash doesn’t directly support … Read more

What is the “N+1 selects problem” in ORM (Object-Relational Mapping)?

Let’s say you have a collection of Car objects (database rows), and each Car has a collection of Wheel objects (also rows). In other words, Car → Wheel is a 1-to-many relationship. Now, let’s say you need to iterate through all the cars, and for each one, print out a list of the wheels. The naive O/R implementation would do the following: And then for each Car: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)