instance

Why javascript function has instance per call?

醉酒当歌 提交于 2019-12-24 13:10:06
问题 The javascript introduction says: When I have code like below: var Person=function(name){ this.name=name; this.sayHello=function(){return 'Hello '+name;} } Whenever I instantiate a "Person", there will be a copy of "sayHello" function in the memory. To reduce this memory consumption, I can change the code like below: var Person=(function(){ var sayHello=function(){return 'Hello '+name} return function(name){ this.name=name this.sayHello=sayHello } })() In this way, there'll not be multiple

Access instance variables from an activity inside a AsyncTask

南楼画角 提交于 2019-12-24 11:25:15
问题 I have an AsyncTask (in a separate file) which is invoked on an activity. When I instantiate the AsyncTask, I send the activity as a param. How can I access the acitivity's instance variables from the onPostExecute method of the AsyncTask? Thanks! 回答1: You must be careful when passing an Activity or Context to an AsyncTask that is not an inner (non-static) class of an Activity - this is because in this case the lifetime of the Activity / Context and the AsyncTask are different, and if you

How to access already running instance of a class without creating an actual object

只愿长相守 提交于 2019-12-24 10:44:25
问题 I have a problem with Java GUI. It is hard to explain but I will do my best. I have 2 GUI classes one is class I and other is class G. Class I is initiated from main method. In the class I there is a field (instance of) class G. Reason being that class I collects vital information and passes it to instance of class G. When a button pressed in class I, that sets the class I frame visibility to false and instance of class G to true (showing up the G interface). Problem here is that I want to be

Preventing Google App Engine Cron jobs from creating multiple instances (and thus burning through all my instance hours)

℡╲_俬逩灬. 提交于 2019-12-24 08:39:15
问题 Very related to this question (How can I prevent my Google App Engine cron jobs from burning through all my instance hours?), yet unfortunatly I not only experience something similar, in my Cron-jobs in Appengine multiple instances are created, which causes quite a high number of Instance hours to be billed. I tried different intervals to determine whether this has an effect on the instance hours, but cannot determine the difference currently. To illustrate, I got billed App Engine Frontend

Instancing new objects in javascript

限于喜欢 提交于 2019-12-24 08:14:35
问题 I'm probably missing something really basic on javascript knowledge, but why doesn't this work? var person = { name:"", age:0, set : function(name,age){ this.name = name; this.age = age; } } var me = new person; // ERROR: Object doesn't support this action! me.set('Victor',12); me.name //Victor But this does: var person = function(){ this.name=""; this.age=0; this.set = function(name,age){ this.name=name; this.age=age; } } var me = new person(); //WORKS! me.set('Victor',12); me.name; //Victor

Error binding type variables in instance of typeclass

牧云@^-^@ 提交于 2019-12-24 08:14:10
问题 I have a class "Shape" which should have "area" defined on all instances. area returns "Area b" (a data type) that contains a number (b belongs to Num typeclass) signifying the area of that Shape. Haskell has problem binding that b to (x*y) where x and y are of type 'a' and 'a' is also of typeclass Num. How do I solve this ?? [If i replace (x*y) by 0, it works but doesn't work even with (0::Int)] Code : data Unit = Unit | Meter | CentiMeter deriving Show data Area a = Area a Unit deriving

How many Vertica Databases can run on a Host in the same time?

ぐ巨炮叔叔 提交于 2019-12-24 05:40:12
问题 I know in Oracle i can have multiple homes running on the same host ? Can this be done in Vertica to ? i am running CE vertion of Vertica and it seems i can not do this !! 回答1: They don't allow multiple databases within a single instance of vertica to be active; it makes sense that they wouldn't allow multiple instance of vertica, resulting in multiple databases, active at the same time. EDIT: Reasons I say it makes sense: Vertica can be resource intensive. It is designed to deal with A LOT

Missing instances for ResourceT in conduit

五迷三道 提交于 2019-12-24 05:06:26
问题 I'm getting a strange error when trying to use ResourceT from conduit 1.0.9.1. I'm missing instances from the documentation. For example import Control.Monad import Control.Monad.Trans import Control.Monad.IO.Class import Data.Conduit test = runResourceT (lift $ print "Hello world") fails with No instance for ( MonadTrans ResourceT ) arising from a use of lift , although there are many instances in the docs, including MonadTrans ResourceT . Checking REPL confirms the problem: Prelude> :m Data

Missing instances for ResourceT in conduit

偶尔善良 提交于 2019-12-24 05:06:05
问题 I'm getting a strange error when trying to use ResourceT from conduit 1.0.9.1. I'm missing instances from the documentation. For example import Control.Monad import Control.Monad.Trans import Control.Monad.IO.Class import Data.Conduit test = runResourceT (lift $ print "Hello world") fails with No instance for ( MonadTrans ResourceT ) arising from a use of lift , although there are many instances in the docs, including MonadTrans ResourceT . Checking REPL confirms the problem: Prelude> :m Data

How can I prevent my Google App Engine cron jobs from burning through all my instance hours?

一个人想着一个人 提交于 2019-12-24 04:03:15
问题 I have a google app engine where I have scheduled several cron jobs as database cleanup tasks, but these cron jobs are burning through all my instance hours (front or back), even though the actual processing time of each of these jobs is almost nothing. Am I doing something wrong? Is there a way I can configure these background tasks to occur without wasting all my instance hours? 回答1: Take a look at the documentation here: http://code.google.com/appengine/docs/adminconsole/instances.html