javascript,socket.io,sails.jsView the original page-Collection of common programming errors

UnKnown Error


  • Phill Collins
    javascript android mobile phone user-agent 2014-1-26 3:09:44
    Is this possible?I want to exclude android phones from using some code, but I still want it to work on android tablets.The only user agent I can find is “android” which will obviously exclude everything android related :/Thanks

  • narayanpatra
    php javascript html 2014-1-26 2:43:28
    I have just started to learn HTML, JavaScript and PHP. After studying little , I am thinking why we need PHP? Whatever we can do by PHP, can be done using Javascript(I think that but I am a noob to this). So why we are using PHP? Can anybody explain me about this?( I apologizes in advance if the question is totally foolish and the answer is very obvious but as I said I am noob to web).

  • PartiallyFinite

  • alFReD NSH
    javascript parsing code-generation interpreter ast 2014-1-26 0:25:49
    I wrote an interpreter in JavaScript for a small language using jison, which is a JS port of bison. The language is used to evaluate expressions and conditions. Right now the evaluation is mixed with the parsing.I’m trying to optimize it and the bottleneck is lexer and the parser. So I decided to parse it before hand and only evaluate on runtime.The question is that which one is faster or cleaner, generate JS code before and only run that or generate AST and iterate on it on runtime?

  • 2astalavista
    javascript jquery css html5 plupload 2014-1-25 23:19:24
    There is a pluploader, it has a file drop zone and its id is dropFilesHere;var uploader = new plupload.Uploader({drop_element : “dropFilesHere”, /*…*/});I would like to make some changes* (like gmail file attachment) on the drop zone if the user holds the file over it.*For example:.mouse_over{border-width:5px border-style:dashed #808080; }Sample:How can I do this?uploader.bind(‘Init’, function(up, params) {$(‘#filelist’).html(“<div>Current runtime: ” + params.runtime + “</div>”);if

  • aztack
    javascript angularjs 2014-1-25 22:28:57
    For me,it’s like magic. How dose Angular know watched expression has changed, and then call the callback? As far as I know, not all JavaScript implementation offer __defineSetter__ and __defineGetter__. Can someone explain how it works?

  • Dimitre Novatchev
    javascript python lxml 2014-1-25 22:15:14
    <html> <head><script type=”text/javascript”>document.write(‘<a href=”http://www.google.com”>f*** js</a>’);document.write(“f*** js!”);</script> </head> <body><script type=”text/javascript”>document.write(‘<a href=”http://www.google.com”>f*** js</a>’);document.write(“f*** js!”);</script> <div><a href=”http://www.google.com”>f*** js</a></div> </body> </html>I want use xpath to catch all labl

  • Meredith
    javascript jquery autocomplete typeahead.js 2014-1-25 20:43:25
    I am using typeahead.js. I am using the prefetch options and need to parse the returned data. It’s not throwing an error; it’s not doing much of anything. I’ve looked for examples but none of them use the Prefetch Filter option.Link to the prefetch documentationMy code (that does not work but throws no errors):$(‘#autocomplete’).typeahead(‘destroy’).typeahead( { name: ‘organizations’,prefetch: {url: ‘jsoncall’,filter: function() {// Blatant hardcoded return valuere

  • eco_bach
    objective-c javascript 2014-1-25 19:00:16
    In C or any ECMAscript based language you ‘call a public method or function’ on an object. But in documentation for Objective C, there are no public method calls, only the sending of messages.Is there anything wrong in thinking that when you ‘send a message’ in ObjC you are actually ‘calling a public method on an Object’.?

  • AP257
    javascript 2014-1-25 18:57:08
    I have a JavaScript object that I’d like to add some properties to, but I don’t know what the names of the properties are until runtime.Can I do this without using eval? If so, how?var get_params = new Object(); var params = {‘name’:’john’, ‘age’:’23’}; //actually not known until runtime for (var i=0, len=params.length; i<len; ++i ){ get_params.p[0] = p[1]; //How can I set p[0] as the object property?} }

  • Rob
    javascript node.js socket.io 2014-1-22 12:25:59
    So I would like to be able to run custom function through socket.io using node My basic idea is fairly simple, I just can’t get it to work. Generally speaking you would write something similar to this to run a function on incoming message…//server socket.on(‘incomingMessage’, function(data) {console.log(data);io.sockets.emit(‘newMessage’, {id: data.id, from: data.name, message: data.message}); }); //client socket.on(‘newMessage’, function(data) {$(‘#messages’).html($(‘#messages’).html() + data

  • Ivan Kozlov
    node.js socket.io 2014-1-12 1:13:42
    In socket.IO there are 2 ways to send message to users separately: rooms and namespaces. In my project I need both of them – namespaces to divide users of different applications and rooms for each namespace for private messages and other specific stuff. It’s quite easy to create rooms directly in runtime. But is it possible to do the same trick with namespaces? I’d like to do something like this:io.of(*someFunctionToCreateNameSpaceInRuntime*) .on(‘connection’, function (socket) {socket.emit(***)

  • Remon Amin
    ruby-on-rails node.js socket.io 2014-1-9 0:48:34
    I am using socket.io on my rails app to server user online/offline on the database,I am using Redis for storing data and 0 fore offline and 1 for online status on my app.js file var app = require(‘express’)() , redis = require(‘redis’) , client = redis.createClient() , server = require(‘http’).createServer(app) , io = require(‘socket.io’).listen(server);server.listen(80);io.sockets.on(‘connection’, function (socket) { console.log(“client connected”)socket.on(‘join’,function(userid){ socket.set(

  • Antonio Max
    node.js socket.io node-mysql 2014-1-6 0:05:36
    I’m a beginner with Node.js, is it ever ok to use MySQL as a global var?I have a db_helper.js with this code inside:global.client = require(‘mysql’).createConnection({user: ‘__mysqluser__’,password: ‘__mysqlpass__’,database: ‘__mysqldb__’,timezone: ‘-03:00’ }); global.client.connect();On my main.js I just do a:require(‘db_helper’);Then on other js files, whenever I need to UPDATE or SELECT I just call:global.client(query, data);I haven’t seen any code like this yet, but it works as expected, but

  • Eric Alan Solo
    node.js express socket.io iisnode 2014-1-4 10:18:40
    Errors:Trying to access http://localhost/appDirectory/socket.io gives:Cannot GET /appDirectory/socket.ioOr to put it another way when trying to load the client file on the page I get this error:GET http://localhost/appDirectory/socket.io/socket.io.js 404 (Not Found)If I load the client file as static content the connect line produces this error:GET http://localhost/appDirectory/socket.io/1/?t=1365535131937 404 (Not Found)Server code:var express = require(‘express’), namespace = require(‘express-

  • Connor Black
    javascript node.js coffeescript socket.io 2014-1-3 18:29:26
    So I’m trying to move my project from development to production, hosted with modulus.io.The problem is that every time I try to emit or receive data between the server <-> client connection, the application fails on the server’s end. This is the error I get:/mnt/data/2/node_modules/socket.io/lib/parser.js:75data = JSON.stringify(ev);^ TypeError: Converting circular structure to JSONat Object.stringify (native)at Object.exports.encodePacket (/mnt/data/2/node_modules/socket.io/lib/parser.js:75:

  • Rustem K
    python socket.io twisted tornado sockjs 2014-1-3 12:47:52
    I am working now on real-time game based on tornado, tornado-sockjs. There are a lot of different timeout strategies in our game application: TIMEOUT_GAME_IF_NOBODY, TIMEOUT_GAME_IF_SERVER_OFF. These timeouts has callbacks that can work with storage directly (update, insert, and so on). The question is what is the right way to organize timeout strategy into a module ?! How can we re-execute callbacks in case of server failure ? Imagine that three timeouts are hanging, and suddenly server that ha

  • Ken OKABE
    node.js cookies express socket.io 2014-1-3 11:32:14
    How to add a cookie value on Socket.IO?io.sockets.on(‘connection’, function (client) { console.log(client.id); client.handshake.headers.cookie.socketID = client.id; // not work// client.handshake.headers.cookie(“socketID”,client.id); //crashconsole.log(client.handshake.headers.cookie); // The current output is: //connect.sid=tI21xumy3u2n4QXO1GljmPAf.pzFQ1Xu%2B6bz36secu4VSCdSNU8PT1L44gQZ4kFUFQqQ //this is express session id, and I also want to add client.id of Socket.IO. //……….. }I have

  • Sneaksta
    node.js ssl https socket.io 2014-1-3 2:40:31
    I have my node.js and socket.io setup and running perfectly on my local machine, but now I am trying to transfer it to my live server.I have installed node.js and socket.io and they’re working, but I can’t seem to link to the socket.io/socket.io.js file through my client. It keeps coming back with “500 Internal Server Error”I have tried using both these paths:<script type=”text/javascript” src=”/socket.io/socket.io.js”></script>and<script type=”text/javascript” src=”https://localh

  • Johan
    javascript html5 node.js websocket socket.io 2014-1-2 15:45:20
    server.jssocket.on(‘adduser’, username, successcallback){if(users.hasOwnProperty(username)){} else {socket.username = username;users[username] = { name: username };socket.emit(‘updatechat’, ‘SERVER’, ‘you have connected’);socket.broadcast.emit(‘updatechat’, ‘SERVER’, username + ‘ has connected’);io.sockets.emit(‘updateusers’, users);successcallback({ msg: ‘User ‘ + username + ‘ has been successfully added’ }); }});index.htmlsocket.on(‘connect’, function(){var username = prompt(‘Whats your name?’

  • Vadorequest
    javascript node.js callback runtime sails.js 2014-1-17 19:28:41
    I’m pretty confused by the way to work on node.js, I’m talking about callbacks, returns and how source code is executed.I’m using sails.js but I don’t think it’s linked, it’s more the way to JS works, I think.Source code:module.exports = function (req, res, callback) {if (req.session.authenticated) {// Accept user authentication.return callback();} else {// Not authenticated. Try auto authentication.if(validator.check([validator.rulesHardwareId(req.param(‘hardwareId’))])){Device.findOne({hardwar

  • Jeremie Parker
    promise sails.js q 2013-12-30 2:07:19
    I’m starting to convert my callback code to promises in Sails.js, but I don’t understand how I can raise custom errors and handle them in the promise chain. Sails.js uses Q as its promise library.User.findOne({email: req.param(‘professorEmail’), role: ‘professor’}).then(function (user) {if (user) {return Course.create({user_id: user.id,section: req.param(‘section’),session: req.param(‘session’),course_code: req.param(‘course_code’)});} else {// At this point `user` is undefined which means that

  • Madd0g
    node.js express sails.js 2013-12-30 2:06:48
    I’m trying to find the best place to handle connectivity errors, or any other global errors that crash the server.What is the right place to catch adapter/global errors and not have them crash the server?Specifically, I want to handle these types of errors in a graceful way:Error spawning mySQL connection: error: Hook failed to load: orm (Error: connect ECONNREFUSED) error: Error encountered while loading Sails core! error: Error: connect ECONNREFUSED

  • René Fournier
    javascript node.js express websocket sails.js 2013-12-18 22:45:30
    I am having a problem similar to socket.io issue using sails.js. Every once in a while (once per day, or even few hours, it varies), a visitor to the web site/app will crash Node, seemingly due to the way his websocket client tries to connect. Anyway, here’s the crash log:debug: Lowering sails…/Volumes/Two/Sites/lsdfinder/node_modules/sails/node_modules/express/node_modules/connect/lib/utils.js:216return 0 == str.indexOf(‘s:’)^ TypeError: Cannot call method ‘indexOf’ of undefinedat exports.par

  • anwyatt
    javascript socket.io sails.js 2013-11-12 13:41:57
    I am attempting to use the subscribe function described here. However, when editing /assets/js/app.js, I am getting this error:Uncaught ReferenceError: Room is not defined So, I am not entirely sure why, but it cannot find my model. Here is my code:Room.subscribe(req, [{id: “5278861ab9a0d2cd0e000001”}], function (response) {console.log(‘subscribed?’);console.log(response); });and here is is in the context of app.js(function (io) {// as soon as this file is loaded, connect automatically, var sock

  • bwaaaaaa
    node.js ftp sails.js 2013-9-20 6:19:25
    Im using node jsftp module and sailsjs. I am having problem with the ftp session, i think that’s the problem. Correct me if Im wrong. I just need to display the file list when the user login.Here’s the problem. After logging in, the user is redirected to the homepage. However, after redirection the ftp instance is gone. Do i need to reconnect “ftp.auth” everytime i redirect?Please see the code below. Thanks in advance!/*———————:: Ftp -> controller ———————*/ var Ft

  • Loed
    node.js mongodb authentication sails.js 2013-9-11 14:28:40
    I’m making an API that has different levels of access, the ‘client’ may only read. But ‘admin’ must have write access. The different roles are check every time as a policy in Sails.js and sets the rights in the req.session. I just need to give the ‘client’ no access to create, update and delete actions, therefore i created an controller that has those CRUD actions and checks if the user has the right role. All of the actions that has restricted access are redirected trough routes.js to this cont

  • adc06
    socket.io sails.js 2013-9-1 11:31:11
    I am trying to use socket.io with sails js. I understood that it was pretty straighforward and that sails provided an available socket.io structure out of the box. Howeve When I try to connect to my sails server from a distant client usingio.connect(http://localhost:1337)It makes my server crash with the message:/node_modules/express/node_modules/connect/lib/utils.js:216return 0 == str.indexOf(‘s:’)^TypeError: Cannot call method ‘indexOf’ of undefinedI am probably missing something but I don’t u

  • Elliot Lings
    node.js socket.io sails.js passportjs 2013-8-17 3:42:04
    When I use Sails.js with Passport.js, the isAuthenticated method does not exist on the req object when requested through websocket.Could anyone tell me why this happens?Thanks