In the article How To Ask Questions The Smart Way, authors Eric Raymond and Rick Moen go on a rant about the stupid questions posted on the internet, and what you can do to ensure that your questions are “smart” questions.
Safely turning a JSON string into an object
Given a string of JSON data, how can I safely turn that string into a JavaScript object?
Obviously I can do this unsafely with something like:
var obj = eval("(" + json + ')');
but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval.
At the time this question was posted (2008), parsing JSON with JavaScript was not possible natively, as indicated by one of the older answers. Matt identified that his solution of using eval()
was dangerous, and he was asking the community if there was a better way. It’s possible that a Google search at the time could have produced an answer, but Google has a tendency of putting just about anything in front of you, regardless of the source, so I can understand taking the question to a community of professionals for their opinions.
How to find the length of an array in shell?
How do I find the length of an array in shell?
For example:
arr=(1 2 3 4 5)
And I want to get its length, which is 5 in this case.
Bash/shell might not be the most used programming language out there, but I am sure that the answer to this question is a quick Google search away. I would imagine that Arunachalam could have spent less time searching for the answer than typing this question.
Having responded to my fair share of customer inquiries over the years, I have seen more than enough “not so smart” questions. My personal favorite is when the question exists in the document appropriately named “frequently asked questions”, which clearly no one takes the time to read. While I can understand why the authors of this article are irritated, I cannot understand why they took the time to write 20 pages about it. I would argue that anyone sophisticated enough to be reading an article titled “How To Ask Questions The Smart Way” would have a statistically significant bias towards already asking “smart” questions, and those with the most to gain from reading such an article will continue to ask stupid questions, none the wiser of its existence.