ObjectID showing Unicode gibberish instead of a string - node.js

When I debug my Node application, my ObjectId's are represented by Unicode gibberish like ObjectID {id: RýÕ/H} instead of the actual readable ID. Here's a screenshot. Does anyone know what's causing this?
I am using WebStorm 7.0.1 on Crunchbang Waldorf x64.
UPDATE: After checking in node-inspector, I get the same results: http://i.imgur.com/8dxOGhd.png
The only time I can see my ObjectId's properly is if I check them in Robomongo (a MongoDB GUI) or if I log them to the console from within the Node app.

Unfortunately, it's just the way WebStorm currently works. You can do a quick evaluate using object.toString() when debugging if you need it. Instead of WebStorm showing something friendly, it's showing the binary representation of the ObjectID.

I had the same problem while doing a Node.js and MongoDB exercise from this book: https://leanpub.com/nodecraftsman. The code I'm talking about is on page 83, line 12.
I was running and testing everything through the command line.
What I discovered was that one line of the code (line #12) contained console.dir(documents). I changed it to console.log(documents), and it gave me back an id I expected -- something like 54e95c6f322fd679214d3a18 rather than the gibberish of, for example, Té\o2/Öy!M:\u0015
MDN describes console.dir() as "nonstandard," so perhaps there was something odd going on. More info: https://developer.mozilla.org/en-US/docs/Web/API/Console/dir

This is a bug in WebStorm. They are tracking the issue here:
https://youtrack.jetbrains.com/issue/WEB-9945

Related

How to read node errors from the console?

I have this error in the console, below which gives the number 8301. What does this number mean and how can I use it to troubleshoot the error?
(node:8301) DeprecationWarning: current URL string parser is
deprecated, and will be removed in a future version. To use the new
parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Pleas note, I am using this as an example error to try and understand the printed number (node:8301). I don't need help with the error itself.
Please help me to understand node errors.
The number portion of (node:8301) is the node process's process id (pid). This is attached to all warnings that Node.js itself emits, or that are emitted via its process.emitWarning() utility.
(In the particular example in the question, the warning is from a user module using process.emitWarning().)
For what it's worth, NODE_DEBUG also logs pids in the logged information, although strangely not in that format.
I'm not sure if there is actually official documentation on this. There is presently a discussion to add a "Warnings" section to the official documentation: https://github.com/nodejs/node/issues/24987
This question was also asked to https://github.com/nodejs/node/issues/25120, where I discovered and originally answered it.
try this:
MongoClient.connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true })
from here
Honestly, I’ve been working in node since 2009, and I’ve never bothered to look into the error codes unless I need my software to handle the error. Mostly, I just read the error text.
In the case of your example, the error text clearly tells me what the problem is.
I’ve found generally that the quality of error messages and codes alike varies greatly on the library you’re using.

CS50 Pset7 Finance

I have question for my CS50 Pset7 finance project. I don't know where to ask this question, so I seek help here. I just finished the register part, however, when I try to test the website, I registered successfully, however, when I try to log in, I got a strange error which I think is because of my way of using hash is not correct. So I got the error TypeError: invalid method '' for security.py", line 186, in _hash_internal, and I can see my hash value like $6$rounds=656000$OiBqI/lX2GqhI8be$G. I found in the API that the schema support has been removed. I'm wondering how should I use hash method other than pwd_context.hash(request.form.get("password")). Any advice will be appreciated.
Use generate_password_hash() to replace hash() will work. Don't forget to remove or update the existing entries inside your db since the old hash will cause error.

GIT. Web interface (Node.js). Wrong encoding

I'm trying to build web interface for GIT on Node.js.
Currently I have one problem: wrong Unicode encoding while 'git commit'. Commit message are shown in gibberish in log. And I have no clue on which step in which way I need to correct.
At this point I have:
1) UTF-8 encoded HTML page for interface;
2) Node.js child_process.spawn() to execute git commands;
3) ["-C",repo.path,"commit","-m",post.msg] as an argument list to pass to git;
When I execute the same command from git shell (Under Windows if it matters) - everything is fine.
Any suggestions?
Thanks in advance!
Update
I guess I won't have this question answered, but still add one detail:
it feels like somewhere message is converted from UTF8 to ISO 8859-1
Update2
Looks like 8859-1 - is my default CMD.exe (who proceed my commands) encoding... still have no idea on what to do with it.
The cause of problem was not about git, cmd or node.js. It was my stupid mistake.
On client I wrapped data into encodeURIComponent before send. On server unwrapped it with unescape. It took too much time to notice it.
Now, after I replaced unescape by decodeURIComponent, it works perfectly well.

Issue with basic AS3 workers classes

I have followed Lee Brimelow's tutorials (part 1, part 2), but somehow my project doesn't work as expected.
Currently, publishing "src/Secondary.as" to "www/assets/swf/secondary.swf" works properly, however when trying to run "src/Main.as", an error shows up:
Exception fault: TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Main/init()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:52]
at Main()[/Volumes/DOCUMENTS/Tests/AS3/test-workers/src/Main.as:32]
If anybody has time, you can look at my code on Github and maybe see where I screwed up? Thanks a bunch!
As your error message says: the problem raised in Line 52 in your Main.init()method. What you try to do there is to create a new instance of SecondarySWF. I would say that your embedment of Secondary class into SecondarySWF doesn't work properly, so it is not available in your init-method. You should set a breakpoint at the first line of your init-method and when the debugger reaches this point check what's in SecondarySWF. I expect that there's nothing in that variable, so what your new SecondarySWF() then means actually is new null().
Because you embed your secondary.swf with a MIME-type specified the Flex compiler ignores it because it is unable to detect the actual type of data in the loaded file. I found this post on Adobe's cookbook page that explains what you have to do in addition to adding the file using [Embed]. Hope this will fit your needs.

Getting echofunc.vim to work

I came across echofunc.vim today (from a link in SO). Since I'm rubbish at remembering the order of function parameters, it looked like a very useful tool for me.
But the documentation is a bit lean on installation! And I've not been able to find any supplementary resources on the internet.
I'm trying to get it running on a RHEL box. I've copied the script into ~/.vim/plugin/echofunc.vim however no prompt when I type in a function name followed by '('. I've tried adding
let g:EchoFuncLangsUsed = ["php","java","cpp"]
to my .vimrc - still no prompting.
I'm guessing it needs to read from a dictionary somewhere - although there is a file in /usr/share/vim/vim70/ftplugin/php.vim, this is the RH default and does not include an explicit function list.
I'm not too bothered about getting hints on the functions/methods I've defined - just trying to get hints for the built-in functions. I can see there is a dictionary file available here which appears to provide the resources required for echofunc.vim, I can't see how I set this up.
TIA,
It expects a tags file, the last line of the description describes exactly how to generate it:
ctags -R --fields=+lS .
It works here with PHP but not with JS. Your mileage may vary.
I didn't know about this plugin, thanks for the info.
You should try phpcomplete.vim, it shows a prototype of the current function in a scratchpad. It is PHP only, though.

Resources