scoping

backbone.js Model.get() returns undefined, scope using coffeescript + coffee toaster?

谁都会走 提交于 2019-12-10 16:39:19
问题 I'm writing an app using coffeescript with coffee toaster (an awesome NPM module for stitching) that builds my app.js file. Lots of my application classes and templates require info about the current user so I have an instance of class User (extends Backbone.Model) stored as a property of my main Application class (extends Backbone.Router). As part of the initialization routine I grab the user from the server (which takes care of authentication, roles, account switching etc.). Here's that

Eagerloading with scoping in rails3

主宰稳场 提交于 2019-12-10 13:02:47
问题 I have been trying to eager load associations based on some scope in my rails3 app, but could not find any solution. My app has following models: class Project has_many :entries has_many :to_dos class ToDo has_may :entries has_many :tasks belongs_to :project class Task has_many :entries belongs_to :to_do class Entry belongs_to :project belongs_to :to_do belongs_to :task # options format: {:from_date=>(Date.today-1.week), :to_date=>(Date.today+1.week), :user_id=>60} scope :filtered_list,

Why does my R run in dynamic scoping? Shouldn't it be lexical?

霸气de小男生 提交于 2019-12-09 03:58:41
问题 I just learned in class that R uses lexical scoping, and tested it out in R Studio on my computer and I got results that fit dynamic scoping, not lexical? Isn't that not supposed to happen in R? I ran: y <- 10 f <- function(x) { y <- 2 y^3 } f(3) And f(3) came out to be 4 (2^3) not 100 (10^3), even though my class presented this slide: http://puu.sh/pStxA/0545079dbe.png . Isn't that dynamic scoping? I may just be looking at this wrong, but is there a mode on a menu somewhere where you can

double as true / false

泪湿孤枕 提交于 2019-12-08 19:32:01
问题 Bjarne suggests using the condition in if's as scope restriction. In particular this example. if ( double d = fd() ) { // d in scope here... } I'm curios how to interpret the declaration in a true / false sense. It's a declaration It's a double. Edit: It's in 6.3.2.1 The C++ programming language as a recommendation. Edit2: templatetypedefs suggestion of pointers, in particular with dynamic casts, might give insight to Bjarnes suggestion. SteveJessop tells me: - A condition is not an

When should i be opening and closing MongoDB connections?

岁酱吖の 提交于 2019-12-08 15:29:25
问题 i am very new to MongoDB and NoSQL in general and i've just started building a site with MongoDB / Norm / ASP.NET MVC 3. I am wondering how i should be scoping the connections to my Mongo database. Right now i have a Basecontroller that instanciates the MongoSession and onActionExecuted i dispose it so all my deriving controllers will have access to my MongoSession. The MongoSession class opens a connection in its constructor and disposes it on Dispose(), the way it's working today. private

scope of the object literal methods

。_饼干妹妹 提交于 2019-12-08 03:38:16
问题 I am currently doing some experiment about scoping and hoisting in JS.Here i have two example which confusing me in a different way.First i have assigned a anonymous function to a variable named parent.Obviously returned child function has access to its outer function scope so it can access text variable.It is clear and easy.Here is the code.. var parent = function() { var text = 'i can access the container'; return function() { alert(text); } }(); parent(); Later i wanted returned an object

Shallow and Deep Binding

99封情书 提交于 2019-12-08 01:50:27
问题 I was trying to understand the concept of dynamic/static scope with deep and shallow binding. Below is the code- (define x 0) (define y 0) (define (f z) (display ( + z y)) (define (g f) (let ((y 10)) (f x))) (define (h) (let ((x 100)) (g f))) (h) I understand at dynamic scoping value of the caller function is used by the called function. So using dynamic binding I should get the answer- 110 . Using static scoping I would get the answer 0 . But I got these results without considering shallow

Issue with child scoping of this in Typescript

痞子三分冷 提交于 2019-12-07 15:38:11
问题 This is ALMOST the same as every other this scoping question I have read so far other than one slight difference which makes it relevant (imo) to ask this question. Now originally my problem was scoping of this with Knockout and Typescript, so given the following: class ViewModel { public SomeObservableArray = new ko.observableArray(); public AddToTheObservableArray(someJsonData: any) { this.SomeObservableArray.push(new SomePojo(someJsonData)); } } So the this bit in the above code would blow

Rails: default scoping being cached by query cache?

本秂侑毒 提交于 2019-12-07 15:15:32
问题 I got a default scoping like this which is dynamic: default_scope :conditions => ["departure_date >= ?", DateTime.current.beginning_of_day] When I use this code the first day is ok. Lets say first day is 28-03-2011 But the next day seems like it's still using "departure_date >= 28-03-2011" Is my default scoping being cached? 回答1: The problem is that that code is only being executed once , when your app is loaded, and thus the actual date isn't changing. You need to change it to load lazily:

Python scoping problem

Deadly 提交于 2019-12-07 15:11:32
问题 I have a trivial example: def func1(): local_var = None def func(args): print args, print "local_var:", local_var local_var = "local" func("first") func("second") func1() I expect the output to be: first local_var: None second local_var: local However, my actual output is: first local_var: Traceback (most recent call last): File "test.py", line 13, in func1() File "test.py", line 10, in func1 func("first") File "test.py", line 6, in func print "local_var:", local_var UnboundLocalError: local