scope

jinja template variable assignment scope

人走茶凉 提交于 2019-12-10 18:43:12
问题 Given the following Jinja snippet {% set sep='' %} {% for stamp in stamp_list -%} {%- for heartbeat in heartbeat_list -%} {%- if heartbeat.name == site.name and heartbeat.stamp == stamp.stamp -%} {{- heartbeat.sc_time -}} {{- sep -}} {% set sep=',' %} [PROOF for new value {{ sep }}] {%- endif -%} {%- endfor -%} {%- endfor %} Look at the sep variable (short for separator) I want to separate the sc_time with comma's.. like 3.13,2.5,1.33,... So I introduce the var sep, which I change in the

C Prototype scope

老子叫甜甜 提交于 2019-12-10 18:38:54
问题 I learnt that the type specifier that declares the identifier in the list of parameter declarations in a function prototype (not part of a function definition), the identifier has function prototype scope, which terminates at the end of the function declarator. Please see the C program mentioned below. void fn (struct st {int a;} a, struct st b) ; struct st obj ; Compilers promptly issues an error as 'obj' size is unknown (or) struct st is not a 'type'. That's right! the declaration of the

Ionic: Preserve $scope when navigate to another view

爷,独闯天下 提交于 2019-12-10 18:36:36
问题 I'm developing an app using Ionic Framework (Angular+Cordova). The app have a News section with a list of news loaded from a server in JSON, then I tap in a new to open the Single New's View, but when go back to the list of news, $scope has been cleared and must get again the news list from the server. Is this the usual behavior or am I doing something wrong? How could I prevent this behavior? Thanks! 回答1: You should save this kind of data in a separate service, something in the line of this:

Scope on each last elements of a has_many relation

耗尽温柔 提交于 2019-12-10 18:35:12
问题 Let's say I have a has_many relation between User and Messages. I'd like to set a scope to be able to filter users by the ones who have something in the last message they posted. So searching only among each user's last message. Below I got the results among all messages... class Contact < ActiveRecord::Base has_many :messages scope :filter_by_last_messages, lambda { |value| joins(:messages).where("messages.content = ?", value) } end 回答1: Doing this in one shot in a scope is not possible but

How to get a scope for all database rows in rails 3?

≡放荡痞女 提交于 2019-12-10 18:16:35
问题 assume we the following setup: class Post < ActiveRecord::Base belongs_to :user end class User < ActiveRecord::Base has_many :posts end assume further the user has a boolean attribute 'admin', which indicates if he is a global admin or not. I want to write a method (or a scope?) for the User class, called 'visible_posts'. If the user is no admin, it should return just its own posts. If he IS admin the method should return all posts in the system. My first attempt was something like this:

Add-Type in a function contained in a module

蓝咒 提交于 2019-12-10 18:15:52
问题 I'm not sure why this is failing, but if I Add-Type from a function then for whatever reason my code fails when I need to use the *.dll api. function Add-References { Add-Type -Path "C:\myDllPath.dll" Add-Type -Path "C:\myDllPath2.dll" } I have tried making the function global, the dot operator... Keep in mind this function is contained in a module and is being called by a script. My goal is to just use the function to declare my references rather than copy paste these paths in all of my

CORONA: timer.cancel() returns “Attempt to index a nil value”

大兔子大兔子 提交于 2019-12-10 18:13:46
问题 I'm trying to cancel a timer started in a "touch event" function inside another "touch event" function, as shown below: local function startNewGame(event) if(event.phase=="ended")then local function animationImmaginiOggetti() for i=1, 7 do transition.to(immaginiOggettiAvvioPartita[i], { time = 200, delay = 0, xScale = 0, yScale = 0, alpha = 0}) end end local function removeImmaginiOggetti() if immaginiOggettiAvvioPartita[1] then for i=1, 11 do immaginiOggettiAvvioPartita[i]:removeSelf()

Template + Friend (a deadly combination) [duplicate]

帅比萌擦擦* 提交于 2019-12-10 18:12:04
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Making an undefined class as friend, and defining it later. I have the following code template<typename T> class A { class B; B b; }; int main() { return 0; } The code doesn't emit any error because A is not instantiated. Am I right? But have a look at the second code sample template<typename T> class A { protected: class a { int x; int y; private: friend class b; }; template <typename U > class b { int z; U y;

Validation Error: Redefined outer name from outer scope

妖精的绣舞 提交于 2019-12-10 18:07:06
问题 Not sure I get this but I got a validation error from pyLint saying: Redefining name 'a' from outer scope (line 443) (redefined-outer-name) Redefining name 'b' from outer scope (line 444) (redefined-outer-name) The code is like this: a = 98 # line 443 b = 90 # line 444 def prodNr(a, b): """Definiera prodNr""" return a * b result = prodNr(a, b) ANSWER = result Could anyone please give me a clue on how to get rid of the validation error? 回答1: Call you variables something else: def prodNr(a, b):

Is this good writen transaction in stored procedure

廉价感情. 提交于 2019-12-10 17:31:33
问题 This is the first time that I use transactions and I just wonder am I make this right. Should I change something? I insert post(wisp). When insert post I need to generate ID in commentableEntity table and insert that ID in wisp table. ALTER PROCEDURE [dbo].[sp_CreateWisp] @m_UserId uniqueidentifier, @m_WispTypeId int, @m_CreatedOnDate datetime, @m_PrivacyTypeId int, @m_WispText nvarchar(200) AS BEGIN TRANSACTION DECLARE @wispId int INSERT INTO dbo.tbl_Wisps (UserId,WispTypeId,CreatedOnDate