FAQ Database Discussion Community


Caliburn.Micro attach event handler on event of Behavior

c#,xaml,winrt-xaml,caliburn.micro,behavior
I wrote my own Behavior to handle a swipe gesture and put it to the ItemTemplate of a ListView. If a swipe is completed, I raise an event for LeftSwipe or RightSwipe. This event should be handled by my ViewModel. I use the syntax of Caliburn.Micro to attach handler to...

Groovy in jenkins behaviour of list after applying remove()

groovy,jenkins,behavior
I'm quite a beginner when it comes to working with jenkins+ groovy. I'm working on a groovy script to identify the current queued jobs and remove any duplicates if they have a specific string in their name. What I currently have is the following: import hudson.model.* q = jenkins.model.Jenkins.getInstance().getQueue() items...

OnDetaching function of behavior is not called

wpf,events,mvvm,memory-leaks,behavior
I have WPF behavior on specific control. When I close the window that hold the control the OnDetaching function is not called. The behavior continues to exist (because of the events to which it's registered), although the window does not exist anymore (memory leak). Why the OnDetaching function does not...

printf() function behavior

c,printf,behavior,format-specifiers
int main(){ // Comment the next line, Garbage value is printed. However, this shows an integer value. int x=32; printf("%d"); return 0; } Any reason for this behaviour, or is it random??...

Strange Behavior: Floating Point Error after Appending to List

python,python-2.7,behavior
I am writing a simple function to step through a range with floating step size. To keep the output neat, I wrote a function, correct, that corrects the floating point error that is common after an arithmetic operation. That is to say: correct(0.3999999999) outputs 0.4, correct(0.1000000001) outputs 0.1, etc. Here's...

RadioButtons with behavior bind to single property

c#,wpf,xaml,behavior
I'm having few RadioButtons and I don't want to bind "IsChecked" property of each one of them to unique property in the code. I want to have a single property like "CurrentSelected" and according to that to set the "IsChecked". In addition I don't want to use converters. I...

UML representation of PHP trait

php,symfony2,uml,behavior,trait
I'm creating projects with Symfony2/Doctrine and try to implement traits. So far no problem on small tryouts, but I usually do UML class and sequence diagrams before deep in complex projects. What is the UML design object(s) to be used to symbolize PHP traits, which can be seen as far...

Why SHA256 hashes finish with β€œ = ”?

base64,behavior,sha256
I've made a Webservice which returns a security Token after a successful authentification. However when debugging I noticed that every hash the webservice returned finishes with "=" such as: "tINH0JxmryvB6pRkEii1iBYP7FRedDqIEs0Ppbw83oc=" "INv7q72C1HvIixY1qmt5tNASFBEc0PnXRSb780Y5aeI=" "QkM8Kog8TtCczysDmKu6ZOjwwYlcR2biiUzxkb3uBio=" "6eNuCU6RBkwKMmVV6Mhm0Q0ehJ8Qo5SqcGm3LIl62uQ=" "dAPKN8aHl5tgKpmx9vNoYvXfAdF+76G4S+L+ep+TzU=" "O5qQNLEjmmgCIB0TOsNOPCHiquq8ALbHHLcWvWhMuI=" "N9ERYp+i7yhEblAjaKaS3qf9uvMja0odC7ERYllHCI="...

Java: Unexpected behaviour with concatenating a String and an expression using the plus + operator

java,string,operator-keyword,behavior
Consider the following piece of code public class Test { public static void main(String... strings) { System.out.println("String, " + false); System.out.println("String, " + getFalse()); System.out.println("String, " + new TestClass()); System.out.println("String, " + (new TestClass() == null)); System.out.println("String, " + new TestClass() == null); } private static class TestClass { public...

CommandParameter always passes EventArgs with ElementName binding, no actual binded value

c#,mvvm,windows-phone-8.1,behavior
So, with the Behavior SDK I want to bind a Pivot event to my viewmodel. The binding looks like this: <Pivot Grid.Row="1" x:Name="pvtMain" ItemsSource="{Binding Items}" HeaderTemplate="{StaticResource PivotHeaderTemplate}"> <Interactivity:Interaction.Behaviors> <Core:EventTriggerBehavior EventName="PivotItemLoading"> <Core:InvokeCommandAction Command="{Binding LoadAdditionalData}"/> </Core:EventTriggerBehavior> </Interactivity:Interaction.Behaviors> </Pivot> The action that is performed in the...

why do print and echo behave differently in a β€œfor” loop [duplicate]

php,for-loop,printing,echo,behavior
This question already has an answer here: How are echo and print different in PHP? [duplicate] 6 answers If I use print in this code: <?php for($i = 1; $i <= 3; print $i . "\n") { $i++; } ?> I see as output this: 2 3 4 But...

CakePHP behavior not working with bindModel

cakephp,model,controller,bind,behavior
I have a model named Users defined as: class User extends AppModel { ... public $actsAs = array( 'Date' => array('date_birth') ); ... The Date behavior converts the field date_birth from iso format ('yyyy-mm-dd') to locale format ('dd/mm/yyyy'). When from my controller I do a find such as $this->User->find(...) the...

Runtime error on Ideone but works fine on my computer

c,arrays,runtime-error,behavior
I was writing a program for finding out Intersection of two sorted arrays in C language. The code works fine when I compile it with GCC on my machine and run it, but gives a runtime error on ideone.com. Here is the Live link to the below code: #include <stdio.h>...

How to call all event handler subscribers and get their result?

c#,.net,oop,events,behavior
I have this snippet : public static void Main() { OnComparaison += LePlusPetit; OnComparaison += LePlusGrand; Console.WriteLine(OnComparaison(0, 9)); Console.ReadKey(); } public static int LePlusPetit(object obj1, object obj2) { int int1 = (int)obj1; int int2 = (int)obj2; return (int1 < int2) ? int1 : int2; } public static int LePlusGrand(object obj1,...

Does realloc() invalidate all pointers?

c,pointers,dynamic-memory-allocation,behavior,realloc
Note, this question is not asking if realloc() invalidates pointers within the original block, but if it invalidates all the other pointers. I'm new to C, and am a bit confused about the nature of realloc(), specifically if it moves any other memory. For example: void* ptr1 = malloc(2); void*...

Populating Yii2 Model via behavior

php,yii2,behavior
I'm trying to assign a value to the property with behavior, but no matter what value I pass to $this->owner->property the model assigns this number "127" to the property and saves it. I can't figure out where this number comes from. namespace common\behaviors; use yii\db\ActiveRecord; use yii\base\Behavior; class MyBehavior extends...

Attach behavior globally for all models in application config (without inheritance)

php,yii2,behavior
I'm dealing with a problem for Yii2 on adding TimestampBehavior to run from main config. The reason is that i have to use it in frontend and backend on most of my models. To use it in a model is simple : public function behaviors() { return [ [ 'class'...

Yii behaviors won't save data

php,yii,many-to-many,behavior
I'm trying to save relations in third table 'Relations'. Here's code: Controller save action: $relations = $_POST['VideoCaptions']['countries']; $model->attachBehavior('ManyToManyRelationBehavior', array( 'class' => 'ManyToManyRelationBehavior', 'modelNameRelation' => 'Relations', 'firstField' => 'video_captions', 'secondField' => 'video_countries', 'relationList' => $relations, )); ManyToManyRelationBehavior class afterSave action: if (is_array($this->relationList)){ $model_ = $this->modelNameRelation;...

Unexpected replacement of zero in Python list comprehension

python,list,list-comprehension,behavior
I was looking at a stackoverflow question (if else in a list comprehension) and decided to try the following line [ a if a else "Exception" for a in range(10) ], and got the following list [ "Exception", 1, 2, 3, 4, 5, 6, 7, 8, 9 ] as an...

Behavioral into FlipFlop Structural

process,vhdl,behavior,flip-flop
In this code, when reset equals 1 the s becomes 1000 and when reset equals 0 the s becomes 0100 then 0010 then 0001 and it starts all over again with 1000 as the start value, only if the clock is up. library IEEE; use IEEE.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity clock_behav...

Form with OLE control is unable to receive focus properly

focus,ole,behavior,visual-foxpro
I have a form, which has 2 checkboxes, one of them is Ole Control : Now, if I call them twice, there will be 2 instances of the form, the problem is : Says the focus is now on form 1, and I click on the Ole Control (checkbox), I...

Why extended ASCII (special) characters take 2 bytes to get stored?

c++,c++11,byte,ascii,behavior
ASCII ranging from 32 to 126 are printable. 127 is DEL and thereafter are considered the extended characters. To check, how are they stored in the std::string, I wrote a test program: int main () { string s; // ASCII s += "!"; // 33 s += "A"; // 65...

What is the difference between trait and behavior in cakephp 3?

behavior,cakephp-3.0,trait
I find soft delete in cakephp 3 that implemented via traits. And I try to implement it via behaviors. But unlike the trait version, SoftDeleteBehavior do not work. I have this line in my model initialize method: $this->addBehavior('SoftDelete'); And this is my SoftDeleteBehavior namespace App\Model\Behavior; use Cake\ORM\Behavior; use Cake\ORM\RulesChecker; use...

Java: Peculiar division behviour [duplicate]

java,math,behavior
This question already has an answer here: Why does the division of two integers return 0.0 in Java? 5 answers I would expect System.out.println(13 / 31) to print 0.419354838709677. It prints 0.0. Why?...