little error for a newbie in Javascript MVC - javascript

Hi I am just starting a tutorial in javascriptMVC (JqueryMX) I have an error "Uncaught type error Cannot call method 'Model' of undefined" I have checked all path and don't understand why it is still not working. Any help will be greatfull. todo.js below
steal('jquerypp/class',
'jquerypp/controller',
'jquerypp/model',
'jquerypp/view/ejs',
'jquerypp/dom/fixture',
function($){
$.Model('Todo',
{
findAll : "GET /todos",
findOne : "GET /todos/{id}",
create : "POST /todos",
update : "PUT /todos/{id}",
destroy : "DELETE /todos/{id}"
},{})
});

did you have this solved already?
if not, i would suggest that you try the JMVC code generator (./js jmvc/generate/app myapp) as seen in here --> http://javascriptmvc.com/, there you will see how the libraries are placed.
and by the way, the steal.js should be placed in the html file, all others can be in the main js file.

Related

Uncaught (in promise) Error: Provided weight data has no target variable: block1_conv1_2/kernel

I am new to machine learning and I was following this blog on how to write a model with mobilenet.
I managed to convert the .h5 file model and tried to implement it
on my web app.
Unfortunately, when I try to load the JSON model I get this error:
Uncaught (in promise) Error: Provided weight data has no target
variable: block1_conv1_2/kernel.
Screenshot of the error on a browser
I converted the .h5 model in the command line like so:
tensorflowjs_converter --input_format keras model.h5 ConvertedModel/
The code to load the model in the browser, I followed this blog
let model;
async function loadModel(name) {
$(".progress-bar").show();
model = undefined;
model = await tf.loadModel(`ConvertedModel/model.json`);
$(".progress-bar").hide();
}
To see the code of the model please refer to the blog link.
But below is a screenshot of how the model is compiled.
Model compilation
Dependencies:
Tensorflow 1.13.1
Python 3.6.0
tensorflowjs 1.0.1
Any help to fix this would be appreciated. Thank you so much.
It seems you've encountered this error where an extra suffix has been added to some of your weights.
You can work around this issue by manually removing these extra suffixes from your model.json:
block1_conv1_2/kernel
should instead be:
block1_conv1/kernel
The 'Error in clip' bug has now been fixed so I'm not too sure why you've received this one, but once again you can work around this by manually editing the model.json, and changing every instance of:
{"type":"ndarray", "value":6}
to
6

Adding jQuery script to a single view in Yii2

I am working on the basic template of Yii2. I have got a jQuery script views/usuario/js/create.js that it's only going to be used in one view views/usuario/create.php.
I'd prefer not to use ...
public $jsOptions = array(
'position' => \yii\web\View::POS_HEAD
);
... in assets/AppAsset.php in order to mantain loading of scripts at the end of the page.
create.js it's only needed in the create.php view so I'd prefer to load it just for the create.php view.
So I've tried unsuccessfuly to follow ippi's instructions
Firebug keeps throwing me this error:
SyntaxError: expected expression, got '<'
http://www.example.com/usuario/js/create.js
Line 1
I guess there could be a problem with the route param of ...
$this->registerJsFile('js/create.js');
... but I can't find it out.
Any help would be appreciated.
registerJsFile() needs an url, you should simply publish (make it web accessible) your file before registering it, e.g. :
$pub = Yii::$app->assetManager->publish(__DIR__ . '/create.js');
$this->registerJsFile($pub[1], ['depends' => ['yii\web\JqueryAsset']]);
Or you could create an asset bundle and registering it in your view.
Read more about publish() and registerJsFile().
Try to use $this->registerScriptFile('views/usuario/js/create.js');

Get yahoo friends list using hello js

I am using hello.js for listing all my friends in yahoo.Following is the function used on button click :
getFriends('yahoo', 'me/friends')
I generated yahoo api key for my application.While generating api key I have checked all checkboxes given under permissions.The api key is used in the script as given below,
hello.init( {
yahoo : 'YAHOO_CONSUMER_KEY'
}
, {
redirect_uri:'APPLICATION_URI',
oauth_proxy : 'https://auth-server.herokuapp.com/proxy',
scope:"friends"
}
);
Following is the error I am getting now.
code:"parameter_rejected"
message:"401 could not authenticate"
Can someone please help me to resolve this?
We had an issue with scope parameters in Yahoo's OAuth1 implementation, try seeing if the error goes away if you dont define a scope

Attempted to handle event `becameInvalid` while in state 'root.loaded.saved'

I've implemented DS.Errors for my RestAdapter, thanks to Alex Spellers tutorial on server side validation.
However, in this part of my app I want to do a simple client side check to see if the form is complete. (Why not have DS.Errors handle all the errors?)
process: function(upload) {
var form = upload.get('form');
if (!isComplete(form)) {
upload.get('errors').add('field', 'field isempty');
return;
}
// else "Processing..."
The logic here is somewhat simplified, but errors.add() should invalidate, and add an error to the model. However I'm getting the following error:
Uncaught Error: Attempted to handle event `becameInvalid` on <#model:upload:54a1f298ef912a2ace760b0f> while in state root.loaded.saved.
I have read about the state manager, but am unsure as to how, and what state I should transition to before adding an error to my model.
Thanks in advance!
Ember : 1.8.1
Ember Data : 1.0.0-beta.11
Handlebars : 1.3.0
jQuery : 1.11.2
After revisiting this I came across the following post. What solved my problem was not sending willCommit, but sending upload.send('becomeDirty'); before executing the following:
upload.get('errors').add('field', 'field isempty');
Now errors can be added as the upload model is not in the saved state.

Node.js: error GET http://undefined/socket.io/1/?t=1357634942292

I am running a Node.js app, while loading the url i am getting a error like below:
GET http://undefined/socket.io/1/?t=1357634942292
on trying to send a message another error is produced , which is
Uncaught TypeError: Object # has no method 'send'
EDIT:
I have used a function
client.broadcast.send({ announcement: client.sessionId + ' connected' });
now the error arising is
TypeError:Property 'broadcast' of object # is not a function
Can anybody help me out what might have gone wrong in here?
Cheers
Jeev
how about sharing the client initialisation code?
i guess your io.connect method is called wrong. you do it like io.connect(); where it needs to be: io.connect("http://yourdomain.tld");
did you find the awnser for this? My best tip is to check that you specified io.connect('localhost:6666') or wherever you set up your site, as in that question
refer this
it will be helpfull for you.
Thanks

Categories