w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Meteor client loses connection
Meteor uses a data-on-the-wire principle. So it can load in the browser and needs a connection to the internet to maintain the 'liveness' of the data. So when you lose connectivity its built smart to try and reconnect. So at first it'll try to reconnect is small intervals. What you see there is that meteor is retrying to connect to the server status is its waiting to retry. connected is false retryCount shows how many times it has tried to connect again retryTime shows the last time or next time it tried/will try to connect (not sure which it is) There aren't any errors at this point but meteor will build up a que of whatever you do (changes to the collection, etc) and then as soon as it connects it will commit these to the server. Instead of refreshing the browser you could use Met

Categories : Meteor

Value of directly accessing prototype i.e. Object.prototype.toString.call()
Your way would work perfectly well, of course. It does create and throw away objects unnecessarily, but as you say, the overhead of that would be incredibly trivial. FWIW, the readability thing is subjective (I find the version using the prototype easier to read.) I think it's mostly just a desire to avoid that unnecessary creation, the unnecessary memory churn. Engines used to be a lot slower than they are now. Engaging premature-micro-optimization mode... Looks like for the slice use-case, on Chrome using a literal is about 4% slower on my machine, on Firefox it's more lke 9%, with no difference at all on IE10. Very likely whatever you're doing after that will swamp that effect. Of course, the effects from memory churn are harder to measure. If you're doing this a lot, I would just b

Categories : Javascript

Meteor loses login session on page change (heroku only)
Turns out this was a meteor/chrome bug and will be fixed in version 0.6.5. https://github.com/meteor/meteor/issues/1244 https://groups.google.com/d/msg/meteor-talk/Pct1_kFlp4I/3a2lXlyF6zcJ

Categories : Javascript

Meteor Security: should all database insert, update, remove operation be a Meteor.call() to the server?
For the first point, you can choose any of the two possibilities, but i prefer to use the second one : Client can do insert/update/delete Server has some security checks With this system you use the latency compensation of meteor. So it seems to be a good way of doing. For the second point, you can imagine to store in Session where you are on the list when you click on the detail. Then when you come back to the list, you check the session value and you just have to use it to restore the state.

Categories : Javascript

Meteor: Meteor.call() from within observe callback does not execute
This might be a known issue, i'm not sure since I've not tried it myself, but it looks like there might be a workaround (see https://github.com/meteor/meteor/issues/907) Add your Meteor.call into an instantaneous setTimeout callback: added: function(doc) { console.log("added "+doc.text); setTimeout(function() { Meteor.call('aMethod',doc.text,function(e,r){ if(e){ console.log("error from server: "+e); }else{ console.log("response from server: "+r); } }); },0); }

Categories : Javascript

For prototype.js why I can't see the debug information of onSuccess in the browser?
I saw you have been use jquery in your java script. In that case, you can using the jquery ajax GET/POST to solve your problem with effiency. Some thing like that: jqxhr = $.get("example.php", function() { alert("success"); }) .done(function() { alert("second success"); }) .fail(function() { alert("error"); }) .always(function() { alert("finished"); }); jquery do better in multiple browser for you

Categories : Javascript

How can I delay a reactive Meteor template from updating an HTML template variable, when a Meteor.call() updates the database instantly?
Try to wrap your Meteor.call() inside the setTimeout() itself, like: Template.keno.events({ 'click #start' : function(){ setTimeout(function(){ Meteor.call('process',function(){ //do something. }); }, 20000); } });

Categories : Meteor

Hide Meteor.users and other information on client
The first thing I'd do is remove the insecure package. mrt remove insecure After you do that a few things will probably break since you're no longer publishing everything to the client. You'll have to setup publications and subscriptions.

Categories : Meteor

Exporting a prototype in node.js: module.exports=Prototype or exports.Prototype=Prototype?
The second one would only be useful if you exported multiple classes from one file which is something that is questionable by itself. There is no problem in replacing the exports object at all.

Categories : Node Js

trying to understand Function.prototype.call in js
To answer your question in reverse order... (function()).call(...) sets the context in which the function is to execute. i.e. it sets the this object to the first argument. In your example the first version sets this to the element in the animals[] array. the second will set the context to whatever this is - here it will be the global context. Once the context is set, your code can refer to it with the this keyword. In your first question this refers to the current animals[] element, so it can extract the species, name, etc. for each animal. Omitting the this keyword refers to variables in the global scope, which aren't defined.

Categories : Javascript

Call C address as function without prototype
I think, all of your decision will not be supported multi-compiler, because the mechanism of passing arguments to function (registers, their order, stack, memory) - it's compiler dependence feature...

Categories : C

problems with Array.prototype.indexOf.call
var index = Array.prototype.indexOf.call(parent, ancestor); // ^ Array ^ Element in the array So you want this: var index = Array.prototype.indexOf.call(ancestor, parent); Since ancestor is the element ("array") that contains parent.

Categories : Javascript

Why can't I add a property to an object without using prototype, call or apply?
A function if "applied" to an object, would mean that the function will get "this" variable which would be the object itself. Whereas just calling addX(bar) passes bar as a parameter to the function. So had addX been written like this: function addX(barObject) { barObject.x = 2; } The call addX(bar) would have worked. Whereas,in your example addX.apply(bar), internally does this: // apply does the following internally bar.addX = function() { this.x = 2; } bar.addX() // end of scope for apply hence addX(bar) does not do anything in your example, because in that case, "this" does not belong to anything but the function itself.

Categories : Javascript

Call Object.prototype method on Global Scope
The problem is one of context. That is to say, in essence, what the this value inside the function is when it's called. Calling hasOwnProperty('window') does not have a context. It is the same as doing this: hasOwnProperty.call(undefined, 'window'); Whereas this.hasOwnProperty('window') is the same as doing this: hasOwnProperty.call(this, 'window'); The second line of code will have the output you expect (true), but the first one will obviously not work.

Categories : Javascript

Javascript (prototype) method call from ajax callback
this in your callback function is different from the this referring to SomeFunc, try doing: this.SomeOtherFunc(){ var thatFunc = this; //get hold of this return $.ajax({ <some restful call> }).done(function(){ var localvar = thatFunc.SomeFunc(<value obtained by restful call>); <some operations with localvar>; }); };

Categories : Javascript

Meteor http get call
Please update the url by adding http:// at beginning. Moreover make this call from your server, i.e. Make a method that contains the above code and call that method via Meteor.call(); Please see Meteor.methods() and Meteor.call()

Categories : Javascript

How to call android GCM from meteor
I've made a package that could use this. I haven't got the chance to put it on atmosphere yet. (Here it is on dropbox: https://www.dropbox.com/s/1mpwygl30deo1es/node-gcm.zip) You can use gcm as on https://github.com/ToothlessGear/node-gcm anywhere on your server side javascript code. e.g (simplified version that can work) var message = new gcm.Message(); var message = new gcm.Message({ collapseKey: 'demo', delayWhileIdle: true, timeToLive: 3, data: { key1: 'message1', } }); var sender = new gcm.Sender('insert Google Server API Key here'); var registrationIds = []; registrationIds.push('regId2'); sender.send(message, registrationIds, 4, function (err, result) { console.log(result); }); To make a call from the client you need to interface it with a M

Categories : Android

Meteor.call failing within stub?
You have to use more code. fileReader is the HTML5 api that can read files you put up in an <input type="file" or drag and drop into the window. So when a file is loaded into the browser the fileReader.onload is called with file as the file which was loaded into the browser. It looks like the gist is similar to Meteor-File a package on the atmosphere repository. But not all the code is present in that gist. Luckily Chris Mather who built it made videocasts explaining in depth how it's made : http://www.eventedmind.com/posts/meteor-build-a-file-upload-package

Categories : Javascript

Storyboard prototype cell attributed text label does not display same as prototype
When you set the label's text in code, the storyboard attributes are overwritten. One way to solve this is to copy the attributes from the label and and then reapply them when setting the text: UILabel *label = cell.lblAmount; NSMutableDictionary *existingAttributes = [[NSMutableDictionary alloc] initWithDictionary:[label.attributedText attributesAtIndex:0 effectiveRange:nil]]; label.attributedText = [[NSAttributedString alloc] initWithString:@"12,345.67" attributes:existingAttributes]; Note that you don't need to do this with the built in labels, e.g. textLabel. I think the table view is somehow re-applying the storyboard attributes before displaying the cell.

Categories : IOS

Meteor http.call does not work correctly on server
I think it's a problem with your API, not with Meteor. This http call seems to work for me (server): Meteor.http.call('PUT','http://sciencesoft.at/latex', {content: sentxml, params: {src: latexsrc}});

Categories : Meteor

How to prototype a duplicate prototype method for Array in javascript
The code inside the loop changes the length of the array, so it will just keep growing and you will never reach the end of it. Get the initial length of the array in a variable and use in the loop condition. You can use that as offset for the target index also instead of another counter: var array = [11,22,3,34,5,26,7,8,9]; Array.prototype.duplicate = function() { var len = this.length; for (var i = 0; i < len; i++) { this[len + i] = this[i]; } return this; }

Categories : Javascript

Meteor (js framework) : How can I call a function on the server from an event on the browser?
Add a method at the server using Meteor.methods, then on the client use Meteor.call. http://docs.meteor.com/0.6.0/#meteor_methods http://docs.meteor.com/0.6.0/#meteor_call

Categories : Javascript

Collections inside Meteor.call doesn't update server data
Your method has to be defined on the server if you want to update the real server database. If you define it on the client as well it will be run first ("latency compensation)". Questions = new Meteor.Collection("questions"); Meteor.methods({ post: function(title){ Questions.insert({title: title}); } }); if (Meteor.isServer){ Meteor.publish("questions", function(){ return Questions.find(); }); } if (Meteor.isClient){ var questionHandle = Meteor.subscribe("questions"); $('.save').on('click', function(){ var title = $('input[name="title"]').val(); Meteor.call('post', title); }); } You can see the doc, and EventedMind screencast.

Categories : Meteor

WARNING Error: Meteor code must always run within a Fiber when call method on server
i think you should wrap your callbacks with Meteor.bindEnvironment rather than use fibers directly - see here https://gist.github.com/possibilities/3443021 i use this quite extensively and it works well because you stay within the fiber rather than leaving and having to re-enter normal callback style someMethod({OPTIONS}, function(callbackReturnArgs){ //this is the normal callback )); bind environment wrapped callback someMethod({OPTIONS}, Meteor.bindEnvironment( function(callbackReturnArgs){ //this is the normal callback }, function(e){ console.log('bind failure'); } )); if you consistently wrap async callbacks like this, meteor is always accessbile for this bit here Fiber(function(){ Meteor.call('streamTwit', twit); }).run(); you do not need to fiber

Categories : Mongodb

How can I map a prototype function to an array of objects that have that prototype?
if your method expects one argument, then it's easy. If you need more than one argument, or more importantly, not a number as a 2nd argument (think .toString), then you can use bind to curry this into the 1st argument: "a,b,c".split(",").map( Function.call.bind( "".big ) ); in your code: [object_with_the_prototype] .map( Function.call.bind( thisObject.some_prototype_function ) ); if your method calls like x(a,b,c), the bound function calls like x(this, a, b, c)

Categories : Javascript

Meteor RangeError: Maximum call stack size exceeded. on keypress event
Changing this: Template.modules.events({ 'keypress input#search': function (event) { Session.set("currentFilter", $('input#search')); } }); To This: Template.modules.events({ 'keyup input#search': function (event) { Session.set("currentFilter", $('input#search').val()); } }); I believe you just need the .val() on the jquery dom reference of the input field. Additionally I would recommend using keyup for the event for something like this. For getting the results out like you want you likely want to use a regular expression. Here's what I'm using in my app. Template.hudlies.found = function() { var searchVal = Session.get("searchFilter"); if (searchVal != "") { var searchResults = Hudlies.find({ name: { $regex: '^.*' + searchVal + '.*', $options: 'i' } }); };

Categories : Meteor

How to get more than 1 stock information per call on Google Financials?
Since there are limitations and you are making repeted tests, I suggest using a cache : You can then repeat the test without hitting the limit (assuming you request always the same data for the same date, i.e. using StockInfoSnapshot). You do it by wrapping FinanceApp.getHistoricalStockInfo() so that it serves from the cache if possible, or add to it if info is not available. The cache could conveniently resides in the "script-related storage" : https://developers.google.com/apps-script/script_user_properties Good luck !

Categories : Google Apps Script

Keeping the information obtained in a $.ajax call's done(...) method
Yes, you are right you are assigning to a global variable in your .done, There's nothing wrong in that, the problem is that you are trying to use that global variable before your ajax call is completed (i.e before your .done is executed). That is because of asynchronous behavior or ajax. One bad way to make it work is to make your ajax call synchronous with async:false

Categories : Javascript

How to pass call stack information to an exception using EurekaLog?
EurekaLog exposes several event handlers like OnExceptionNotify. You can implement these in your code. For example: procedure EurekaLogExceptionNotify( EurekaExceptionRecord: TEurekaExceptionRecord; var Handled: Boolean); Here you can see a TEurekaExceptionRecord which is defined in ExceptionLog.pas. But you maybe just own the non-source version which works just fine. The record has a EurekaExceptionRecord.CallStack list. This proprietary list can be converted to TStringsusing the CallStackToStrings method which is also defined in the ExceptionLog unit. Here is an example where I write the CallStack into a StringList. CallStackList := TStringList.Create; try CallStackToStrings(EurekaExceptionRecord.CallStack, CallStackList); LogMessage := 'An unhandled exception occured. He

Categories : Delphi

How to get contact images from recent call information in Android
use the contact id to get the contatct photo URI. Use the following code for getting photo URI: import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; public Uri getPhotoUri(long contactId) { ContentResolver contentResolver = getContentResolver(); try { Cursor cursor = contentResolver.query(ContactsContract.Data.CONTENT_URI,null,ContactsContract.Data.CONTACT_ID+ "="+ contactId+ " AND "+ ContactsContract.Data.MIMETYPE+"='"+ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE+ "'", null, null); if (cursor != null) { if (!cursor.moveToFirst()) { return null; // no photo } } else { return null; // error in cursor process } } catch (Exception e) { e

Categories : Android

JavaScript: why use prototype to call a function instead of just calling the function?
The key benefits are realized when "arr" is not an array, but something like an array; specifically, something with a "length" property and numerically-keyed properties. Good examples are the arguments object and NodeList objects from a DOM. Those things won't have a "slice" method, but they do have numerically-keyed properties and a "length" property. The trick works because the "slice" method is pretty forgiving. If you see it being used with something that's definitely an array already, then you're looking at code written by a confused person :) Oh, and note also that a short-cut is: var foo = [].slice.call(arguments, 0); You don't have to go to the prototype directly if you don't want to; you can get at it from an array instance just as easily. (Yes, it costs a dummy allocation,

Categories : Javascript

API call returning extra unnecessary HTML header information
Another (convoluted) solution is to run it through this HTML Sanitizer API - https://www.mashape.com/pbkwee/html-sanitizer#!endpoint-HTML-Sanitizer I ran your output above and it almost removed everything, except it padded div tags at both ends (well you can remove them)

Categories : Javascript

how to dump the call stack information for native(C/C++) process explicitly when it is not crashed in linux
Throw an exception and catch it immediately. I'm not familiar enough with C but in java this would look like this: try { throw new RuntimeException("bla bla"); } catch (Exception ex) { ex.printStackTrace(); }

Categories : Android

Meteor Call Server Method in Client Got 404 Method Not Found Error
It looks like your code is only running on the client side. Move the block inside the if (Meteor.isServer) to a javascript file in the /server directory of your project. Code inside the /client directory wont run on the server at all, so Meteor.isServer would always be false and the method would never get created on neither the client or server

Categories : Meteor

in Meteor.template.rendered how to make a call after everything is rendered (after the {{#each}} loop finishes)
I've found Meteor to be a little funny with how often it renders templates, and jQuery functions can end up building up. I've taken to adding console.log("users rendered"); to understand how many times and when the render callback is triggered. One thing I've had some success with is wrapping that template inside another, and then tying the callback to the outside template. Something like this: <template name="container"> {{> users}} </template> <template name="users"> {{#each user}} <li id="{{_id}}"> <input type="checkbox" checked /> <span><select name="colorpicker"> {{#each color}} <option value="{{mColorCode}}" {{selected ../mColor mColorCode}}>{{mColorName}}</option&

Categories : Meteor

Meteor: Could a race condition happen with Meteor.collections on server side?
In Meteor's concurrency model, you can imagine a whole method as an uninterruptible block of stuff that happens. In order for Meteor to switch from running one method midway to say, starting another method, you need to "yield"—the method needs to signal, "I can be interrupted." Methods yield whenever they do something asynchronous, which in practice means any time you do a database update or call a method with a callback in Meteor 0.6.5 and later. Since you give your update call a callback, Meteor will always try to do something in between the call to update and the update's callback. However, in Meteor 0.6.4.2 and earlier, database updates were uninterruptible regardless of the use of callbacks. However, multiple calls to saveOnServer will happen in order and do not cause a race condi

Categories : Javascript

Meteor: meteor-collectionapi PUT overwrites the entire object instead of just updating the field I want
I'm guessing that bash is replacing "$set" with an empty environment variable eg. echo "$set" vs echo "$set" so update your PUT command to: curl -H "X-Auth-Token: 97f0ad9e24ca5e0408a269748d7fe0a0" -X PUT -d "{"$set":{"gender":"Female"}}" http://localhost:3000/collectionapi/players/8BW9Yg2oKByBGdnSa By default Collection.update() will replace a document if no modifiers are present ($set, $unset, $push, $pull etc). So the command being sent to the server is to replace the document with {"":{"gender":"Female"}}

Categories : Api

Trying to configure meteor with haml and coffeescript and getting error during meteor startup
there are some work arounds as to where you can install NPM packages directly in Meteor . But the standard practice right now is to use Meteorite for packages. I have not found an HTML preprocessor package that did not give me headaches with MEteor, though, so you might be better off sticking with handlebars. Best of luck!

Categories : Meteor

How to identify a a javascript prototype method callee's name from another prototype method
You need to name your function expressions. Try this: function MyClass1() { this.myAttribute1 = 123; } MyClass1.prototype.foo = function foo() { // I named the function foo var myclass2 = new MyClass2; myclass2.moo(); }; function MyClass2() { this.mySomething = 123; } MyClass2.prototype.moo = function moo() { // I named the function moo console.log("arguments.callee.caller.name = " + arguments.callee.caller.name); console.log("arguments.callee.caller.toString() = " + arguments.callee.caller.toString()); }; See the demo: http://jsfiddle.net/QhNJ6/ The problem is that you're assigning a function which has no name to MyClass1.prototype.foo. Hence it's name property is an empty string (""). You need to name your function expressions and not

Categories : Javascript

inherit prototype methods from other classes without overriding own prototype methods
The best example I can think of comes from: http://robertnyman.com/2008/10/06/javascript-inheritance-how-and-why/ function Being() { this.living = true; this.breathes = function () { return true; }; } function Robert() { // Robert.prototype = new Being(); /* edit */ this.blogs = true; this.getsBored = function () { return "You betcha"; }; } Robert.prototype = new Being(); Robert.prototype.newMethod = function() { console.log('new method executed'); return this; } Note this example, has been updated, the first comment below is directed at the first code I had up, which contained the prototype inside the Robert method.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.