Will animated feedback be annoying or nice?

Question: I'm developing a website called Fablelane which allows you to write your own stories and have others contribute outcomes or "chunks" to that story.
Right now (if you go to the website), there's an experience bar that advances as the user progresses and stays active. (It works for anonymous users too, don't worry.)
As this bar raises, the header rumbles and shakes. Depending on the level you have reached, the shake, rotation, and rumble is more heavy.
Is this appropriate? or will I have to find other ways to engage my users through gamification?
Comment: I went to look and I found that it doesn't just shake the header but rather the entire page.
Comment: Interesting. Thanks. Which browser? It shouldn't.
Comment: Chrome Version 25.0.1364.160
Answer: Why?
If you're going for gamification, consider something that adds more social value. Something that gives some cred within the community of the site. Or possibly greater privileges within the community. Passing out something like Editor status could answer both of those angles.
But don't offer more irritating site chrome.
Comment: @Mathias: possibly (but none-at-all would still be my preference). Btw, I just happened to spot your comment because I had this page still open in my browser. Please use the `@someone` when responding so someone gets notified. Only post owners (you for the question, plainclothes for this answer) will get notified automatically.
Comment: The site already has privileges. Did you find the vibration annoying? The thing about gamification is that "constant feedback" is a very important element. What can I do to substitute this shake-effect then?
Comment: @Mathias: constant feedback does not equal constant intrusion and that is what shaking a page or part thereof feels to me. And I suspect I am not alone in that considering it is in the same league as all the animated banners, gifs and the like that people tend to tune out.
Comment: If only the header shook, would it be better? It's supposed to be like that, but something is malfunctioning.
Answer: Yes, "shaking the website" shapes the user experience and could be considered gameful. However, every gamification measure should ask the question if it is useful (or only "fancy): which activity are you trying to support? (See S. Deterding: "Don't Play Games With Me!", Fol. 70–73 / 22:04–23:40)
In your case, the only way to know if your method provokes the desired results is to ask the users. In this case, I suspect it's too distracting, esp. as you animate so many things during the writing process. But it really depends on your target user base, if they are children they may even enjoy the immediate gratification because for them, typing a word is hard work.
Answer: Is the shaking and rumbling a direct co-relation to the user's progress? If yes, the that is instant feedback for the user and can be considered a game element leading to a gamified site.
Mark LeBlanc's MDA framework (Mechanics, Dynamics, Aesthetics) is something you should take a look at for getting an idea of good elements for a gamified site.
<code>Dynamics: (high level, conceptual elements. grammar of game. NOT rules. implicit structure)
    - Constraints
    - Emotions
    - Narrative
    - Progression
    - Relationships

Mechanics: (process that drives the action forward. verbs)
    - challenges
    - chance
    - competition
    - cooperation
    - feedback
    - resource acquisition
    - rewards
    - transactions
    - turns
    - win states

Aesthetics/Components: (specific ways to do things. nouns.)
    - achievements          - leaderboards
    - avatars               - levels
    - badges                - points
    - boss fights           - quests
    - collections           - social graph
    - combat                - teams
    - content unlocking     - virtual goods
    - gifting
</code>
The progress bar is a very good indicator, but does it have breakpoints or levels which can lead to unlocking of features or such? That can add a level of engagement.
Even though PBLs (points, badges, leaderboards) are a cliche, this is a good site for such a system. You can get badges for the stories you complete. The definition of badges will depend on the core direction you want to push your audience towards: competition, co-operation, generic fun, or something else.
Also, if you can make it a social experience, it would add a lot of value for the players. Make the objective of the site such that you need to co-operate to 'win'. Something what Stackexchanges do quite well.
And lastly, whatever you do, the system should always have instant feedback for the user's actions. I have explained a briefly how user behavior changes can be achieved using gamification in my other answer: How does Gamification change User Behavior?
Answer: First, I tried to enter an contribution, and when I clicked "Submit" it cleaned the textbox with no apparent action. After spending several minutes writing that contribution, that was very, very frustrating.
Second, the site is heavy with animations, which I found a little disturbing. It felt unstable. Animations are attention grabbers. Take that attention very carefully, and only for a justified reason ("general fun" is not one of them).
Regarding specifically the animation of the bar, I would suggest to animate it immediately after points are earned, and only at that precise moment. This is just when you want to grab the user's attention to that fact. It would enhance both the understanding and the excitement of earning points, which is a most important part of the gamified experience.
Comment: It seems that nothing happened, except the textbox was cleared. The scroll did not move, and I didn't notice anything else happening.
Comment: Thank you so much. What happened with the site after you clicked submit?


Is there any way to add DOM elements only with javascript with number index when added?

Question: I am unable to find any solution of adding DOM elements with text nodes and adding number index in the nodes only using javascript.
I've tried using if..else and for loop but none of them work.
function addElement() {
    var para = document.createElement("p");
    var add = document.createTextNode("This is newly added. ");
    para.appendChild(add);
    var element = document.getElementById("div1");
    element.appendChild(para);
}

Comment: It's a bit unclear what you're asking. Please elaborate the question. Are you looking for an existing DOM element indexing, or do you want to create your own indexing?
Comment: Please include a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve).
Comment: Take a look at the `innerHTML` property. You may find it easier than what you are trying.
Comment: Can you post what you have been trying so far?
Answer: You can append one label element inside the p element with the current length of p as the text of the label:

function addElement() {
  var length = document.querySelectorAll('p').length;
  var para = document.createElement("p");
  var add = document.createTextNode("This is newly added. ");
  var label = document.createElement("label");
  label.textContent = length + ' ';
  para.appendChild(label);
  para.appendChild(add);
  var element = document.getElementById("div1");
  element.appendChild(para);
}
document.getElementById('createElement').addEventListener('click',addElement);
<button type="button" id="createElement">Create Element</button>

Comment: Thank you for the help. This is the exact code what I want.


Conformal mapping of nonsimply connected domains

Question: The question asks: Map the complement of the arc $|z|=1$, $y\geq 0$ on the outside of the unit circle so that the points at $\infty$ correspond to each other. How would you construct such conformal map? I think you need to map the arc to part of real/imaginary axis then use square root function. How would you construct this map in details though?
Thanks
Comment: Could you describe the space a little more precisely? The space your description suggests to me is not simply connected.
Comment: @Travis ... nor is the compplement of the unit disk simply connected.
Comment: Typo, I meant NON-simply connected
Comment: @HagenvonEitzen I interpreted the description of the region to mean $\mathbb{C}$ less the upper unit semicircle, but looking at the answer the region in question seems to be the upper half-plane less that semicircle.
Comment: @amathnerd You should be able to edit your the subject line, e.g., the add the missing prefix "non-$, in this case I did it for you.
Answer: First map $z\mapsto \frac1{z+1}$ to bring $\infty$ to $0$ (because we want to keep an eye on the point at $\infty$). At the same instance, this turns the arc to a half line, ending in $\frac12$. Taking the square root centered at its end point, i.e. applying $z\mapsto \sqrt{x-\frac12}$, we obtain a half plane. You sure know how to turn this into the unit disk. Now watch where $\infty$ has gone in this process and apply a reciprocal map that brings it back to $\infty$. Now you already have a complement of some disk, and after scling and translation it becomes the unit disk.
Comment: Thanks for your dedicated answer. I just got this problem by first using the transformation $T=\frac{z+1}{z-1}$ turn the upper disk into a line, then do some transformation to get the upper half plane. Next, change it to unit disk and invert it.
Comment: but the problem is my way does not preserve $\infty $


Recommended way to estimate the fee required to send a message from an L1 contract to a Starknet contract?

Question: I'm sending a message from an Ethereum contract to a Starknet one via the Starknet core contract's sendMessageToL2 function. This function is payable and I'm meant to send ETH to cover the cost of processing the message at the other end. What I don't know is how to estimate the amount of ETH required, which could vary from one call to another, as the processing required on the receiving Starknet contract will vary.
I have searched the docs, but didn't find anything on this. Until recently everything worked with no fee being sent, but that has been tightened up now.
Answer: You can use Starknet's cli to call a function called estimate_message_fee. See it here. It will tell you how much you should attach to your message.
Under the hood, it is called Starknet's feeder gateway API with the same name "estimate_message_fee". You can also call this one directly. The call should be similar to estimate_fee of which you can find an example here
Happy building!
Comment: OK thanks, I think you are suggesting I do this before deploying my L1 contract so I have a fixed fee that my L1 contract sends every time it calls sendMessageToL2?

If so, then doesn't that require that the processing performed by my Starknet contract in the L1Handler has a fairly predictable and unchanging gas cost? I don't see how to handle the case that the processing cost is only known at the time of sending the message. Is there any way to estimate the fee at the time of sending the message to L2 so that a different fee can be sent each time?
Comment: I meant that you should do this check before sending each individual transaction, actually.
Your contract can have a function `triggerMessage() payable` that passes the necessary fee when called I think.
Comment: Thanks again! My scenario is as follows. I have an L1 contract with a function doSomething(...) that end users will call. doSomething(...) will call sendMessageToL2 with a payload that varies according to what the end user passed to doSomething(). doSomething could be payable or not, if not then my L1 contract covers the cost. My end user knows nothing about the Starknet CLI, they just know how to call doSomething on my L1 contract. Is there a way for the code in doSomething to estimate the required fee and send it, from the balance of the L1 contract, in the sendMessageToL2 call?
Comment: ...or is it necessary to call estimate_message_fee separately, before starting the transaction for doSomething()?
Comment: Hello,
It is necessary indeed to call `estimate_message_fee` separately, off chain, before calling `doSomething`.
Another option would be for your to create a system similar to how the messaging bridge works for L2 -> L1 communication. 1. Pass a message hash to L2, 2. Have this message be registered in a contract on L2, 3. Have automated watchers trigger an action, based on the message


Is it possible to get no-scope kills while using the scope?

Question: I just started playing, and with the starting Gearbox sniper rifle, I shot some people while scoped, but it seemed like those kills registered for the no-scope Sniper Kills Challenge.
I kept sniping enemies, while trying things like releasing the scope right after I fired, to see if that would do it, but no.
Is it actually possible to get "no-scope" kills, while actually scoped?
Answer: No It's not, that is why it's called no scope. You have got to shoot without aiming, but it's way easier to take down large enemies with no scope than small or/and fast enemies, so it might be a glitch or something.
Comment: Yeah, I think I did some no-scope kills, then scoped and did some kills, plus notification lag, and everything got mixed up.
Comment: But you know there could still be a way, Google it if you want. It's useful if you can really no-scope with a scope.
Comment: late but question out of interest. Does that apply to the uniquwe Jakobs Sniper Rife "Buffalo"? This one cannot spawn with a scope


JQUERY: Using sortable() on AJAX-generated results (PHP/MySQL)

Question: I have been playing around with the sortable() functionality and I have got it working fine on static DB results, however I have noticed that I can't get it to work on AJAX-generated DB results. I feel it has something to do with how I call the sortable() function within the $(document).ready(function() however I am not 100% sure. I have searched this forum and other forums to see if anyone else has this problem but I haven't found anything similar yet, so here's my attempt to describe my problem:
I have a MySQL database called 'db_objects' which contains 1 table:
CREATE TABLE IF NOT EXISTS `tbl_objects` (
  `obj_id` int(11) NOT NULL AUTO_INCREMENT,
  `obj_name` varchar(50) DEFAULT NULL,
  `obj_type` int(11) DEFAULT NULL,
  PRIMARY KEY (`obj_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

INSERT INTO `tbl_objects` (`obj_id`, `obj_name`, `obj_type`) VALUES
(1, 'Sam', 1),
(2, 'John', 1),
(3, 'Tom', 1),
(4, 'Bob', 1),
(5, 'Fluffy', 2),
(6, 'Paws', 2),
(7, 'Kitty', 2),
(8, 'Tibbles', 2),
(9, 'Mr. Meow', 2);

Now, I have a HTML page where I want to view the results on this table based on a drop-down box which filters by the obj_type column (1 = human names, 2 = feline names):
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><title>SORTABLE EXAMPLE</title>
<link rel='stylesheet' href='http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css'>

    Click and drag each round to re-order.
Object Type:
    <select id="ajax_select_type">
     <option value="1">Human</option>
        <option value="2">Feline</option>
    </select>

Finally, the above page links to the following PHP page which is called via AJAX:
<?php
 //DETERMINE INPUT VALUES
 $object_type=$_GET["t"];

 //CONNECT TO THE DATABASE
 $con = mysql_connect("localhost","<USERNAME>","<PASSWORD>");
 mysql_select_db("db_objects", $con);

 //GET SQL QUERY
 $q_db_result = "SELECT DISTINCT obj_id, obj_name, obj_type
 FROM tbl_objects
 WHERE obj_type = '".$object_type."'
 ORDER BY obj_name";

 //Execute the FULL_RESULT_QUERY QUERY
 $sql_results = mysql_query($q_db_result) or die(mysql_error());

 //TURN THE RESULTS RETRIEVED INTO AN ARRAY
 $results_array = array();
 while($row = mysql_fetch_assoc($sql_results)){
 $results_array[$row['obj_id']]['obj_name'] = $row['obj_name'];
 $results_array[$row['obj_id']]['obj_type'] = $row['obj_type'];
 }

 //ASSEMBLE THE RESULTS
 if(sizeof($results_array)>0){

 foreach($results_array as $obj_id => $result_details){
 //DECLARE VARIABLES
 $obj_name=$result_details['obj_name'];
 $obj_type=$result_details['obj_type'];

 $return_value .= "

".$obj_name."

\n";
 }

 //PUT THE UL TAGS AROUND THE HTML CODE
 $return_value = "
\n".$return_value."
\n";

 //PUT THE RESULTS IN THE INNER CONTAINER DIV
 $return_value = "
".$return_value."
";

 }else{
 $return_value = "NO RESULTS RETURNED";
 }

 //DISPLAY HTML CODE
 echo $return_value;

 //CLOSE DB CONNECTION
 mysql_close($con);
?>

Now, if you can get this working you will notice that the sortable() functionality does not work. As I mentioned before, I think it has something to do with the fact that the DB results are generated on-the-fly by AJAX, so trying to declare/call the sortable() functionality in the $(document).ready(function() won't work, i.e.
$(document).ready(function() {
 $('#ul_sortable').sortable();
});

I'm not sure how to get around this - does anyone have any suggestions? Thanks in advance!
Answer: you can call the sortable() function after the reponseText is appended  .. so that it gets the dynamically generated DOM elements...
xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){document.getElementById("ajax_results").innerHTML=xmlhttp.responseText;$('#ul_sortable').sortable();}}  //here

Comment: Sorry it took so long to identify this as the correct solution. Worked a charm. Thanks!
Answer: ul_sortable came from ajax_page.php that is not include when your HTML loaded. So you can put $('#ul_sortable').sortable(); after your ajax request is done.
Answer: try using this way:

Not sure but try putting it after your ajax call in the change function of the dropdown within the doc ready handler


Change dictionary values wrong when using KVO with NSOperationQueue?

Question: I was working through an example in the concurrency chapter of "More iPhone 3 Development," and can't get KVO on an NSOperationQueue working as expected. I create an NSOperationQueue and observe its operations array using:
NSOperationQueue *newQueue = [[NSOperationQueue alloc] init];
self.queue = newQueue;
[newQueue release];
[queue addObserver:self
        forKeyPath:@"operations"
           options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
           context:NULL];

When the first NSOperation is added to the queue, I expect it to be added to its underlying operations array (which the iOS documentation says is KVO-compliant) and hence, in the change dictionary, to find a mapping from NSKeyValueChangeKindKey to NSKeyValueChangeInsertion, along with a mapping from NSKeyValueChangeNewKey to the added NSOperation. But I wasn't seeing any kind of value NSKeyValueChangeInsertion.
I know the debugger is pro and all, but in the interest of having something useful to copy here, I started my observer method with:
- (void) observeValueForKeyPath:(NSString *)keyPath
                       ofObject:(id)object
                         change:(NSDictionary *)change
                        context:(void *)context {
  NSNumber *kind = [change objectForKey:NSKeyValueChangeKindKey];
  NSObject *newValue = [change objectForKey:NSKeyValueChangeNewKey];
  NSObject *oldValue = [change objectForKey:NSKeyValueChangeOldKey];
  NSIndexSet *indexes = [change objectForKey:NSKeyValueChangeIndexesKey];
  NSLog(@"kind=%d, newValue=%@, oldValue=%@, indexes=%@",
       [kind integerValue], newValue, oldValue, indexes);

And that prints:
2010-11-18 20:01:56.249 Stalled[2692:6f07] kind=1, newValue=(
    "<SquareRootOperation: 0x5f51b40>"
), oldValue=(
), indexes=(null)

2010-11-18 20:01:56.250 Stalled[2692:6f07] kind=1, newValue=(
    "<SquareRootOperation: 0x5f51b40>"
), oldValue=(
    "<SquareRootOperation: 0x5f51b40>"
), indexes=(null)

(SquareRootOperation is simply my subclass of NSOperation that overrides main appropriately, and Stalled is simply the project name.) But note that the method is called twice upon inserting a single operation, and both times with a kind value of 1, which is NSKeyValueChangeSetting, not NSKeyValueChangeInsertion. Additionally, newValue and oldValue seem to be the array itself, not the item added.
Any ideas? Thanks!
Answer: The docs say -operations is KVO-compliant, but don't specify to what detail the notifications will be. In practice, it seems you are only told that a change has occurred, so would have to compare the old and new values to find out what was inserted.
Don't forget that these notifications can be sent to you on any thread!
Comment: The insert notification will never be sent because the property has type of NSArray (check the documentation) and therefore cannot be inserted into.
Answer: The operations property of NSOperationQueue does not have a mutable type (it returns NSArray*).  It therefore does not implement the indexed to-many compliance methods for mutable arrays so you'll never see the insert events, only the change event for the whole array.
Edit
Shadowmatter has brought up the fact that the actually returned object is an NSMutableArray.  This does not, however, change anything.  Firstly, Apple's documentation is clear on the issue.  If a method is advertised to return an immutable object, you must respect the API.  You must not use isKindOf: to find out if it is really mutable and you must definitely not change it.
The API says the operations return type is immutable and you must therefore treat it as such. More importantly for this question, as it's not a mutable collection property, it is not key value coding compliant for the mutable array KVC values. For mutable indexed collection  compliance, the class has to

Implement one or both of the methods -insertObject:in<Key>AtIndex: or -insert<Key>:atIndexes:.
Implement one or both of the methods -removeObjectFrom<Key>AtIndex: or -remove<Key>AtIndexes:.

(taken directly from the Apple KVC guide)
The designer of the NSOperationQueue class designed the operations property as immutable and therefore deliberately ommitted the above methods.
Comment: OK, maybe you need to re-read the docs on KVO-compliance. When you observe something like `-operations` you are observing the *property*, **not** the *array* itself. The observed object is free to implement KVO-compliance however it likes. Yes, it's easiest to use the automatic support gained from writing accessor methods backed by an `NSMutableArray`. But that approach is **not** a requirement.
Comment: And I assure you, you are wrong. The return type of a method and it's KVO-compliance are **orthogonal**. Indeed a method that returns an `NSMutableArray` will not be KVO-compliant without additional work, since modifying that array directly will not send KVO-notifications.
Comment: Even though it returns type `NSArray`, the real type of the returned value is the subclass `NSMutableArray`. I've confirmed it by using `isKindOf`. Is this not enough?
Comment: Thanks for the answer, JeremyP! The More iPhone 3 Development book actually pointed out that, even though the return value was `NSArray`, the actually instance returned was `NSMutableArray` and so you could observe elements being inserted or removed. I assume that at some point Apple fixed this so that the behavior of the class complied with their own documentation, and now the example is broken. It all makes sense now... Thanks again!
Comment: The array being immutable/mutable has **nothing** to do with KVO-compliance. The docs say `-operations` is KVO-compliant and it is
Comment: @Mike Abdullah:  It has everything to do with KVO compliance.  If your property is a mutable collection, there are **additional** KVO notifications you can get when things are inserted to or removed from  it (as opposed to when the property is reassigned with a new collection).  The questioner was trying to use the mutable collection notification on a property that was an immutable type.
Comment: The array is not the object in charge of KVO notifications, so mutable/immutable has no bearing on the notifications sent. I could quite easily implement an API along the lines of `NSOperationQueue`'s, backed by an *immutable* array, that sends detailed insertion/removal notifications.
Comment: @Mike Abdullah: No you couldn't.  How do you insert into an **immutable** array?  Semantically, it makes no sense.  And this is why the operations have not been implemented in this case.  The property is advertised as immutable.  You don't expect to be able to insert into an immutable object.  You don't expect insert notifications.  You don't *get* insert notifications.  Do you understand now?
Comment: The property is not advertised as immutable as such. There is an `-addOperation:` method! Yes, the returned type of `-operations` is `NSArray`, but I challenge you to find more than a tiny handful of APIs in Cocoa that return `NSMutableArray`.
Comment: You could happily create a property that's backed by an `NSArray` instance. Upon insert, a new array is created (the old array + inserted object), and that replaces the old array. Yes, it's fairly inefficient, but can be useful for properties that are read a lot, but updated rarely.
Comment: @Mike Abdullah: The property is advertised as an NSArray (go and read the official documentation).  That means you **must** treat it as an immutable colllection whether it is implemented as a mutable array or not.
Comment: @Mike Abdullah: And your idea of creating a mutable property by replacing an immutable array will not work.  If a property is advertised as a mutable collection, then it is reasonable for a client to assume that retrieving a reference to the collection and then getting an insert notification will not invalidate the reference, which your implementation does.
Comment: OK, show me some examples from Cocoa that are "advertised as a mutable collection"
Comment: @Mike: Why?  The fact that other properties in Cocoa might by typed as mutable collections would not alter in any way the fact that this one is not.
Comment: @Mike: Will you **please** read what I keep telling you.  The **property** is typed as an **NSArray**.  The **property** is typed as an immutable collection.  Read the documentation for NSOperationQueue **please**.  You'll see the operations property is declared as `- (NSArray *)operations`.  That is why the Apple developers did not see fit to implement the insert/delete notifications.
Comment: @Mike Abdullah: Aha, you are beginning to get there.  We are talking about the KVO **insert** notification which only makes sense where the **property** type is a mutable collection.  Please acknowledge that you understand that.
Comment: What do you mean by "the property type is a mutable collection"?
Comment: @Mike Abdullah: Even properties are declared.  Either there is an `@property (...) someType propertyName;` in the interface or there is a getter (and optionally a setter) method declared e.g. `-(someType) propertyName;`.  In both of these cases "someType" is the type of the property.  According to the Apple documentation, the declaration of the operations type is `-(NSArray*) operations;` that makes it a collection but not a mutable collection.  If it had been  `-(NSMutableArray*) operations;` it would be a mutable collection, but it's not,so the insert notification has not been implemented.
Comment: And if I were writing such a class myself, I most definitely would **not** make an `-(NSMutableArray*)operations` method. By writing such a thing, the queue would have no good way to know when operations were added/inserted/remove, and KVO notifications would **not** be sent. To gain those features, quite a bit more custom code would be required.
Comment: More importantly, the docs show how to be KVO-compliant, which strangely enough, do not involve publishing a mutable array: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ModelObjects/Articles/moIntegrating.html
Comment: @Mike Abdullah, you are right in that respect.  Look at this document for how to properly implement relationship properties that are KVC/KVO compliant http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html%23//apple_ref/doc/uid/20002172-SW2


Filter function for wsapi store not working in Rally SDK

Question: EDIT- ANSWER FOUND
I realize why its not working. The 'filters' config field i was reading about was based on the Ext.data.AbstractStore class's config, not Rally's Rally.data.wsapi.Store config. Rally doesn't support the filter 'functions' becasue all Rally.data.wsapi.Store filters get turned into the wsapi query syntax (I read that in the SDK guide), which you cannot do with functions. That is why they only accept the Object[] argument, not Function[] argument.
So please correct me if I'm wrong, but i believe that the documentation for the wsapi Stores are wrong for the 'filters' config field.

I am trying to use a customized filter function to load Features from a list of User Stories. My issue is with understanding how filter functions work for the store Configuration. Right now i have:
<code>_loadFeatures: function(cb){
    var me = this;
    Ext.create('Rally.data.wsapi.Store',{
        model: 'PortfolioItem/Feature',
        autoLoad:true,
        start: 0,
        pageSize: 20,
        fetch: //stuff
        context: //stuff
        filters:[
            function(feature){ return false; },
            function(feature){
                return feature.get('Release').Name == me.releaseRecord.get('Name');
            },
            function(feature){
                var oid = feature.get('ObjectID');
                var rs = me.StoryStore.getRecords();
                for(var i = 0;i<rs.length;++i){
                    var r = rs[i];
                    if(r.get('Feature') && r.get('Feature').ObjectID == oid)
                        return true;
                }
                return false;
            }
        ],
        listeners: //stuff
    });
},
</code>
There are a few things that are confusing me:
1) One of my functions returning false no matter what, which I believe should return NO results. Yet the store returns all of the Features, like there were no filters at all (it returns the first page of results, but the pages include all features)
2) can we tread the parameters in the filter functions as 'records' or the records' data, similar to record.data. What i mean is should I be using record.get('ObjectID') or record.ObjectID.
3) can I even use the 3rd filter function above, because it requires scoped variables, and
the filtering is done server side. Are the scope variables preserved?.
I don't know the answers to these because i can't put console logs in the filter functions, as they are filtered server side.
Answer: You can still further filter the store on the client side after it has been loaded and remote filtered on the server:
http://help.rallydev.com/apps/2.0rc3/doc/#!/api/Ext.data.Store-method-filterBy
Comment: Thanks, and I did try doing that, but I found out that filterBy only filters on the current page of records, which can make for paged rallygrid to look funny, and have innaccurate pagingToolbar numbers. I had to set limit:Infinity and disable the paging toolbar on my Rally Grid in order to use filterBy.


Dishwasher Hose Clamps won't open

Question: This will come across as a silly question but I cannot open up the hose clamp for my dishwasher's drain tube. I need to unhook/open the tube, clean its head, then reattach. The metal clamp simply won't open, when I use screwdriver, the screw simply won't come out, it just becomes loose in its place but there is no way to take it out. I'm not sure how pliers would help either because I tried pulling the screw out and it didn't work either.

NOTE: I need to use the same hose , so I cannot break this hose. It's FAR beyond my expertise to change the whole tube, I'm just trying to clean the head to open it up. So I need to be able to reattach it.
Thank you very much for your help.
UPDATE:
Sorry for my bad wording: I don't need to reuse/keep the clamp, I just need to keep/maintain the tube/hose because changing it requires taking out the whole dishwasher. My dilemma is cutting the clamp without damaging the hose now.
The END SOLUTION:
Lots of great answers, comments and suggestions. I ended up actually forcing (force pulling) the tube/hose, and took it out. Once it was out, it was easy to just slip the shot clamp!
Comment: The screw doesn't actually come out, your text implies you think that the screw does come out.  Turning the screw causes the clamp to open, the more you turn the more it opens.
Comment: Aside: I'd very highly recommend using a nut driver (usually 1/4") rather than a flathead screw driver. I've seen people injure themselves several times when the screw driver slips out and cuts their hand), and either way it takes at least twice as long to do vs using a nut driver.
Comment: @BeginnerDBA When you say it goes from "tight to loose" I think what you mean to say is the resistance to your turning it alternates from some to almost nothing.  This suggests that the worm is not able to move the band.  That is the screw is slipping over the slots instead of pushing them.  You might want to get one of these at the store (cheap) and take a look at how they work.  If the threads aren't engaging, you might be able to simply pry it loose.  Another option is to squeeze the housing closer to the pipe and then try turning.  That might engage the threads.
Comment: @BeginnerDBA Another thing is that the rubber piece that is connecting the hose to the waste should be easy to replace.  It's not part of the hose coming from the dishwasher.  If you damage it, just take it in to the hardware store with you.  These are inexpensive.
Comment: added picture to the question
Comment: @Tyson Thank you for the comment. yes I assumed that the screw is supposed to open. When I turn the screw it goes from tight to loose to tight to loose, it doesn't really do anything aside from going from one state to the next. What is it supposed to do? Open all the way??
Answer: Based on other answers and comments, I'm hoping I can provide some help by bringing together some of the relevant information into one answer.

How it works

As @user1289451 pointed out, the "screw" is technically a worm gear. However, instead of the threads on the worm turning a gear, it is advancing the band by engaging the slots and moving the band forward and backwards. Because one side of the band is secured, then this forward and backwards motion results in widening or narrowing the band around the hose.

Loosen the connections

It sounds like the screw is turning, but if something seems seized anywhere, pick up some PB Blaster from your local hardware store. It will help free frozen joints. If you are screwing the worm drive and nothing is happening, then the threads or the band are so rusted out that the threads are not making contact with the band. As such, the only thing holding the clamp together would likely be rust/corrosion. Spray PB Blaster into the housing and let it sit for a while (check can for durations). When you come back, attempt to use pliers/flat head screwdriving to get leverage on the band itself using the slots and simply pull it apart.

Use a nut driver (To loosen it)

I would also second what @gregmac said in his comment. When loosening this, it is highly recommended to use a nut driver (or an appropriately sized socket if it's not 1/4") to loosen this. Between slippage and stripping the screwdriver slot, a nut driver will save you lots of headache. However, when you reattach the existing or a new hose clamp, be careful when using your nut driver because it is very easy to overtighten the clamp, possibly damaging the metal/plastic/copper hose/pipe to which you are clamping.

Replace the clamp

I'm not entirely clear on why you need to resuse the clamp as you can replace just that part with a part from a local hardware store. In fact, if you are unclear about its operation, I would recommend a trip to your local hardware store and looking at hose clamps in the store and playing around with them so you understand what how it operates under normal conditions. I would recommend replacing this if at all possible to avoid issues if service of the same connection is required in the future. If you need to cut the clamp, there are several ways to do it. If you want to avoid damaging the hose at all possible costs, then a hacksaw through the top of the wormgear housing might be your best bet. Once you've broken through to the worm itself, use a pair of pliers to bend/twist/open up the housing so that the band moves freely (since it will have not resistance against the worm anymore). You could attempt to cut the band, but this has a much higher chance of damaging the hose.

Pipe replacement

If you get to the point where you need to replace the metal pipe itself, or even any portion of the dishwasher hose, look into using Pex piping. I know it seems scary, but Pex makes plumbing much simpler and with a little research you should be able to replace part or all of the pipe if necessary. The damaged section can be cut back and a piece of PEX can be cut and inserted in the line and secured with a crimp clamp. With a little care, almost any size pipe or hose can be replaced with PEX.
Comment: Hi Stephen, thank you for the great answer (I wish I could vote it up but I don't have enough rep LOL), I don't want to use the same clamp, I meant I need to use the same tube!! (because changing the tube would require me to take out the dishwasher). And honestly, I'm not sure how to cut the clamp without damaging the tube.
Comment: Lots of great comments and suggestions. I ended up actually forcing (force pulling) the tube/hose, and took it out. Once it was out, it was easy to just slip the shot clamp!
Comment: I'll explore the hacksaw option, but I really cannot risk/afford to cut the hose. Thanks so much again for the great summary and lots of helpful hints in it
Comment: @BeginnerDBA, if you use the hacksaw to cut into the top of the worm gear housing and open it up, you reduce the risk of damaging the hose, because as soon as you get through the first layer of the worm gear housing, the housing can be disassembled. The worm itself will be between your saw and the hose at all times while cutting, so as long as you don't slip way off the housing (just cut slowly and carefully) you should have a greatly reduced risk of cutting the hose.
Comment: The recommendation to use PEX pipe in this answer is potentially confusing.  This is a dishwasher discharge hose.  If it requires replacement it should be replaced with the replacement part from the dishwasher manufacturer, or with a universal discharge hose available at a hardware store.  PEX piping is used for supply lines, and would not be an appropriate or code approved choice here.
Comment: @mfarver I see your point.... I added it because I thought he was concerned about damaging the metal pipe it was connected to... I will add some clarification....
Answer: Hose clamps like this are made to clamp, but they are not made to un-clamp so easily - instead, as you have observed, the worm-drive screw tends to un-screw out of its housing when turned anti-clockwise.
The way I loosen the clamp in this situation is to first snug the clamp using the screw - we are not wanting to make the clamp tighter, but simply to get a baseline of the worm-drive screw in its housing.
Next, loosen the screw one or two turns, so it is loose, but not falling out of its housing.
Finally, and this is why my response is the correct answer, you need to use slip-joint pliers ("water pump pliers", "Channelock pliers") to squeeze the head of the worm-drive screw into its housing, which will have the effect of pushing the clamping band open (instead of pulling it tighter). You will need to repeat this sequence (loosen clamp screw couple of turns, squeeze with pliers) until the clamp is as loose as you like.
Note that I have used this method for years on dishwasher hoses such as yours and various hoses under the hoods of my cars and on motorcycles. No chemicals, no hacksaws, just tools & technique. And sincere appreciation to the handyman who showed me this trick when I was a wee lad. :)
Comment: thanks so much for the reply, I will try this now as it is much more convenient than hacksaw
Comment: Yes, try to push the clamp out while turning the screw counter-clockwise. Or maybe just wigging it while turning it would loosing the clamp.
Answer: One of several things is probably happening:

The clamp has corroded or gunked in place, so you'll have to continue turning the screw until opening force is applied to the grooves cut into the clamp band, popping the band's bond to itself and the pipe.
The screw threads are stripped and not engaging the grooves in the band. In this case, a rotary tool and cutoff wheel are your friend.
Comment: All that ^^, but you might try gripping the 'tail' of the clamp and pushing it (or tapping it) back toward the screw mechanism. You'll need to replace the clamp.
Comment: @AloysiusDefenestrate thanks for the comment. So I'll have to "tighten" the screw and try to push it? Sorry I'm not sure what to do. You could also add your response as an "answer" here too. THanks
Comment: No -- leave the screw loose and tap the tail, because the screw appears to be stripped. If I get more time, I'll go into detail about how the screw is a worm drive on the band.
Comment: You can also cut it with a file.  A junior hacksaw would work too but would be more likely to damage the hose end.
Answer: This type of clamp utilizes a worm gear. You see the slots in the band? The threads of the screw turn into those slots and move the band in or out tightening or loosening it. The screw is stationary. It cannot be removed. It just spins in place pushing or pulling the band.
You need to "loosen" the screw by turning it left. Using a nut driver or a socket wrench is better than a screwdriver. Eventually, the band will expand enough that it can move freely on the hose.
If that doesn't happen, the worm gear system is probably shot. Whether that's the screw or the actually slots in the band. In that case, your only option is to cut the band and replace the clamp. They are very inexpensive.
Edit: If you decide to cut it, you could get by with a hacksaw but it will be a pain. I have added some markings to your picture. I would cut along the red line. Once cut, you can just bend the screw assembly over out of the way and the clamp will release.
Comment: thank you for the answer. So I am using a flat-head screwdriver to turn it to the left, and it just doesn't really do anything. I tried "tapping it" on the tail to make it work, but it still just stays there and the band doesn't move. Could this be due to using a flat-head screwdriver? or is the clamp shot and I need to just cut it? Thank you again
Comment: @BeginnerDBA: If in doubt, cut the clamp off, its probably a ten cent item at any nearby hardware store (take the cut-off remnants there)
Comment: @RedGrittyBrick sorry for the bad wording in my question. I don't need the clamp, I have to reuse/maintain/keep the hose/tube. there is no way I could take out a whole dishwasher and replace the tube. Clamp, I just don't know how to cut it without damaing the hose.
Comment: If the screw is spinning, but the clamping is not opening, the clamp is broken. If you're lucky the clamp isn't too tight and you may be able to pull the hose off with the clamp still on depending on the connection on the pipe. I would try grabbing the hose where the clamp is, twisting it back and forth and pulling it off. If you're lucky, you can work it off the pipe, remove the clamp and replace it with a new one.
Answer: You say that the screw goes "from tight to loose", rather than just spinning without seeming to become tighter or looser, which makes me think that it is engaging the slots in the strap, but the strap is frozen to itself or the hose.  If this is true, try loosening the screw as far as it will go, holding the screw housing (not the screw!) still with a pair of pliers, and then tapping the head of the screw with a hammer.  That might unstick it.
Answer: Use an 5/16" socket wrench. gets best leverage and covers the entire nut for torque.

Dishwasher Hose Clamps won't open


A-Frame: rotate entity on mouse down using laser-controls

Question: I have a component which is set on the entity which should be rotated on a mousedown event:
AFRAME.registerComponent('spin', {

init: function () {

    var self = this;
    this.mouse_down = false;
    // assuming only one controller for now
    this.laser = document.querySelectorAll('.laser-controls')[0];

    this.el.addEventListener('mousedown', function (e) {
        self.mouse_down = true;
    });

    this.el.addEventListener('mouseup', function (e) {
        self.mouse_down = false;
    });
},

tick: function() {

    if (this.mouse_down) {

        var el = this.el;
        var rotationTmp = this.rotationTmp = this.rotationTmp || {x: 0, y: 0, z: 0};
        var rotation = el.getAttribute('rotation');
        rotationTmp.y = (this.laser.object3D.getWorldRotation()._y / (Math.PI / 180));
        el.setAttribute('rotation', rotationTmp);
    }
}

});

But it is not rotating properly (tested in Gear VR). What I would like is: hold any controller button and rotate the entity, until controller button is released. Thanks!
Answer: Assuming that laser-controls events are properly fired and captured (no context provided). Modify the object3D directly:
el.object3D.rotation.y = this.laser.object3D.rotation.y;
The question needs additional information on what not rotating properly means. Notice that if you rely on the controller rotation the entity will stop being intersected and mouseup will fire prematurely.
Probably better to rely on button release that doesn't depend on the raycaster:
// Enables rotation when entity is clicked on
this.el.addEventListener('mousedown', function (e) {
  self.rotate = true;
});

// Releases entity
this.laser.addEventListener('triggerup', function (e) {
  self.rotate = false;
});

Also notice you have two laser-controls entities in your scene (for left and right hand). GearVR has a single controller and only one of the entities will be actively tracked. The one that correspond to the configured handedness.
Try to do this.laser = document.querySelectorAll('.laser-controls')[1] to access the right hand one. Likely the one configured in GearVR
With this.laser = document.querySelectorAll('.laser-controls')[0] you are accessing the left hand controller. That's why you don't see any rotation.
A more general solution would be to check if the entity has an associated controller:
var hasActiveController = document.querySelectorAll('.laser-controls')[0].components['tracked-controls'];

Comment: Thanks for your answer and I tried your code. The issue is the same. If I click using the controller, the scene freezes. There must be something wrong with the code in the tick() function.
Comment: Any errors in console? Can you share a simple example on glitch to reproduce?
Comment: There are no errors in the console. The scene is not freezing anymore (was my fault, laser-controls did not exist before using them in the tick function), but I cannot spin the "blog post" around me in VR. This is the glitch: https://rough-asp.glitch.me/  Thanks!
Comment: The problem is that the laser-controls don't seem to have the rotation of the controller in my hand. But I saw that tracked-controls have the rotation info, which is set by the gearvr-controller. How to access the component from laser-controls, since the debug component does not show the tracked-controls in the DOM.
Comment: Updated and expanded answer. Hope it helps.
Comment: Thanks! My issue was `this.laser = document.querySelectorAll('.laser-controls')[1]`.


Extremely low FPS running XCOM 2

Question:
As you can tell, when I'm in the Avenger main screen as well as watching cutscenes, my fps drops significantly to around 10-30 fps, as well as my gpu reaching temperatures around 73 degrees C.
Basically, almost every part of the game has a significant visual lag even though I have a mid-tier gaming rig.  This was tested on running low -> high settings, and the issues are still prevalent on low and high.
The issues:

Low framerate in Avenger HQ
Extremely low framerate when in Dropship
Low framerate in combat after concealment is lifted
In-game cinematics also have low framerate.

Anyone else getting this, and have a fix for this? Is this just a part of poor optimisation?
Comment: Sounds like the lack of proper optimization, usual in games just after their release.
Comment: I was having mid 20-30 fps in the Avenger screen on my 970, but the game defaulted to 8xMSAA.  Dropping down to 2x, or FXAA pushed my frame rates back up to 50-60.
Comment: Looking at [the steam reviews](http://store.steampowered.com/app/268500/#app_reviews_hash), bad performance is a very common complaint about the game. I guess we will have to wait for version 1.1
Answer: This was fixed in the first performance patch that Firaxis pushed through.

Extremely low FPS running XCOM 2


Go to closing Tag in Visual studio (using Resharper)?

Question: I'm using the latest Resharper (v 8.1) with visual studio 2010.
Is there a keyboard shortcut/feature to "Jump to closing tag"  ?
For example : if the cursor is on the first tr :

I want the cursor to go to the closing tr  which is

Is there any shortcut for this ?
(p.s. - something like goto matchine brace but for Xml/html tags)
Answer: From what I've gathered there's no shortcut for this in either reSharper or Visual Studio. A "work around" would be to collapse the tag using Ctrl + M + M, then go to the start or end of the line using Home or End key. When you open it again using Ctrl + M + M will you be either at the top or bottom of the tag.

Ctrl + M + M
Home / End (Depending if you want to go to the start or end tag)
Ctrl + M + M
Answer: I heard that ctrl + ] does the trick
Comment: No. if  the cursor is ` aaaaaa     ` and you press `ctrl]` it will take you  `> aaaaaa     ` and not ` aaaaaa     ` as desired
Comment: @RoyiNamir +1 for your efforts in comments :)
Comment: Yeah Ctrl + ] brings you to the closing brace, not the closing tag. I posted another method you could use.
Answer: Ok here is the answer  as macro which i've built which does it (toggle ) including go to focus :
Here is the demo :

And here is the code  , enjoy !
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Windows.Forms

Public Module Module2
    Sub beginToEnd()

        'Place cursor somewhere in beginning tag, run macro, to select from beginning to End Tag

        DTE.ActiveDocument.Selection.SelectLine()
        Dim objSel As TextSelection = DTE.ActiveDocument.Selection
        Dim topPoint As TextPoint = objSel.TopPoint
        Dim lTopLine As Long = topPoint.Line
        objSel.GotoLine(lTopLine, False)
        '  DTE.ActiveDocument.Selection.StartOfLine()
        DTE.ActiveDocument.Selection.SelectLine()
        Dim line1 As String = DTE.ActiveDocument.Selection.Text()
        If InStr(line1, "/") Then

            ' MsgBox(line1)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ActiveDocument.Selection.EndOfLine()
            DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True)
            objSel.GotoLine(lTopLine, False)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")

        Else

            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ActiveDocument.Selection.EndOfLine(False)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")

        End If
        DTE.ActiveDocument.Selection.SelectLine()
        Dim line2 As String = DTE.ActiveDocument.Selection.Text()
        Dim objSel3 As TextSelection = DTE.ActiveDocument.Selection
        Dim topPoint3 As TextPoint = objSel3.TopPoint
        Dim lTopLine3 As Long = topPoint3.Line
        objSel.GotoLine(lTopLine3, False)
        DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, False)

    End Sub

End Module


Can you get more than one buff by eating multiple cooked dishes?

Question: For example, in the game Link eats a dish which gives heat-resistance boost for a given length of time and eats a dish which increases attack power for another given length of time, will Link have both ability boosts to keep or will the ability boost from the newest dish overwrite the older dish?
Answer: No, you cannot combine buffs by eating multiple foods/elixirs. You can, however, combine a food/elixir buff with armor buffs. If you eat a second food/elixir, the newer buff will overwrite the older buff.
From Reddit:

How to get a buff
Link can gain a buff (positive effect) by wearing certain pieces of armor or by consuming certain foods/elixirs. Whereas armor buffs apply whenever the armor is worn, food/elixir buffs have a countdown timer (length varies by ingredients).
(Note: In this post, the term "armor" includes all clothing and items which can be equipped to Link's head, torso, and legs.)
When buffs are unstackable
No single food/elixir may provide more than one buff. Further, when a food/elixir buff timer begins, it overwrites any existing buff timer Link was enjoying. Thus, food/elixir buffs aren't stackable with other food/elixir buffs (but they can be combined with armor buffs; see below).
Combining different buffs
Multiple buffs may be combined by mix-and-matching armor pieces (for example, wearing a piece of Attack Up armor with a piece of Stealth Up armor), or by using a food/elixir buff with one or more armor buffs.
Comment: FWIW, this is also stated on one of the [loading screen](http://orcz.com/Breath_of_the_Wild:_Loading_Screen_Tips) tips. *You can only enjoy one effect from a dish or elixir at any given time. If you're relying on an active effect, be careful not to cancel it by eating something with a new effect.*
Comment: Shaun Thank you for answering and providing an alternate solution!


How to extract day and month from a Date data in sqlite database

Question: I have a column in my database bornDate which has this format dd/MM/yyyy. I want to extract the day and month to compare with the current day and month and in this way to select users who are born today
Comment: You already asked this question: https://stackoverflow.com/questions/65464335/how-to-query-a-sqlite-database-to-obtain-users-who-are-born-today You should edit the original question to add additional info instead of posting a new one.
Answer: You can use string functions:
select *
from mytable
where substr(bornadte, 1, 5) = strftime('%d/%m', 'now')

Note that you should not be storing dates in this format. SQLite understands dates in format YYYY-MM-DD.  I would strongly recommend fixing your data model:
update mytable
set borndate = substr(borndate, -4)
    || '-' ||  substr(borndate, 4, 2)
    || '-' ||  substr(borndate, 1, 2)

Comment: Great answer +1 and I didn't think the date format was even salvagable.


How to run a trivial ZIO for comprehension snippet

Question: In the getstarted zio doc page there is this trivial exemple, but I cannot run it, what could be a simple code to make this snippet work (have a question and be able to answer in the console) ?
import zio.console.{getStrLn, putStrLn}
object Bug41 {
  def main(args: Array[String]): Unit = {
    println("Start")
    val program =
      for {
        _    <- putStrLn("Hello! What is your name?")
        name <- getStrLn
        _    <- putStrLn(s"Hello, ${name}, welcome to ZIO!")
      } yield ()
    program.run
  }
}

Answer: If you are just interacting with ZIO you can use the built-in zio.App instead
object Bug41 extends zio.App {
  def run(args: List[String]): URIO[ZEnv, ExitCode] =
    (for {
      _    <- putStrLn("Hello! What is your name?")
      name <- getStrLn
      _    <- putStrLn(s"Hello, $name, welcome to ZIO!")
    } yield ()).exitCode
}

This way you can push everything to the end of the world and handle errors cleanly.
Answer: object Bug41 {

  val program: RIO[Console, Unit] =
    for {
      _    <- putStrLn("Hello! What is your name?")
      name <- getStrLn
      _    <- putStrLn(s"Hello, $name, welcome to ZIO!")
    } yield ()

  def main(args: Array[String]): Unit = {

    val runtime: Runtime[zio.ZEnv] = zio.Runtime.default.mapPlatform(_.withReportFailure(cause => println(cause)))

    runtime.unsafeRun(program)

  }
}

Answer: import zio._
import zio.console._
import zio.internal.Platform

object Logic {
  val main: RIO[Console, Unit] =
    for {
      _    <- console.putStrLn("Hello! What is your name?")
      name <- console.getStrLn
      _    <- console.putStrLn(s"Hello, $name, welcome to ZIO!")
    } yield ()
}

object Bug41 extends zio.App {
  def run(args: List[String]): URIO[ZEnv, ExitCode] = Logic.main.exitCode

  override val platform: Platform = Platform.default.withReportFailure(println)
}

Comment: Merged previous answers.


Manage replicas of ISM indices with templates

Question: I have a standalone instance with Opensearch for testing purposes, I want to keep it light and clean so I'm using ISM to delete indices older than x days.
What I noticed is that by default Opensearch generates a management index (".opensearch-ism-config") with replica "1".
Since I'm using a standalone instance (it is just testing, I'm not worried with redundancy, HA or anything like that) and want to keep my cluster with green status, I have decided that I want those indices to have replica "0".
In order to achieve that, I have created a template in which I set replica "0" for these indices:
{
  "order" : 100,
  "version" : 1,
  "index_patterns" : [".opensearch-ism-*"],
  "settings" : {
    "index": {
      "number_of_shards" : "1",
      "number_of_replicas": 0
    }
  }
}

After a PUT, I start using ISM so that the management ISM index is created after this template is on Opensearch node.
What I observe is that all management indices from ISM are generated with replica "1", therefore ignoring the template.
I can set replica to "0" by updating index settings after creation but this is not the ideal scenario as ISM index rotate and new ones are generated from time to time.
Is there any way to have ISM indices applying replica "0" automatically ?
Comment: "What I observe is that all management indices from ISM are generated with replica "0", therefore ignoring the template". Do you mean "1"? 0 means all good no? Also maybe you meant ".opendistro" and not ".opensearch"?
Comment: I corrected the post, sorry.
Comment: There is just one index called `.opendistro-ism-config`. Wat do you mean by "all"? In your case only `.opendistro-ism-config` should have 0 replica and no other index. So are you saying that '.opendistro-ism-config' index still have 1 replica after index rollover? I am not even sure if there is a roll over for this index as this index has all the config for ISM. Be very carefull with this.
Comment: There is another index .opendistro-job-scheduler-lock also with replica "1". If these indices don't rollover I can PUT replica "0" after the index ceation.
Although, I think the proper behaviour should be that these indices respect the index template.
Comment: But your index pattern doesn't match ".opendistro-job-scheduler-lock"!
Comment: It does, I have another index template:
Answer: I ran into this same issue when transitioning from Elasticsearch 6 to OpenSearch. In Elasticsearch I was accustomed to index templates being additive. For example, in Elasticsearch 6, I could do something like this:
Create an index template to configure ILM rollover alias
PUT _template/a_descriptive_template_name-ilm
{
    "settings": {
        "index.lifecycle.name": "an_efficient_ilm_policy",
        "index.lifecycle.rollover_alias": "a_descriptive_index_name-ilm"
    },
    "order": 10,
    "index_patterns": [
        "a_descriptive_index_name-ilm-*"
    ]
}

Create an index template to configure index shard settings
PUT _template/a_common_template_name
{
    "settings": {
        "number_of_shards": 2,
        "number_of_replicas": 1
    },
    "order": 5,
    "index_patterns": [
        "a_descriptive_index_name-ilm-*"
    ]
}

Create the initial index
PUT a_descriptive_index_name-ilm-000001
{
    "aliases": {
        "a_descriptive_index_name-ilm": {
            "is_write_index": true
        }
    }
}

Verify the settings
GET a_descriptive_index_name-ilm-000001
{
  "a_descriptive_index_name-ilm-000001" : {
    "aliases" : {
      "a_descriptive_index_name-ilm" : {
        "is_write_index" : true
      }
    },
    "mappings" : { },
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "an_efficient_ilm_policy",
          "rollover_alias" : "a_descriptive_index_name-ilm"
        },
        "number_of_shards" : "2",
        "provided_name" : "a_descriptive_index_name-ilm-000001",
        "creation_date" : "1692853100041",
        "number_of_replicas" : "1",
        "uuid" : "AJ3OiRaXRj2cVCvuKlUWgg",
        "version" : {
          "created" : "6081299"
        }
      }
    }
  }
}

When I tried to do this same technique in Opensearch 2.3, I noticed that it did not work as I expected. The template with the higher priority overwrote the settings in the lower priority template, completely, even if there were not overlapping settings. In the example below, where I am doing the same thing as Elasticsearch (but using different verbs for OpenSearch), you will see that the additive behavior is no longer supported:
Create an index template to configure ISM rollover alias
PUT _index_template/a_descriptive_template_name-ism
{
    "template": {
        "settings": {
            "plugins.index_state_management.rollover_alias": "a_descriptive_index_name-ism"
        }
    },
    "priority": 10,
    "index_patterns": [
        "a_descriptive_index_name-ism-*"
    ]
}

Create an index template to configure index shard settings
PUT _index_template/a_common_template_name
{
    "template": {
        "settings": {
          "number_of_shards": 2,
          "number_of_replicas": 1
        }
    },
    "priority": 5,
    "index_patterns": [
        "a_descriptive_index_name-ism-*"
    ]
}

Create the initial index
PUT a_descriptive_index_name-ism-000001
{
    "aliases": {
        "a_descriptive_index_name-ism": {
            "is_write_index": true
        }
    }
}

Verify the settings
{
  "a_descriptive_index_name-ism-000001" : {
    "aliases" : {
      "a_descriptive_index_name-ism" : {
        "is_write_index" : true
      }
    },
    "mappings" : { },
    "settings" : {
      "index" : {
        "number_of_shards" : "1",
        "plugins" : {
          "index_state_management" : {
            "rollover_alias" : "a_descriptive_index_name-ism"
          }
        },
        "provided_name" : "a_descriptive_index_name-ism-000001",
        "creation_date" : "1692853523944",
        "number_of_replicas" : "1",
        "uuid" : "ZZSjabAVQACC7m8Xn0uKtA",
        "version" : {
          "created" : "136247827"
        }
      }
    }
  }
}

As you can see, the "number_of_shards": 2 setting gets overwritten.
To apply both the shard settings and the ISM rollover settings, (and whatever other settings / mappings required), there are two options.

Combine all the settings / mappings and ISM configuration into a single index template (or single index template per index pattern)
[Better Solution] Use the OpenSearch Composable index templates functionality to allow for "layering" templates.

The OP answered in a later comment "It does, I have another index template". To solve for this scenario, option 2 is the way I suggest to follow.
Here is an example:
Create a component template to configure index shard settings
PUT _component_template/shards_component_template
{
      "template": {
        "settings": {
          "number_of_shards": 2,
          "number_of_replicas": 1
        }
    }
}

Create the index template to configure ILM rollover alias, referencing the component template
PUT _index_template/a_descriptive_template_name-ism
{
    "template": {
        "settings": {
            "plugins.index_state_management.rollover_alias": "a_descriptive_index_name-ism"
        }
    },
    "priority": 10,
    "index_patterns": [
        "a_descriptive_index_name-ism-*"
    ],
    "composed_of": [
        "shards_component_template"
    ]
}

Create the initial index
PUT a_descriptive_index_name-ism-000001
{
    "aliases": {
        "a_descriptive_index_name-ism": {
            "is_write_index": true
        }
    }
}

Verify the settings
{
  "a_descriptive_index_name-ism-000001" : {
    "aliases" : {
      "a_descriptive_index_name-ism" : {
        "is_write_index" : true
      }
    },
    "mappings" : { },
    "settings" : {
      "index" : {
        "number_of_shards" : "2",
        "plugins" : {
          "index_state_management" : {
            "rollover_alias" : "a_descriptive_index_name-ism"
          }
        },
        "provided_name" : "a_descriptive_index_name-ism-000001",
        "creation_date" : "1692854275856",
        "number_of_replicas" : "1",
        "uuid" : "SGvVILFsSG-3PdpoCg8Tkw",
        "version" : {
          "created" : "136247827"
        }
      }
    }
  }
}


How can I get the username from a python script run with pkexec?

Question: I'm executing a python script as root with pkexec and I'm using working_dir = os.getenv('HOME') to get the username but it always returns root instead of test1 which is the current user.
How can I get the user that ran pkexec instead?
I already tried print os.environ["SUDO_USER"] but that fails since it's not being executed directly with sudo. I am on trusty now but behaves the same in 16.04.
Comment: AFAIK the only environment variable inherited from the invoking user is `PKEXEC_UID`, so you'd need to find a (non evil) way to derive the home directory from that
Comment: Thanks, using `print os.environ["PKEXEC_UID"]` I managed to get the normal user's uid. I just need to get the name of the user from the uid and this should solve my problem which is less complicated
Answer: I fixed it like this:
import pwd
import os

user = pwd.getpwuid(int(os.environ["PKEXEC_UID"])).pw_name
working_dir = '/home/{}'.format(user)


How can I correctly create a C++ vector in Python3 by swig?

Question: I try to test swig library 'std_vector.i', but I can't create a vector in Python3 like official demo, Here is some information.
swig_test.i
%module swig_test

%{
#include <vector>
void worker(std::vector<int> &v) {
    v.push_back(123);
}
%}

%include <std_vector.i>
%template(MyVector) std::vector<int>;

void worker(std::vector<int> &v);

Then I run:
swig -python -py3 -c++ swig_test.i

It works right.
And then is setup.py
from distutils.core import setup, Extension

test_module = Extension('_swig_test',
                           sources=['swig_test_wrap.cxx'],
                           )

setup(name = 'swig_test',
       version = '0.1',
       author      = "SWIG Docs",
       description = """Simple swig test from docs""",
       ext_modules = [test_module],
       py_modules = ["swig_test"],)

And then run:
python setup.py build_ext --inplace

It creates the file '_swig_test.cp38-win_amd64.pyd', I test it in the shell.
>>> import _swig_test
>>> v = _swig_test.MyVector([1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module '_swig_test' has no attribute 'MyVector'

It's too strange, it can't be work as normal, then I run dir
>>> dir(_swig_test)
['MyVector___bool__', 'MyVector___delitem__', 'MyVector___delslice__', 'MyVector___getitem__', 'MyVector___getslice__', 'MyVector___len__', 'MyVector___nonzero__', 'MyVector___setitem__', 'MyVector___setslice__', 'MyVector_append', 'MyVector_assign', 'MyVector_back', 'MyVector_begin', 'MyVector_capacity', 'MyVector_clear', 'MyVector_empty', 'MyVector_end', 'MyVector_erase', 'MyVector_front', 'MyVector_get_allocator', 'MyVector_insert', 'MyVector_iterator', 'MyVector_pop', 'MyVector_pop_back', 'MyVector_push_back', 'MyVector_rbegin', 'MyVector_rend', 'MyVector_reserve', 'MyVector_resize', 'MyVector_size', 'MyVector_swap', 'MyVector_swiginit', 'MyVector_swigregister', 'SWIG_PyInstanceMethod_New', 'SwigPyIterator___add__', 'SwigPyIterator___eq__', 'SwigPyIterator___iadd__', 'SwigPyIterator___isub__', 'SwigPyIterator___ne__', 'SwigPyIterator___next__', 'SwigPyIterator___sub__', 'SwigPyIterator_advance', 'SwigPyIterator_copy', 'SwigPyIterator_decr', 'SwigPyIterator_distance', 'SwigPyIterator_equal', 'SwigPyIterator_incr', 'SwigPyIterator_next', 'SwigPyIterator_previous', 'SwigPyIterator_swigregister', 'SwigPyIterator_value', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'delete_MyVector', 'delete_SwigPyIterator', 'new_MyVector', 'worker']

I try to add #define SWIG_FILE_WITH_INIT, but it have no any use, and I try to imitate official demo, it works same result.
How can I deal with it?
Comment: (BTW this is a good example of how to make a decent first question - everything needed to understand what you did and where you're at is succinctly presetned)
Answer: The problem here is how you're importing and using the module you've built.
When you ran SWIG as well as generating some C++ code it also generated some Python too. Rather than directly access the native module you want to access it via the generated python instead, e.g.
import swig_test # Note no leading _
v = swig_test.MyVector([1,2,3])

Which will work just fine then.
Note that you can also ask SWIG to generate native-only module by invoking SWIG with the -builtin flag as well, e.g.:
swig -python -py3 -c++ -builtin swig_test.i

However I wouldn't usually recommend this when getting started as it makes a bunch of common things quite a lot harder.
Comment: Thanks a lot! It means that I should import the `.py` file(and it still need the `.pyd` file) instead of directly importing the `.pyd` file?
Comment: Correct - if you import the .py file then it should import the native code for you automatically


Move a body from VecA to VecB, instantly, but properly affect other bodies

Question: I'm using the box2dflash library to create a game, and so far I've been using "SetPosition" to instantly move a body from one place to another... the problem is that it obviously skips affecting other bodies when I do this. I have the body set to bullet... now I just need to know how I calculate the force(?) to get the body to the exact coordinates that I need to move it to... preferably after only a single frame.
How would I go about doing this in box2d properly?
Answer: You could SetLinearVelocity to the difference between the current location and the destination, multiplied by your frames per second. That should get the body there in one frame, then you will need to stop it! SetLinearVelocity again to zero would work.
Comment: Velocity is given in units per second, so it would take one second to get there if you simply set the velocity to the difference between the current and target locations. If your framerate is 60fps that would be 60 frames... if you want it there in one frame it'll need to be going 60 times faster :)
Comment: That... was EXACTLY correct. How did you know that multiplying by the frames per second was the way to achieve this? I would have spent much too long reverse engineering the SetLinearVelocity code to find this sort of answer. I wish I could upvote this ten times!


Insert into syntax wrong

Question: i want to add new user into the access database using vb but it keeps saying wrong insert into syntax when i execute it. can anybody tell me whats wrong with it? ive searched for the mistakes and i think the code is not wrong. help me please
Imports System.IO
Imports System.Data.OleDb

Public Class Adduser
Private Sub createbtn_Click(sender As Object, e As EventArgs) Handles createbtn.Click
    If required() = True Then
        Return
    End If

    Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Gio\Documents\Visual Studio 2012\Projects\CSS\CSS\bin\Debug\CSS.accdb;")
    Try
        If connection.State = ConnectionState.Closed Then connection.Open()

        Dim sql As String = "insert into User(Names,Username,Password,isAdmin) values (@Names, @Username, @Password, False)"
        Dim command As OleDbCommand = New OleDbCommand(sql, connection)

        Dim isAdmin As Boolean

        Dim Names As OleDbParameter = New OleDbParameter("@Names", OleDbType.VarWChar, 50)
        Names.Value = namebox.Text.ToString()
        command.Parameters.Add(Names)

        Dim Username As OleDbParameter = New OleDbParameter("@Username", OleDbType.VarWChar, 50)
        Username.Value = unamebox.Text.ToString()
        command.Parameters.Add(Username)

        Dim Password As OleDbParameter = New OleDbParameter("@Password", OleDbType.VarWChar, 50)
        Password.Value = namebox.Text.ToString()
        command.Parameters.Add(Password)

        command.Parameters.AddWithValue("@isAdmin", isAdmin)
        isAdmin = False

        If command.ExecuteNonQuery() Then
            connection.Close()
            MessageBox.Show("New user is added!")
            namebox.Text = ""
            unamebox.Text = ""
            passbox.Text = ""

        Else
            MsgBox("Addition of new user failed!")
        End If

    Catch ex As Exception
        MessageBox.Show(ex.Message.ToString(), "Data Error")
        Exit Sub
    End Try
End Sub

Answer: User and Password are both reserved words in Access so you should surround them with square brackets [User] or rename them.
Comment: ive change the user into something else. and the password also. but it still says insert into syntax error
Comment: **Add** your revised code and the full error message at the bottom of your original post. If you are not able to edit then put relevant details in a comment.
Comment: ..but, you don't have an **isAdmin** parameter.
Comment: i have it there @Andy G. below password parameter. but i dont know whether it is wrong or correct. since it is in boolean data type and im quite confused on how to make it

Insert into syntax wrong


Compare with int and string in IF condition

Question: Code in PHP :
<?php
    $key = 0;
    if($key == 'monty' && $key == 'anil'){
        echo 'Mackraja';
    }else{
        echo "Nothing";
    }
?>

OR
<?php
    $key = 2;
    if($key == '2abc' || $key == 'abc2'){
        echo 'Mackraja';
    }else{
        echo "Nothing";
    }
?>

OUTPUT: Mackraja
Comment: why use `&&` ? one attribute cant get two different values at the same time! use `||`
Comment: it does not mean which operator we are using || or && it giving same output
Comment: logical, its not true , not about syntax
Comment: yes, i was thinking same logically its not true but how its coming in true condition @MohsenShakibafar
Comment: because of type. type difference 0 is integer , if you put `'0'` you see it work fine. see http://stackoverflow.com/questions/523643/difference-between-and-in-javascript
Comment: Funny, because when comparing correctly the first condition will never be true
Comment: See my answer, i hope it will explain you more and will help you in your programming
Comment: it's look like the first one , all cause of ,different types
Comment: @MohsenShakibafar No, its not like that, even i write answer for this, i hope it will help others
Comment: @Monty , you right , my mistake.
Answer:
If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. - Source

This means that
<?php
    var_dump(0 == "a"); // 0 == 0 -> true
    var_dump("1" == "01"); // 1 == 1 -> true
    var_dump("10" == "1e1"); // 10 == 10 -> true
    var_dump(100 == "1e2"); // 100 == 100 -> true

So when you're comparing $key (with value 0) to the strings, the strings have value 0 and they both return true. This way, it will always output "Mackraja".
Changing the value of $key to any other integer will return false.

Note that

The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value. - Source

This means that changing the comparison operator to === will mean that the values have to match completely - i.e., a string 1 will not be equal to an integer 1: they have to match formats:
echo $key == 'monty' && $key == 'anil' ? 'Mackraja' : 'Nothing';
//will echo "Mackraja"

echo $key === 'monty' && $key === 'anil' ? 'Mackraja' : 'Nothing';
//will echo "Nothing"

Comment: When we do it :---> echo $key == 'monty' && $key == 'anil' ? 'Mackraja'; 'Nothing';
//will echo "Mackraja" :-> It will give you Nothing not Mackraja

echo $key === 'monty' && $key === 'anil' ? 'Mackraja'; 'Nothing';
//will echo "Nothing"
Comment: Your answer not satisfying me
Comment: @Monty Apologies there was a syntax error in my `if/else` statement. Try now.
Comment: See my answer : @Ben
Answer:
If you compare a number with a string or the comparison involves
  numerical strings, then each string is converted to a number and the
  comparison performed numerically.  Reference

Now check
<?php
$key = 0;
if($key === 'monty' && $key === 'anil'){
    echo 'Mackraja';
}else{
    echo "Nothing";
}
?>

you will get output "Nothing".
now integer value of those strings are 0 you can observe that here.
<?php
$a = 'monty';
echo (int)$a; //0

How ? / Why ?
Taking the situation to out of programming little bit to explain it, how ever better way can be posted, I am trying my way to explain the concept to you.
If you have come across principle of homogeneity  it states that you can not compare two quantity if their dimensions are different.
Here in programming you can not compare a string and integer directly, it needed to be converted to any one to be compared.
In PHP, if you will go through manual you can notice or that is a basic idea of PHP that:-

PHP does not require (or support) explicit type definition in variable
  declaration; a variable's type is determined by the context in which
  the variable is used.

For comparison operator when you are even comparing two string (with loose comparison)  those are converted to integer and then they are compared You can notice it on the reference page "Comparison with Various Types" table.

So, I can say comparison operator itself needs integer type variable
  to comapre, that is why both operators are compared to integers.

$key = 2;
if($key == '2abc' || $key == 'abc2'){
    echo '
Mackraja';//outputs
}else{
    echo '
nothing';//does not output
}

now,
$key = 200;
if($key == '2a2' ){
    echo '
' . $key . '== 2a2' . ' Equal';//does not output
}else{
    echo '
' . $key . '== 2a2' . ' Not Equal'; //outputs
}

and
$key = 200;
if($key == '2e2' || $key == 'abc2'){
    echo '
' . $key . '== 2e2' .  ' Equal';//outputs  Now it does not convert it to integer, it converts it to
}else{
    echo '
' . $key  . '== 2e2' . " Not Equal";//does not output
}

now
echo '
'.'1E1'*1;  //it outputs 10 why ??
echo '
';
echo '
1E1'*1;  //it outputs 10 why ??

see below:-
echo '
cast to int 1E1 = ' . (int)1E1;//10
echo '
Cast to int 1E2 = ' . (int)1E2;//100
//echo '
Cast to int 1A1 = ' . (int)1A1;//gives you error as can not be cast
//echo '
Cast to int 1A2 = ' . (int)1A2;//gives you error as can not be cast
echo '
Cast to int 1A1 = ' . (int)('1A1');//1
echo '
Cast to int 1A2 = ' . (int)('1A2');//1

echo '
get int value 1E1 = ' . intval('1E1');//1
echo '
get int value 1E2 = ' . intval('1E2');//1
echo '
get int value 1A1 = ' . intval('1A1');//1
echo '
get int value 1A2 = ' . intval('1A2');//1

"This is not about getting the intvalue from a variable it is about
  how a variable is cast."

I am giving you another clean table, taht you have already seen from my previous reference link,how different types of variable are casted in PHP when compared you can notice that from here.
If you need more resource, the best idea is to go for source code how it is written you can learn a lot from that, and why they  did like this can be better answered by PHP group.
May be you may get something like can not becompared for such situation if PHP will not convert these variable implicitly, if you want your PHP to behave like this, you can make your own version .
I am adding the table how conversion happens when loosely variable are compared:-

Comment: I wanted to know the reason, i know how to do it. Not satisfy with your answer
Comment: @Monty I have edited my answer, I hope I am able to give you better idea   this time.
Comment: @Monty I have added more explanation with more example where you can notice different condition and behavior of PHP.
Comment: : I am impressed with the reference link which you written in your answer. Have  you look my answer, what you think its near to real answer or not
Comment: @Monty now going to read other answers , I have not gone through any other answers still now.
Comment: @Monty yes, I can say you have given a good language to explain the concept and I have provided better examples :P why reference link is better is next person will go through all the things you have gone when he will visit this page and these links are going to remain for a long time with php manual .
Comment: Thanks, So as we both know what is reason behind it, I hope if any developer come here than he will not confuse.
Comment: @Monty there is less chance in current time developers will like to spend time on core, everyone wants to earn money by  learning quickly to make things work either correctly or semi-correctly . :D
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/102564/discussion-between-monty-and-prafulla-kumar-sahu).
Comment: how to compare 9829098290 and 09829098290? Kindly share your suggestion. Thanks. Note: please do not suggest to add single / double code outside of both the numbers. Any standard method?
Comment: @Kamlesh I need to understand how you want to compare them as integers or string or how exactly you want to compare them, based on that only the comparison can happen. and it will be better if you can post this as a separate question, so that we can handle that separately without messing it.
Answer: check the type conversion rules for loose comparison (Loose comparisons with ==): php type conversion rules
You'll see that with using loose type comparison, integer 0 equals to any string...
Answer:
If you compare a number with a string or the comparison involves
  numerical strings, then each string is converted to a number and the
  comparison performed numerically. These rules also apply to the switch
  statement. The type conversion does not take place when the comparison
  is === or !== as this involves comparing the type as well as the
  value.When you provide $key as 0 then comparison will take place numerically ie, (int)'monty' = 0 and (int)'anil' = 0.

Try this if you want correct result
$key = 0;
if($key === 'monty' && $key === 'anil'){
    echo 'Mackraja';
}else{
    echo "Nothing";
}

Comment: i know it, i want how (What is reason)
Answer: if a string is compared with number, string will be converted t number and the check / comparition is done numerically
if you still need to get the correct output with data type check you can use "===" in if as below will result the output u expect as "Nothing"
<?php
  $key = 0;
  if($key === 'monty' && $key === 'anil'){
    echo 'Mackraja';
  }else{
    echo "Nothing";
  }
?>

this will output: Nothing
Comment: I wanted to know the reason, i know how to do it. Not satisfy with your answer.
Answer: Just do like this..
<?php
$key = 0;
if((string)$key == 'monty' && (string)$key == 'anil'){
    echo 'Mackraja';
}else{
    echo "Nothing";
}
?>

Output:
Nothing

Comment: i know it, best option is compare type like this : === But my question is how possible
Comment: Because you are trying to compare integer with string
Answer: After a long discussion with my colleagues :  We Found Solution
Examples :
#1    var_dump("00005ab" == 5); // true
#2    var_dump("abc" == 0); // true
#3    var_dump(2 == "ab2"); // false
#4    var_dump(2 == "2ab"); // true

Explanation :

In the condition left operand (2) match with right operand (ab2), if
  it does not found at the beginning then output will be false else true.

#1 : we found 5 at the begining output will be true. 0 will be eliminated.
#2 : string + int = int output will be true.
     Priority of int is higher, 0 == 0 output will be true,
#3 : 2 is not found at the beginning of match value (ab2), output will be false.
#4 : 2 is found at the beginning of match value (2ab), output will be true.

Reason :
1.) In PHP, its automatically convert Type Casting.
2.) Rules of Type Casting :
    2.1) int + int = int
    2.2) string + string = string
    2.3) float + float = double
    2.4) int + string = int
    2.5) float + string = double
    2.6) int + float = double


Parametrization of $SO(N)$ using unit vectors

Question: The group $SO(N)$ has $m=N(N-1)/2$ generators and one thus needs $m$ angles to parametrize it.
In the case of $SO(2)$ and $SO(3)$, one can also parametrize using unit vectors $\vec q$ in $\mathbb R^{m+1}$, i.e. $\vec q=(q_1,...q_{m+1})$ with $\vec q.\vec q=1$. Then the $m$ angles parametrizes the corresponding coordinates of $\vec q$, and one gets the corresponding orthogonal matrix using some specific mapping $O=\Phi(\vec q)$.
Furthermore, still for $N=2$ and $N=3$, one can show by direct calculation that ${\rm Tr}(O(\vec q_1)O^T(\vec q_2))$ is invariant under rotations of $\vec q_1$ and $\vec q_2$, that is ${\rm Tr}(O(\vec q_1)O^T(\vec q_2))={\rm Tr}(O(\vec q_1')O^T(\vec q_2'))$, with $\vec q_i'=Q \vec q_i$ and $Q \in O(m+1)$. For $SO(2)$ ($SO(3)$) matrices, with thus have an invariance of this trace under $O(2)$ ($O(4)$) rotations of the unit vectors parametrizing them.
My questions are : Is this parametrization with unit vectors true for all $N$ ? And if so, and more importantly to me, is this invariance under $O(m+1)$ of the trace also always true ?
Finally, is there a deeper meaning to this invariance ?

EDIT: It seems that my conjecture is not true. For $SO(4)$, the parametrization is in term of two unit 4-vectors $\vec q\in \mathbb R^4$ and $\vec p\in \mathbb R^4$, $\vec q^2=\vec p^2=1$ (see Wikipedia).
Furthermore, it is not too hard using this parametrization to show that for $O_1$ and $O_2$ in SO(4),
$$
\rm{ Tr}(O_1^T O_2)=\rm{ Tr}(O(\vec q_1,\vec p_1)O(\vec q_2,\vec p_2))=f(\vec q_1.\vec q_2,\vec p_1.\vec p_2),
$$
is invariant under $O(4)\times O(4)$ corresponding to independent rotations of the $\vec q$'s and $\vec p$'s.
Even though it is not as simple as I thought, there is nevertheless a symmetry of these traces, associated to the parametrization in terms of unit vector.
Does any one knows more about this ?
Answer: Ingeneral, $SO(n)$ has topology of a "twisted product" of spheres $S^{n-1} \ltimes S^{n-2} \ltimes \ldots \ltimes S^1$, obtained inductively by observing that for the defining action of $SO(n)$ on $\mathbb{R}^n$ orbit of any vector is  $S^{n-1}$ and the stabilizer is $SO(n-1)$. The case $n=2$ gives a sphere trivially, and in the case $n=3$ we get a fibration which is double covered by the Hopf fibration. This means that $SO(3)$ is $RP^2$, and the "parametrization" by $S^3$ is the universal cover map $ S^3 \mapsto RP^2$. When $n=4$ we get $SO(4)=S^{3} \ltimes RP^2$, from which the double cover of $SO(4)$ by $S^{3} \times S^{3}$ comes.  In general, you have a "tautological" parametrization by the orthonormal frame to which the standard frame is rotated - that is, by the columns of the  rotation matrix. Of course then $Tr(O_1^T O_2)$ is the sum of dot products of the corresponding columns, $\sum_j q_{j,1} \cdot q_{j,2}$.
Apart from these ''small n coincidences",  $SO(n)$ can not be covered by a sphere, since it has "wrong topology" (for example, homotopy groups of $SO(n)$  are subject to Bott periodicity, while homotopy groups of spheres are famously complicated. I think that also means that $SO(n)$ can not be covered by a fixed number of spheres, but I have not thought about the details of this.
Of course one can parametrize almost all of any compact m-manifold by $
\mathbb{R}^m$, and hence by part of $S^m$ or some such, but that will not have the type of symmetry you seem to be looking for.
Comment: Thanks for the answer. I am not sure how for example the double cover of $SO(4)$ insures that $Tr(O^T_1 O_2)$ will be invariant under $O(4)\times O(4)$ (although of course it has the smell of it...). Note that this is not equivalent to your tautological parametrization (which would involve 4 vectors, whereas the symmetry I mention involves only 2).
Comment: The last vector in tautological parametrization is redundant, so 3, not 4. And the $SO(3)=\mathbb{R}P^2$ makes the last 2 into one, so you get 2 instead of 3.
Comment: I'm not sure I understand what you mean... For sure because I don't know enough about projective spaces and their relation to the orthogonal groups. Also, I don't understand why this way to go from 4 to 2 vectors insure that the symmetry associated with the trace is O(4)xO(4).
Comment: My comment was a bit off: what it says is that you could get a "two vector" parametrization from the tautological one, but the problem is that I can't see how to make that very natural (and that's why the symmetry is not visible).


how to ignore MatchError then processing a large json file in spark-sql?

Question: I'm trying to process a bunch of large json log files with spark, but it fails every time with scala.MatchError, Whether I give it schema or not.
I just want to skip lines that does not match schema, but I can't find how in docs of spark.
I know write a json parser and map it to json file RDD can get things done, but I want to use sqlContext.read.schema(schema).json(fileNames).selectExpr(...) because it's much easier to maintain.
Comment: If validating data is not option I doubt there is a simple way. It looks like you could patch [`JacksonParser.parseJson`](https://github.com/apache/spark/blob/c025c3d0a1fdfbc45b64db9c871176b40b4a7b9b/sql/core/src/main/scala/org/apache/spark/sql/json/JacksonParser.scala#L180) to log instead of throwing an exception.
Answer: This will be solved in Spark 1.6.1 https://issues.apache.org/jira/browse/SPARK-12057
For now you can compile a version of spark which includes the fix (essentially raising a parsing exception instead of a general exception on a MatchError and then reporting the record as corrupt - see code https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/json/JacksonParser.scala )


Polynomial solution of non-homogeneous linear recurrence relation

Question: Suppose we have a non-homogeneous linear recurrence relation
$$
a(n) + c_{1}a(n-1) + \dots + c_{d}a(n-d) = p(n), \,\, n\in\mathbb{Z}
$$
where $c_1,\dots, c_d$ are constants. If $p(n)$ is a polynomial, is there always a particular solution $a(n)$ which is a polynomial?
Basic texts I've looked at are all following a trial-and-error approach, without stating anything general. A pointer to a helpful reference would be much appreciated!
Comment: Yes; check any textbook in discrete math. You can find a solution by indetermined coefficients as a polynomial of degree $\deg p$ plus the multiplicity of $0$ as a root of the characteristic equation. All the theory is **exactly** the same as in the case of differential equations.
Comment: Thanks for your comment! The thing is, a large proportion of the basic texts actually don't do this. The "method of indetermined coefficients" is even given another colloquial name: "method of judicious guessing"! And the presentation is something like: here's what you should guess in this kind of case; look, here are some examples where it works. If you have a nice suggestion of a particular textbook where this result is stated in a nice way, that would be fab!
Answer: As noted above, there are many resources for this well-studied problem. In particular, when the the RHS is a polynomial of degree $k$ you start with the ansatz $Q(x)$ of the same degree. There are also algorithms. At any rate, here is one online reference in case you find no access to books.
  http://www.fq.math.ca/Scanned/40-2/el-wahbi.pdf


Is it worthwhile to cover fiberglass insulation with Tyvek under a house?

Question: I have a raised home in New Orleans, where the weather is hot and humid 2/3 of the year, but it can get quite cold for brief periods in the winter.
The house is about 100 years old and there is some old fiberglass insulation installed between the beams under the house. But in most places the batts do not fill the entire space between the beams. There is still plenty of room for some more insulation. I have started to fill the remaining space with some more fiberglass insulation, and I am also stapling Tyvek sheets to the lower edges of the beams, so that the Tyvek will completely cover the underside of the house, and help support the additional fiberglass.
But before continuing with this labor intensive project, I would like to have an opinion: does it make sense to add the extra insulation that way, and is the Tyvek cover going to serve any insulation purpose (other than helping with the support)?
Answer: Tyvek will not add any insulative value.
Aside from helping keep the insulation in place and preventing it from falling down, it will act as a draft stop and might be worth your time to install it.
Answer: It may no longer be the case, or perhaps in this one, but Tyvek cannot handle long term UV exposure, and would figure that the underside of the home will at least get some exposure, even if it is indirect. After a period of time the Tyvek becomes very weak, like notebook paper and may not be able to handle a stiff breeze or wind. I used Tyvek on my home and evidently, did not cover it in the time specified and when I did a chimney addition I found this. I wasn't pleased at all.
Comment: When I built my home, Tyvek had a 30 day exposure warrantee, now I believe it is 90 days to allow it to be exposed before covering, to keep its warranty. At the time I was certain it was less than 30 days but who knows? It still does not last with exposure.
Comment: I did not know about the effect of UV exposure on Tyvek. I am hoping that the underside of my house is sheltered enough from light that it won't be a serious problem but in any case I plan to check regularly and fix whatever problems as they occur.


How to autostop jmeter once all URL execute from Excel sheet

Question: I have 250+ URL in excel sheet and i need to run all 250+ URL and once 250+ URL execute jmeter should auto stop.
Thanks in advance
Answer: On the CSV data set config change Recycle on EOF to False and Stop thread on EOF to True. This will make Jmeter stop when the CSV file reach the end of file.
Check Using CSV DATA SET CONFIG for more info.
Comment: Hi i used virtual user as 30 and thread group run for 30 virtual users. How can i cross verify that the 250+ URL are hitted and getting the result.
Comment: Add view result tree listener at the same level of your thread group and check the requests that has been sent and their response.
Comment: hi are you telling about above the screen shot value
Comment: No, i meant [View result tree listener](http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree)
Comment: there i get 30 response and how i can verify whether the 250+ hitted by user or not
Comment: If you want the 30 Vusers to keep running till the 250+ URL are hit, then tick the **Forever** box on the thread group.


Oracle Database Rownum Between

Question: There are 25 records in this sql query
I want to get between 5 and 10. How can I do it ?
I use 11g
select
(
    select count(*) as sayfasayisi
    from konular t
    where t.kategori is not null
) as sayfasayisi,
t.id,
t.uye,
t.baslik,t.mesaj,t.kategori,t.tarih,
t.edittarih,t.aktif,t.indirimpuani,t.altkategori,t.link,
nvl(
    (select case when t.id = f.konuid and f.uye = 'test' then '1' else '0' end
     from takipkonu f where t.id = f.konuid and f.uye = 'test'), '0') as takip
from konular t
where t.kategori is not null

Comment: Oracle does not assign a permanent row number to records, so if you're looking for 5th to 10th record from your table, please know that it is not guaranteed that you will get the same records every time. For your specific question here, you need to see your specific requirement for retrieving only those records.
Comment: You can use `ROW_NUMBER()` with a certain ordering and then retain only the 5th through 10th record.  [See here](https://stackoverflow.com/questions/7480243/sql-oracle-order-by-and-limit).
Answer: You can use ROW_NUMBER() to assign a row number based on some ordering logic contained in your current query, e.g. a certain column.  Then, retain only the 5th to 10th records:
select t.*
from
(
    select
    (
        select count(*) as sayfasayisi
        from konular t
        where t.kategori is not null
    ) as sayfasayisi,
    ROW_NUMBER() OVER (ORDER BY some_col) rn,
    t.id,
    t.uye,
    ...
) t
where t.rn between 5 and 10;

Oracle Database Rownum Between


Dimension of image and kernel?

Question: If W is a subspace of $\mathbb R^4$ given by $W=\{(x,y,z,w):x+z+w=0,y+z+w=0\}$ . Then what will be the dimension of image and kernel of W.
I just learned that dimension of $W=\text{number of independent variables}-\text{number of constraints}=4-2=2$. I amcurious to know abou the dimension of kernel and image.
Comment: The $W$ is your question is a *subspace*. The concept of image and kernel are defined for a *linear transformation*. You have confused these two concepts. So your question, as it stands now, is meaningless.
Answer: You need a linear function for a kernel and an image. A set doesn't have one. If you consider $A=\begin{pmatrix}1 & 0 & 1& 1\\0&1&1&1\end{pmatrix}$ then it induces a linear map $L:\mathbb R^4\to\mathbb R^2$ defined by $$
L\begin{pmatrix}x\\y\\z\\w\end{pmatrix}=A\begin{pmatrix}x\\y\\z\\w\end{pmatrix}=\begin{pmatrix}x+z+w\\y+z+w\end{pmatrix}.
$$
For this linear map we have a kernel
\begin{align}
ker(L)&=\left\{\begin{pmatrix}x\\y\\z\\w\end{pmatrix}\in \mathbb R^4~:~L\begin{pmatrix}x\\y\\z\\w\end{pmatrix}=\begin{pmatrix}0\\0\end{pmatrix}\right\}=\left\{\begin{pmatrix}x\\y\\z\\w\end{pmatrix}\in\mathbb R^4~:~\begin{pmatrix}x+z+w\\y+z+w\end{pmatrix}=\begin{pmatrix}0\\0\end{pmatrix}\right\}\\
=&=\left\{\begin{pmatrix}x\\y\\z\\w\end{pmatrix}\in\mathbb R^4~:~x+z+w=0,y+z+w=0\right\}
\end{align}
You see, this is your set $W$. Now consider $L$. You might can use the following formula
$$
\dim(W)=\dim(ker(L))=\dim(domain(L))-\text{rank}(L)=\dim(\mathbb R^4)-\text{rank}(A)=4-2=2.
$$
The rank of $A$ is the maximal linear amount of linear independent rows.
And the image of $L$ is given by
$$
image(L)=\left\{\begin{pmatrix}a\\b\end{pmatrix}\in\mathbb R^2~:~\text{there exists }\begin{pmatrix}x\\y\\z\\w\end{pmatrix}\text{ such that }L\begin{pmatrix}x\\y\\z\\w\end{pmatrix}=\begin{pmatrix}a\\b\end{pmatrix}\right\}.
$$
The dimension of $image(L)$ is such the rank of $A$ and therefore it can't be greater than the dimenion of the codomain. Here it is $2$ and since $\dim(\mathbb R^2)=2$ you get $image(L)=\mathbb R^2$.

Dimension of image and kernel?