Stackoverflow exception when transitioning an issue status to itself (tested to tested) in Jira Scriptrunner

Question: I am using the Jira custom post function of ScriptRunner on a transition to be executed by the user from one state to itself. I am having a StackOverflow exception after executing a transition that leads to itself. I would like to transition the current status of the issue to itself. In my case, "Tested" to "Tested" and I am running into a stackoverflow exception when I do this. Here is my code in ScriptRunner. This is a custom postfunction code to be executed when the user clicks on a transition.
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import com.atlassian.event.Event
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.ofbiz.core.entity.GenericValue;
import org.ofbiz.core.entity.GenericEntity;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import org.ofbiz.core.entity.GenericDelegator;
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.Issue
import groovy.xml.MarkupBuilder
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.link.LinkCollectionImpl;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.workflow.WorkflowManager;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.workflow.function.issue.AbstractJiraFunctionProvider;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;
import com.opensymphony.workflow.loader.ActionDescriptor;
import com.opensymphony.workflow.loader.StepDescriptor;
import com.opensymphony.workflow.spi.SimpleStep;
import com.atlassian.jira.config.ConstantsManager
import com.atlassian.jira.workflow.ImmutableWorkflowDescriptor
import com.atlassian.jira.web.action.admin.workflow.ViewWorkflowStep
import com.opensymphony.workflow.loader.ActionDescriptor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.bc.issue.IssueService.IssueValidationResult
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilFactory
def log = Logger.getLogger("atlassian-jira.log")

def defectComment= "Fix FIXSUMMARY[ISSUEKEY] has been released by USERNAME[USER].";
// def fixComment= "The following Defects resolved by this Fix were notified: ISSUEKEYS.";
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
List<IssueLink> links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
List<IssueLink> linksIn = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
ApplicationUser applicationUser=getCurrentUser();
            ArrayList<MutableIssue> issuesWithValidateError = new ArrayList<MutableIssue>();

log.warn("resolved "+ links.size()+" links in size "+ linksIn.size() +" "+ applicationUser)

for( def link in links){
    if(link.getLinkTypeId()==10022){
    log.warn("resolved "+link)

    }
}

User loggedInUser = getCurrentUser().getDirectoryUser();
 log.warn("resolved transition 1"+loggedInUser )
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
 log.warn("resolved transition 2" )

JiraWorkflow workflow = workflowManager.getWorkflow(issue);
 log.warn("resolved transition 3" )

List <Object> actions = workflow.getLinkedStep(issue.getStatus()).getActions();
 log.warn("resolved transition 4" )

def wfd = workflow.getDescriptor();
 log.warn("resolved transition 5" )

def actionName = wfd.getAction(transientVars["actionId"] as int).getName();
 log.warn("resolved transition 6 "+actionName )

 def actionId= transientVars["actionId"] as int;
  log.warn("resolved transition 7 "+actionId )

transition(actionId)

void transition(int transitionToBeDone) {

log.warn("CAM 1" + issue.getIssueType().name)

  def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
  log.warn("CAM 2" )

def issueManager = ComponentAccessor.issueManager
log.warn("CAM 3" )

IssueService issueService = ComponentAccessor.getIssueService()
log.warn("CAM 4" )

def actionId = transitionToBeDone // change this to the step that you want the issues to be transitioned to
log.warn("CAM 5" )

def transitionValidationResult
log.warn("CAM 6" )

def transitionResult
log.warn("CAM 7" )

def customFieldManager = ComponentAccessor.getCustomFieldManager()
log.warn("CAM 8 " )

 transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
log.warn("CAM 9 " )

 if (transitionValidationResult.isValid()) {
 transitionResult = issueService.transition(currentUser, transitionValidationResult)
 if (transitionResult.isValid())
 { log.warn("Transitioned issue $issue through action $actionId") }
 else
 { log.warn("Transition result is not valid") }
 }
 else {
 log.warn("The transitionValidation is not valid")
 }

}

 ApplicationUser getCurrentUser() {
        ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getUser();
        if (user == null) {
            String defaultUser = gc.getValue("user");
            user = ComponentAccessor.getUserManager().getUserByName(defaultUser);
        }
        return user;
    }

I am getting a stackoverflow exception so my log.warn statements keep getting printed indefinitely. Here is my output. I suspect the reason for this is that my action ID (transition to be done) is leading to the same status which is Tested to Tested, it is leading to itself. I have tried having tested leading to a different status such as Follow up and it worked and I didn't have any error. Anyone knows what needs to be fixed?
2022-08-15 01:54:23,721+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 7
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 6
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 5
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 4
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 3
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 2
2022-08-15 01:54:23,706+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 1Fix
2022-08-15 01:54:23,690+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 7
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 6
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 5
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 4
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 3
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 2
2022-08-15 01:54:23,674+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 1Fix
2022-08-15 01:54:23,628+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 7
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 6
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 5
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 4
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 3
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 2
2022-08-15 01:54:23,612+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 1Fix
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 7
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 6
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 5
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 4
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 3
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 2
2022-08-15 01:54:23,581+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 1Fix
2022-08-15 01:54:23,565+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,565+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 7
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 6
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 5
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 4
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 3
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 2
2022-08-15 01:54:23,549+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 1Fix
2022-08-15 01:54:23,534+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 9
2022-08-15 01:54:23,534+0200 https-openssl-nio-443-exec-21 WARN mouh 114x35166x1 txzbek 10.248.75.214 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] CAM 8

Answer: I found the answer, I was having a recursive call inside my code. I didn't think of it as recursive because it was a static method accessed from another class. Here os the line that was causing the recursion:
 transitionResult = issueService.transition(currentUser, transitionValidationResult)

Here is the correct code below:
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import com.atlassian.event.Event
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.ofbiz.core.entity.GenericValue;
import org.ofbiz.core.entity.GenericEntity;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import org.ofbiz.core.entity.GenericDelegator;
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.Issue
import groovy.xml.MarkupBuilder
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.link.LinkCollectionImpl;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.workflow.WorkflowManager;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.workflow.function.issue.AbstractJiraFunctionProvider;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;
import com.opensymphony.workflow.loader.ActionDescriptor;
import com.opensymphony.workflow.loader.StepDescriptor;
import com.opensymphony.workflow.spi.SimpleStep;
import com.atlassian.jira.config.ConstantsManager
import com.atlassian.jira.workflow.ImmutableWorkflowDescriptor
import com.atlassian.jira.web.action.admin.workflow.ViewWorkflowStep
import com.opensymphony.workflow.loader.ActionDescriptor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.bc.issue.IssueService.IssueValidationResult
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilFactory
import com.atlassian.jira.workflow.TransitionOptions

def log = Logger.getLogger("atlassian-jira.log")

//def defectComment= "Fix FIXSUMMARY[ISSUEKEY] has been released by USERNAME[USER].";
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
List<IssueLink> linksOut = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
List<IssueLink> linksIn = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
ApplicationUser applicationUser=getCurrentUser();
ArrayList<Issue> issuesWithValidateError = new ArrayList<Issue>();
List<IssueLink> links = new ArrayList<IssueLink>()

log.warn("resolved "+ linksOut.size()+" links in size "+ linksIn.size() +" "+ applicationUser)

log.warn("THIS IS MY LINK LINKSOUT "+linksOut.size())

for( IssueLink link in linksOut){
    if(link.getDestinationObject().getIssueTypeId().equals("5")){
    log.warn("THIS IS MY LINK everything "+link.getLinkTypeId() +" "+ link.getDestinationObject().getKey())

    links.add(link)
}

}
log.warn("THIS IS MY LINK linksIn "+linksIn.size())

for( IssueLink link in linksIn){
if(link.getDestinationObject().getIssueTypeId().equals("5")){
        log.warn("THIS IS MY LINK everything "+link.getLinkTypeId() +" "+ link.getDestinationObject().getKey())

    links.add(link)
}
}

for( IssueLink link in links){

    log.warn("THIS IS MY LINK MOUNA "+link + link.getDestinationObject().getKey())
}
  if(links.isEmpty()){

                log.warn("No linked Defect-Issues found.");
                return;
            }
User loggedInUser = getCurrentUser().getDirectoryUser();
 log.warn("resolved transition 1"+loggedInUser )
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
 log.warn("resolved transition 2" )

JiraWorkflow workflow = workflowManager.getWorkflow(issue);
 log.warn("resolved transition 3" )

List <Object> actions = workflow.getLinkedStep(issue.getStatus()).getActions();
 log.warn("resolved transition 4" )

def wfd = workflow.getDescriptor();
 log.warn("resolved transition 5" )

def actionName = wfd.getAction(transientVars["actionId"] as int).getName();
 log.warn("resolved transition 6 "+actionName )

 def actionId= transientVars["actionId"] as int;
  log.warn("resolved transition 7 "+actionId )

log.warn("This is the last action "+actionName);
List<String> sourceObjectLinkList= new ArrayList<String>();

def targetStatus= getTargetStatus( issue);
 log.warn("resolved transition targetStatus "+targetStatus +"end")    ;

//transition(actionId, links)
  for(IssueLink link : links){

    String foundID = foundActionID(link);

    if(foundID == null){

                    log.error("Action for Issue " + link.getKey() + " not found!");
                    issuesWithValidateError.add(link);
                    continue;
                }
     log.warn("CAM 0 "+ foundID)    ;

    Mounatransition(link.getDestinationObject(),foundID, link.getSourceObject());
     log.warn("links tostring "+ links.toString())    ;

    sourceObjectLinkList.add(link.getDestinationObject().getKey());
    log.warn("MOUNA COMMENT "+link.getDestinationObject().getKey())

  }
log.warn("MOUNA COMMENT "+ sourceObjectLinkList)
String fixComment= "The following Defects resolved by this Fix were notified: ISSUEKEYS.";

fixComment = fixComment.replaceAll("ISSUEKEYS", sourceObjectLinkList.toString());
log.warn("MOUNA CAMELIA COMMENT "+ fixComment)

CommentManager commentManager = ComponentAccessor.getCommentManager();
            // add comment but do NOT fire event
commentManager.create(issue, getCurrentUser(), fixComment, false);

void Mounatransition(Issue linkedissue, String transitionToBeDone, Issue sourceObject) {
def defectComment= "Fix FIXSUMMARY[ISSUEKEY] has been released by USERNAME[USER].";

 log.warn("CAM 1 "+ transitionToBeDone)

IssueService issueService = ComponentAccessor.getIssueService()
log.warn("CAM 1 "+transitionToBeDone)
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.warn("CAM 2")

TransitionOptions transitionOptions = new TransitionOptions.Builder()
        .skipConditions()
        .skipPermissions()
        .skipValidators()
        .build()
log.warn("CAM 3")
  int transitionToBeDoneInt = transitionToBeDone as Integer
String status = getTargetStatus(sourceObject)  as String;
def constantsManager = ComponentAccessor.getConstantsManager()

   def statusName=constantsManager.getStatus(status).getName();
log.warn("STatus"+status)

def inputParameters = issueService.newIssueInputParameters()
log.warn("CAM comment "+defectComment +" summary: "+sourceObject.getSummary())

defectComment=defectComment.replaceAll("FIXSUMMARY", sourceObject.getSummary());
log.warn("CAM comment 2"+defectComment)

defectComment=defectComment.replaceAll("ISSUEKEY", sourceObject.getKey()).replaceAll("USERNAME", currentUser.getDisplayName());
log.warn("CAM comment 3"+defectComment)

defectComment=defectComment.replaceAll("USER", currentUser.getName());
log.warn("CAM comment 4 "+defectComment)

defectComment=defectComment.replaceAll("released", "set to \"" + statusName + "\" ");
log.warn("CAM comment 5 "+ defectComment)

inputParameters.setComment(defectComment)
IssueService.TransitionValidationResult result = issueService.validateTransition(currentUser,
        linkedissue.getId(),
        transitionToBeDoneInt,
        inputParameters,
        transitionOptions)
log.warn("CAM 4 "+ linkedissue.getKey())

try {
    if(result.isValid()) {
    log.warn("CAM 5")

    issueService.transition(currentUser, result)

}

} catch(Exception e) {
        log.warn("CAM 6 "+e)

      log.warn (result.getErrorCollection().getErrors());

}

}

 ApplicationUser getCurrentUser() {
        ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getUser();
        if (user == null) {
            String defaultUser = gc.getValue("user");
            user = ComponentAccessor.getUserManager().getUserByName(defaultUser);
        }
        return user;
    }
 def getTargetStatus(Issue issue) {
            log.warn("resolved inside target")

        def targetStatus = "";
        try {
            List currentSteps = (ArrayList)transientVars.get("currentSteps");
        SimpleStep simpleStep = currentSteps.get(0);
        int actionId = simpleStep.getActionId();
        int beforeStepId = simpleStep.getStepId();
        def workflow = ComponentAccessor.workflowManager.getWorkflow(issue)
        ActionDescriptor ad = workflow.getDescriptor().getAction(actionId);
        int afterStep = ad.getUnconditionalResult().getStep();
        log.warn("resolved transition target "+afterStep)
log.warn( "resolved transition target last "+ComponentAccessor.workflowManager.getNextStatusIdForAction(issue , transientVars['actionId'] as int) )

         targetStatus=ComponentAccessor.workflowManager.getNextStatusIdForAction(issue , transientVars['actionId'] as int)
def constantsManager = ComponentAccessor.getConstantsManager()

   def statusName=constantsManager.getStatus(targetStatus).getName();
        log.warn("resolved transition target "+targetStatus + "status name "+statusName)

        } catch (Exception exception)
        {
            log.error("getTargetStatus threw exception: " + exception.getMessage());
        }
        return targetStatus;
    }

     String foundActionID(IssueLink issueLink){

        String id = null;
                log.warn("foundActionID 1 here")
        Issue issue=issueLink.getDestinationObject()
        List<StepDescriptor> actionDescriptorList = ComponentAccessor.workflowManager.getWorkflow(issue).getDescriptor().getSteps();
                        log.warn("foundActionID 2 here" )

        List<ActionDescriptor> myStepDescriptor = null;
        log.warn("foundActionID 3 here"+actionDescriptorList )
        Boolean foundAction = false;
        log.warn("foundActionID 1"+foundAction)
        for (StepDescriptor stepDescriptor : actionDescriptorList) {

            if (stepDescriptor.getName().equals(issue.getStatusObject().getName())){

                myStepDescriptor = stepDescriptor.getActions();
                                log.warn("foundActionID2 "+myStepDescriptor)

                break;
            }
        }

        for(ActionDescriptor actionDescriptor : myStepDescriptor) {
                log.warn("foundActionID3 ")
            WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
            JiraWorkflow workflow = workflowManager.getWorkflow(issue);
            List<ActionDescriptor>actionIDs= workflow.getLinkedStep(issue.getStatus()).getActions();
            log.warn("foundActionID4 "+actionIDs +"  "+String.valueOf(actionDescriptor.getId()))
            List<String> actionIdsStrings= new ArrayList<String>();
            for(ActionDescriptor a in actionIDs){
            actionIdsStrings.add(Integer.toString(a.getId()));
            }

            if(actionIdsStrings.contains(String.valueOf(actionDescriptor.getId()))){

                id = String.valueOf(actionDescriptor.getId());
                foundAction = true;
                log.warn("foundActionID5 "+ id)

                break;
            }
        }

        if(!foundAction)
            return null;

        return id;
    }


Can I run CTS if there is no external SD card slot on the Android device and how?

Question: I am assigned to run CTS on our Android device (Android TV). However, no SD card slot is in the design.
Can I still run CTS without any SD card? If I can what should I do to store media data?
Answer: Yes, You can run CTS without SD card implemented on device. Android is not mandated SDCard support.
Example, Pixel devices does not support SD card, but they passed android CTS certification.


How do I solve volumes bounded by solids using slices?

Question: How to find the volume of the solid bounded by the paraboloid $y^2+4z^2=x$ and the plane $x=4$ Using the slice (ellipse) indicated in the figure to compute the volume?
Ellipse
Comment: You have to put `$` signs around the MathJax expressions for the formatting to work.
Comment: That seems like a strange picture to me.  Why wouldn't one take slices parallel to the $yz$-plane?
Answer: \begin{align*}&\int_{y^2+4z^2\leq 4}\ (4-y^2-4z^2)\ dA \\&=
\int_{y=-2}^{y=2}\int_{ -\sqrt{\frac{4-y^2}{4}} }^{
\sqrt{\frac{4-y^2}{4}} } \ (4-y^2-4z^2)\
 dzdy \\
 &=\int_{-2}^2\ \frac{2}{3}(4-y^2)\sqrt{4-y^2}\ dy \\&=
   \int^{\pi}_0\ \frac{32}{3} \cdot\sin^4 t\ dt\\&=
4\pi
\end{align*} since $$ \sin^4 t
=(1-\cos^2 t)^2 =\bigg(1- \frac{\cos\ 2t+1}{2} \bigg)^2 = \frac{3}{8}
 +C\cos\ 2t +D\cos\ 4t $$
Answer: First you find the intersection of the plane $x=4$ and the parabolid $y^2+4z^2=x$
That gives you an ellipse $y^2/4+z^2=1$
Then you form a double integral on the ellipse with the integrand being the function $4-y^2-4z^2$
Follow the proof given by HK Lee for the rest of the story.
Comment: I'm not sure this is what the OP is asking for.  I think the question means that he wants to integrate the volume of an elliptical cylinder as $x$ runs from $0$ to $4$.
Comment: thank you @saulspatz, I really dont know how to solve this. do you have a solution you could show me on how to do this?
Answer: The idea is to approximate the volume by slices parallel to the $yz$-plane.  The slices are elliptical cylinders so the volume is the height times the area of the base.
The cross-section at height $x$ is the ellipse$${y^2\over(\sqrt{x})^2}+{z^2\over(\sqrt{x}/2)^2}=1$$ whose area is ${\pi x\over 2}$.  Taking this as the base, and the height as $dx$ we get $$V=\int_0^4 {\pi x\over2}\mathrm{dx}$$
Comment: can this still be integrated though?
Comment: @AnthonyFernandez Surely you know how to integrate $x\mathrm{dx}$
Comment: yep haha thanks @saulspatz
Comment: the answer is 4π right?
Comment: @AnthonyFernandez Yes, that's right.


Device to detect where heat or cold air is escaping or entering a structure

Question: I would like to lower my environmental impact and reduce my energy bills by reducing areas where air might be entering or exiting my home.
What type of device can be used to detect where heat or cool air is escaping or entering a home?
I would prefer the device be inexpensive, if possible.
Comment: Honestly, in the middle of winter, I use my hand to feel for cold drafts.  Just left a rental property where I did this along the stone foundation wall with a can of great stuff in the other hand.
Comment: @ssaltman That is certainly inexpensive! :)
Comment: MOE12 has the inexpensive answer. The expensive one is a FLIR or other thermal imaging camera. [Handheld standalone](http://www.amazon.com/FLIR-E4-Compact-Thermal-Resolution/dp/B00FKD9DSW/ref=sr_1_2?ie=UTF8&qid=1418395627&sr=8-2&keywords=flir+imager) versions start at about $1000, and it looks like [Android](http://www.amazon.com/Seek-UW-AAA-Thermal-Connector-Black/dp/B00NYWAHHM/ref=pd_sim_p_1?ie=UTF8&refRID=1HQWSD3P8HQCFV6GFGZW)/[IOS](http://www.amazon.com/FLIR-ONE-Thermal-Imager-iPhone/dp/B00K0PXFB6/ref=pd_sim_hi_4?ie=UTF8&refRID=1SX9HAQVE0TFB9R7V31R) plugins run from $200-300.
Answer: A thermal imaging gun will show you all the hot and cold spots inside your house, but they are very expensive.
What I did was I purchased a infrared thermometer gun at my local harbor freight. It cost about $15.00 Then I went around took all the temperatures throughout the house.
I found in my basement the rim joists were not insulated, I also found my attic hatch was not insulated. After doing that and caulking the windows, the cost for the insulation and caulk paid for itself the first winter.
Comment: You may be able to rent one.
Comment: for rental, see, e.g., [here](http://www6.homedepot.com/tool-truck-rental/mobile/Thermal_Camera/FLIR_i7/) (promise I'm not advertising any particular service -- others please add other links of you know of them, this is just the first thing that popped up and was available in my area)
Answer: A FLIR (infrared) or thermal imager is still the best way; you can rent them pretty easy and cheap, even at Home Depot http://www.flir.com/homedepot/
Comment: do you think 3 hours is a reasonable amount of time to be able to use the FLIR properly? HD near me offers a 4-hr rental, not sure I'll be able to image my whole apartment in that window.
Answer: I have a FLIR camera. It's awesome, but it's expensive and not necessarily the best tool for detecting air leaks. An IR camera is too slow; you won't use it unless you have more dedication than most.
What you want is a fog machine. Turn it on inside the house, close all the windows but one, and put a box fan in that window blowing air into the house. This will pressurize the house and force the fog outside. You go outside and see where the fog is coming from. For an even more spectacular effect, get colored fog juice.


p:confirmDialog message not refreshed after f:setPropertyActionListener

Question: I have a datatable and on each row there is a commandLink. On click of commandLink I set the row object to a property of baking bean using f:setPropertyActionListener tag.
When I debut I can see setter of property has been called and correct value is getting passed. On commandLink oncomplete I also have a call to open ConfirmDialog, which shows some values from selected row to user before confirming the action.
The problem is that ConfirmDialog is not showing the latest value selected.

    <f:setPropertyActionListener target="#{corporateActionBean.selectedCARecord}"
                                 value="#{dividendRecord}"/>

Answer: Do you have the dialog in same <h:form> element? Looks like the update="@form" attribute is causing the problem. Try to put table and dialog in the same form and set update="confirmDialog".


Accessing specific value of rows and columns in pandas

Question: I have a data set with a few columns and rows

I have to create a bar graph of the mean revenues from the year 2006-2011 and 2012-2016
I've already tried using if statements to separate the revenues from 2006-11 and 2012-16 but getting errors.
if movie_data['Year']<=2011:
    movie_data['rev_new']=movie_data['Revenue (Millions)']
print(movie_data)

Answer: I would create two bins for the two time windows by manually specifying your desired time frames
bins = pd.cut(pd.to_datetime(df['year']), bins=[pd.to_datetime('2006'), pd.to_datetime('2011'), pd.to_datetime('2016')])

Then group your dataframe by these bins and create your bar chart
df = df.groupby(bins).mean()
df['Revenue (Millions)'].plot(kind='bar')

Answer: You can separate the dataframe in this way:
before_2011 = movie_data[movie_data['Year'] <= 2011]
after_2012 = movie_data[movie_data['Year'] >= 2012]

and access the revenues as:
before_2011['Revenue (Millions)']

Comment: yea got it mate. Thanks


How to send push message from Kinvey and Delphi for a specific user

Question: Does anyone know how to send a push message to a particular user through Kinvey service? Today I can send Push for everyone who uses my application, but I need to send to a single user.
thanks
Answer: I found this comment in a blog article:

If you select Addons > Messaging > Push and select to send a message
  to Everyone, then everyone who has your app installed will receive
  that message. You can also setup specific users inside Kinvey and then
  select 'Specific Users' and define the users you want to send the
  message to.
Comment: Thanks. I'm reading this post, but is not complete. I did not like to do.
Comment: @user558516 have you tried to set up specific users inside Kinvey, or contacted the vendor support (forums)?
Answer: Basically I am using KinveyProvider and PushEvents to authenticate
TBackendUsers to create new user KINVEY
In Console Kinvey created in Business Logic A Custom EndPoint as their documentation
Then in Delphi I shoot the KinveyProvider.EndPoint: = 'name kinvey endpoint';
I know it's not exactly what you need, as I am also studying the same point you thought it would be helpful to share this information.


NotifyItemMoved between different ViewTypes Not Working

Question: I have been going at this problem for many days now with no end in sight, so any help would definetely be appreciated! This is the problem:
I have a room database and a recycler view where I display part of that database. And generally everything works fine. However, if I try to drag (thus switching the order) of two items with different viewtypes, the adapter drops the item back at his original place.
This previous stack overflow question displays the problem beautifully:Android RecyclerView: drag and drop over multiple ViewType
The code: (In the fragment java)
        // Configuring RecycleView
        RecyclerView recyclerView = root.findViewById(R.id.recyclerview_viewpager_schedule);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.setHasFixedSize(true);

        // configuring Adapter
        daysAdapter = new DaysAdapter();

        prevfrom = -1;
        flagish = -1;

        //daysAdapter.setHasStableIds(true);
        recyclerView.setAdapter(daysAdapter);

        daysViewModel.getNotesInDay(args.getInt(ARG_OBJECT)).observe(getViewLifecycleOwner(), new Observer<List<DayActivity>>() {
            @Override
            public void onChanged(List<DayActivity> dayActivities) {
                //I use a flag in order for the list not to update onMove because that makes a weird looking effect. It updates later on and it works just fine!
                if (flagish != 5) daysAdapter.submitList(dayActivities);
                flagish = 1;

            }
        });

        ItemTouchHelper mIth = new ItemTouchHelper(
                new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0) {
                    @RequiresApi(api = Build.VERSION_CODES.N)
                    @Override
                    public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
                        final int fromPos = viewHolder.getAdapterPosition();
                        final int toPos = target.getAdapterPosition();

                        Log.d("onMove", "From:" + fromPos);
                        Log.d("onMove", "to:" + toPos);

                        Log.d("STOP_HERE_please_1", fromPos + "   " + toPos);
                        Bundle arguments = getArguments();
                        Log.d("STOP_HERE_3", String.valueOf(arguments.getInt(ARG_OBJECT)));

                        if (fromPos==toPos) return false;

                        //prevFrom is the previous fromPos in case the item hansn't been dropped yet
                        if (prevfrom == -1) prevfrom = fromPos;
                        if (prevfrom == toPos) return false;
                        getView().clearFocus();

                        // Change position

                       DayActivity lItem;
                        newList = new ArrayList<>();

                        int lIncrement = (fromPos<toPos) ? -1 : +1; //  true if scroll down
                        int lMax = Integer.max(prevfrom, toPos);
                        int lMin = Integer.min(prevfrom, toPos);

                        List<DayActivity>oldList =daysAdapter.getOrdersBetween(lMin, lMax);
                        //This function (getOrdersBetween) gets the DayActivities whose positions are between those two values
                        for (int i=lMin; i<= lMax; i++) {
                            lItem = oldList.get(i);
                            if (i == fromPos) {
                                lItem.setOrder_Day(toPos);
                            } else
                                lItem.setOrder_Day(lItem.getOrder_Day() + lIncrement);
                            //The program uses the order to order the items in the recycler view
                            newList.add(lItem);
                        }

                        daysAdapter.notifyItemMoved(fromPos, toPos);

                        return true;

                    }

                    @Override
                    public boolean isLongPressDragEnabled() {
                        return true;
                    }

                    @Override
                    public boolean isItemViewSwipeEnabled() {
                        return false;
                    }

                    @Override
                    public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
                    }

                    @Override
                    public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) {
                        super.onSelectedChanged(viewHolder, actionState);
                        if (actionState == ACTION_STATE_DRAG)
                            viewHolder.itemView.setAlpha(0.5f);
                    }

                    @Override
                    public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
                        super.clearView(recyclerView, viewHolder);
                        viewHolder.itemView.setAlpha(1.0f);
                        flagish = 5;
                        if(newList != null) daysViewModel.updateList(newList);
                        prevfrom = -1;
                    }

I believe the problem is routed in the adapter.notifyitemmoved, but I haven't been able to solve it! Some people reccommended in other posts for me to make sethasStableIds(), but this function only lead notifyItemMoved to have a similar effect even if the two items have simiar viewtypes.
I don't think there is any need to overload this post with code from the adapter, but if anyone needs it, just let me know. Thanks!!!
Comment: Did you find a solution to this problem? I'm struggling to find a solution to this myself.
Comment: @masterwok unfortunately no!! I have decided to postpone solving this problem, because I have been reviewing those exact code lines for way too much time!! But if you ever find out, please, please, let me know!!!
Comment: I'm just about at that point too. I've been stuck on this for a week. I'll be sure to let you know if I find anything.
Comment: @masterwok thanks very much! it seems impossible... :(
Answer: NotifyItemMoved should work with different ViewTypes.
I assume you are using AsyncDiffer? Check if you override adapters getItemViewType(position) function correctly, maybe you are fetching position from AsyncDiffers current list which is not yet synced?


Bootstrap 3 Datetimepicker 3.0.0 - make a week start on Monday

Question: There are few reasons I use Bootstrap 3 Datetimepicker 3.0.0 in my MVC 5 project.
Any idea how to offset week start so it starts from Monday? Language tag also not working.
 $(function () {
    $('#PickupTime').datetimepicker({
     weekStart: 1
    });
 });

This is not working because it is not the same bootstrap-datapicker.js
Answer: If you are using moment.js from v2.8.1 onwards, add the below code before calling datetimepicker().
moment.updateLocale('en', {
  week: { dow: 1 } // Monday is the first day of the week
});

$('#DateTime').datetimepicker();

If you are using old version of moment.js, do the following
moment.lang('en', {
  week: { dow: 1 }
});

$('#DateTime').datetimepicker();

Comment: This works as expected. Shows Monday as the first day on the calendar. In addition to this i needed the Monday and Sunday from any date they picked.

 i.e if they choose 08/09/2018 (MM/DD/YYYY) then i needed 08/06/2018 and 08/12/2018 . to Get those I used the ```Weekday()``` function. i.e ```moment(new Date()).weekday(6).format("MM/DD/YYYY")``` which gave me Sunday for the week
https://momentjs.com/docs/#/get-set/weekday/
Answer: You can also override the dow value via the locale when calling datetimepicker()
$('#myid').datetimepicker({
    format:'YYYY-MM-DD',
    locale:  moment.locale('en', {
        week: { dow: 1 }
    }),
});

Comment: Worked like a sharm! Thanks
Answer: According to the options for Datetimepicker this is not possible. It only supports the following properties:
$.fn.datetimepicker.defaults = {
    pickDate: true,                 //en/disables the date picker
    pickTime: true,                 //en/disables the time picker
    useMinutes: true,               //en/disables the minutes picker
    useSeconds: true,               //en/disables the seconds picker
    useCurrent: true,               //when true, picker will set the value to the current date/time
    minuteStepping:1,               //set the minute stepping
    minDate:`1/1/1900`,               //set a minimum date
    maxDate: ,     //set a maximum date (defaults to today +100 years)
    showToday: true,                 //shows the today indicator
    language:'en',                  //sets language locale
    defaultDate:"",                 //sets a default date, accepts js dates, strings and moment objects
    disabledDates:[],               //an array of dates that cannot be selected
    enabledDates:[],                //an array of dates that can be selected
    icons = {
        time: 'glyphicon glyphicon-time',
        date: 'glyphicon glyphicon-calendar',
        up:   'glyphicon glyphicon-chevron-up',
        down: 'glyphicon glyphicon-chevron-down'
    }
    useStrict: false,               //use "strict" when validating dates
    sideBySide: false,              //show the date and time picker side by side
    daysOfWeekDisabled:[]          //for example use daysOfWeekDisabled: [0,6] to disable weekends
};

Source: http://eonasdan.github.io/bootstrap-datetimepicker/#options
You can disable the weekend if you don't want to see sunday.
Comment: Finally i switched to https://github.com/smalot/bootstrap-datetimepicker but will follow development of first one.
Comment: But still left column is sunday, and people expect monday
Comment: In bootstrap-datapicker.js I have offseted the names, but only names get mooved, not the dates itself, so entire calender is not correct. Eaven treid changing in moment.js, but same thing.
Comment: Any replacement sugestions?
Comment: NO i didn't. It is buggy and simply not working. Gong back to original.
Answer: Instead of using moment.js I used moment-with-langs.js (I guess it came with default package ASP.NET MVC 5).
By calling:

thing works, finally the calender starts from monday.
UPDATE:
Even better, add key to web.config
<appSettings>
    <add key="Culture" value="hr" />
</appSettings>

and then
$(document).ready(function () {
    $(document).on('focus', '#Date', function () {
        $(this).datetimepicker({
            locale: '@System.Configuration.ConfigurationManager.AppSettings["Culture"]',
            format: 'DD:MM:YYYY',
        });
    });
});

Answer: I have just done! In moment.js change this line:
_week : {
    dow : 1, // Sunday is the first day of the week.
    doy : 6  // The week that contains Jan 1st is the first week of the year.
},

'dow' MUST BE 1 and the week starts at Monday.
Answer: open jquery.datetimepicker.js and find variable "dayOfWeekStart" and set it to 1
Comment: The OP was referring to [Eonasdan Bootstrap-Datepicker](http://eonasdan.github.io/bootstrap-datetimepicker/). This has nothing to do with jQuery's datepicker.
Comment: Nothing to do with OP's question.
Comment: not edit, but use as option $(".dataPicker").datetimepicker({ dayOfWeekStart: 1 });
Answer: 'locale' => [
    'firstDay' => 1
]

Answer: I stumbled upon the same question, and i'm using:

Bootstrap3 Datetimepicker (4.14.30)
Moment (2.10.3)

And, following the answer of user3928861 I found the answer on line 961 of moment.js as follows:
var defaultLocaleWeek = {
    dow : 1, // Sunday is the first day of the week.
    doy : 6  // The week that contains Jan 1st is the first week of the year.
};

Answer: Datetimepicker has an option to set that to match wherever you are in the world (see the locale option http://eonasdan.github.io/bootstrap-datetimepicker/Options/#locale)
You can manually override it
$('#DateTime').datetimepicker({
    locale: moment.local('en')
});


How can I access GET parameters from a Facebook iframe tab using PHP?

Question: I am creating a Facebook iframe application, and need to use some $_GET variables.  This works fine for the application, using something similar to what is described in this question.
However, when I use the app as a tab inside of a facebook fan page, I can't figure out how to pass the variable, or retrieve it.  The URL for the site looks like this:
http://www.facebook.com/pages/(Page Name)/(Page ID)?sk=app_(app ID)

And if I try to simply tack a &var1=val1 to the end it doesn't work (Which I didn't really expect it to...) at all.
Is there a way that I can get to the displayed file, the home.php, in the url so I can tack the get variable onto the end and use it?  Right now, there's no way to make it so that a copy-pasted url directs to a specific page inside the application.
Answer: You need to pass JSON via the app_data parameter. See https://developers.facebook.com/docs/authentication/signed_request/ for details.
Comment: This seems as if the app_data section of the JSON is a good way to pass the variable on, but it doesn't make it so that the URL is changed in a way that will make a copy-past URL load the correct variable, correct?


Is this the right way to make my website google-friendly?

Question: I have created several Q about correctly mapping a website with a database so that google can index it properly. However, need more info.
My website is a classifieds website (PHP). Users can search ads on my site. Searching for 'BMW' will bring up only the titles of all 'bmw' ads and display them as a search result. (like google kindof).
When user clicks on an 'ad', no matter which ad, an ID of that ad is passed along to 'show_ad.php'.
In 'show_ad.php' the ID is received and the proper ad is displayed from the mysql database.
Also, when displaying the ad, meta-tags are also dynamically changed (fetched from db) to fit the ad (I need this so that google finds the ad easier hopefully).
Now, would this be enough for making my site 'friendly'?
Also, I can change the URL with .htaccess I think, so instead of:
   http://www.mypage.com/show_ad.php?ID=12345

it will show:
   http://www.mypage.com/12345.htm

Also, I think I must add a link like the one above inside a static html page for each ad created, just so that google knows its there... right?
But, still, will this be enough?
Please guide me...
Comment: iam not an expert, but i if you work on the URLs anyway, make it more "human readable" in the first place... so,

- Try to create "speaking" keys, e.g. instead of "123456" use "bmw-motorcycles-july-2010" or something..

so your url would be http://www.mypage.com/show_ads.php?key=bmw-motorcycles-july-2010
Comment: This does not look programming-related at all.  It should go to SuperUser or ServerFault.
Comment: I voted to close this question because it is not a programming question and it is off-topic on Stack Overflow. Non-programming questions about your website should be asked on [webmasters.se]. Please delete your question here and re-ask it there.
Answer: To make it more friendly, I would suggest the following:

For each URL, instead of having (just) an id, try to add keywords to the URL as well. The earlier the better: /bmw/12345/show_ad.php
For each page, make sure you have a good <title>. I.e. 'My page - Ads - BMW'
Have a proper
-tag containing the keywords you want to rank high in.
Answer: If your pages are dynamic and share a layout, there is a good chance Google will throw many of them out as duplicates. If the content is significantly different from page to page,there is less of a chance of that happening. Google will likely not index all of your pages in either case.
If possible, you should make your urls have words not numbers as Google will look at the URL for keywords.
Comment: Google is very good at detecting shared elements and ignoring them for duplicate content purposes.
Answer: I would recommend this book. An answer on stack overflow won't give you sufficient information.
(The art of SEO "Theory in Practice")
http://www.amazon.com/dp/0596518862
Comment: +1 Agreed. SEO is a huge field. Also check out Google's page on SEO http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35291
Answer: Yes, it will help a lot, google will still spider pages with parameters on the end, but they still treat .htm pages differently.
As another suggestion, try putting the subject into the filename:
http://www.mypage.com/traeger-grill-for-sale.htm

Or something like that, and have a search parameter thrown in to show_ad.php. This will help even more.
Comment: What's your evidence for them treating .htm pages differently?
Comment: My own SERPs, and consensus by pretty much every large player in the seo/marketing industry.

Nobody outside of Google truly knows how their algorithm works, so all you can do is measure results. And this one is pretty much common knowledge these days.
Answer: Don't use ids, use the tag in the URL, more Google and human friendly, so instead of
http://www.mypage.com/12345.htm

use URLs like this one
http://www.mypage.com/your_tag_name.htm

To do this type of things you would need another field in you DB for the URL friendly name for the tag (spaces, accents... removed) and use mod_rewrite to rewrite the URLs.
Answer: 1.URL is primary in your situation. Google does not like URL created from data base. So make a change to it. I recommend you make your URL in this way: www.yourdomain.com/BMW/12456/bmw-car-AD.The advantages of this URL are:
It is user friendly, Google friendly(since it contains keywords)and system stable as well(see the ID).
2.All of SEO stuff like good title and description tag,<im> your keywords, decently use <t>,keywords etc. It is worthwhile to read some related articles. Do not obsessed by SEO, do things Google encouraged you to do.
3.Good sitemap is also useful. Pay attention to URL structure of your whole site, if possible,  please build some inbound links to your site, that is also helpful.
Good luck to you!
Answer: Here is what Google says as of today (20 Apr 2023):
Optimize your site for search engines (for beginners)
Top tips to improve your site's search results on Google
Here are a few simple ideas that can help Google understand your site, and help the right people find it.
Be descriptive: Use accurate, descriptive titles for your pages. We recommend putting different topics, products, or services on different pages, one topic (or closely related set of items) per page.
Be complete: Mention everything that you have to offer. Google is smart, but we can't guess what you don't tell us.
Be topical: Update your content to account for seasons, trends, or new offerings. For example, if you run an ice cream store that also sells hot chocolate, be sure to feature your ice cream in the summer, and your hot chocolate (or coffee, or sandwiches) prominently in the winter, when people won't be looking for ice cream stores. If a new trend starts for kiwi ice cream and you have it in your store, feature it prominently.
Keep your site up to date: If you haven't updated your site since 1925, it's time to remove the references to Calvin Coolidge in your current events blog.
Use text: Don't put all your site content or page titles only in images, video, or other non-text formats that Google understands less well than text. If you use a graphic for your site name, include the name in the page text as well.
Get referrals: Have your site mentioned in useful places online. See if you can get into your local online news sites, or in any other appropriate resources.
Want more? Read the full guide here.


Finding solvable groups with given Fitting subgroup

Question:
Let $K=\mathbb Z_2 \times \mathbb Z_2$. What finite solvable groups (up to isomorphism) have Fitting subgroup isomorphic to $K$?

So far I've found that $K, S_4, A_4$ satisfy that property. I don't know whether there are others...  What follows is what I know. Let $G$ be a group we want to find. Then there is $n\in \mathbb N$ such that $G^{(n)}={1_G}$ (a derived subgroup is trivial). Its Fitting subgroup is the intersection of all the $p$-cores of $G$, or equivalently, the unique maximal normal nilpotent subgroup.
Since $p$-groups are nilpotent, if $G$ is a $p$-group, then $G=K$. Let's assume $G$ is not a $2$-group. Then there is $q\neq 2$ prime, dividing $|G|$. For every $p\neq 2$ dividing $|G|$, there are more than one Sylow $p$-subgroups, since its core is trivial.
Another important fact about finite solvable groups is that the centralizer of the Fitting subgroup is its center. In our case $C_G(K)=K$. Yet I can't see how this would help.

Is there a general strategy for any group $K$?
Answer: Since $C_G(K)=K$, the conjugation action of $G/K$ on $K$ maps $G/K$  into a subgroup of ${\rm Aut}(K) \cong S_3$. We can't have $|G/K| = 2$, so $|G/K| = 1,3,$ or $6$ giving the three examples that you have found. So there are no more examples.
The same strategy would work for any abelian $p$-group $K$. Otherwise it would get more complicated but could still be done because $G/Z(K)$ must be a subgroup of ${\rm Aut}(K)$, and hence $|G|$ is bounded.
Comment: Thanks. Another question then arises: how can I recover $G$ from the quotient $G/K$, without computing all the groups with that order and checking the other properties?
Comment: You know the conjugation action of $G/K$ on $K$, so you don't have to consider all such groups. But in general there could be nonsplit extensions.
Comment: Sorry, I still can't see how to find $G$ from the conjugation action...
Comment: For a given conjugation action, one possibility id=s the semidirect product of $K$ with $G/K$. But there could also be nonsplit extensions.
Comment: I've just read the definition of _split extension_ given by Wikipedia, but it doesn't help much... Let's go back to $K=\mathbb Z_2^2$. Let's say that the conjugation action of $G/K$ on $K$ maps $G/K$ into ${\rm Aut}(K)$. How do you know that $G \cong S_4$?
Comment: Because $S_4$ is the semidirect product of $Z_2^2$ by $S_3$ with the specified action. In this example you can see that there are no nonsplit extensions, because the normaliser of a subgroup of order $3$ is a complement of $K$. Sorry but I don't think I can help any more with this!


PS4 slim won't recognize controller

Question: I'm at my wit's end please help me. I have done all the things I needed to do with the controller and it still won't pick up. It does charge it but won't let me do anything with the PS4 even when I put it in safe mode.
Answer: Did you try resetting the controller?

Find a paperclip and press the reset button (under L2)
Hold it for ten seconds
Then press and hold the PS button

If that doesn't work try this:
http://manuals.playstation.net/document/en/ps4/settings/bluetooth.html

PS4 slim won't recognize controller


R crashes with "caught illegal operation" when installing gert

Question: I'm using R 3.4.4 and Ubuntu 16.04 and following gert installation instructions here. I have installed libgit2-dev, but gert installation crashes with the error below:
<code>** testing if installed package can be loaded

 *** caught illegal operation ***
address 0x7fbf6f06b405, cause 'illegal operand'

Traceback:
 1: .Call(R_git_config_list, NULL)
 2: git_config_global()
 3: doTryCatch(return(expr), name, parentenv, handler)
 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 5: tryCatchList(expr, classes, parentenv, handlers)
 6: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
 7: try({    settings <- git_config_global()    name <- subset(settings, name == "user.name")$value    email <- subset(settings, name == "user.email")$value    if (length(name) || length(email)) {        packageStartupInform("Default user: %s <%s>", as_string(name),             as_string(email))    }    else {        packageStartupInform("No default user configured")    }})
 8: fun(libname, pkgname)
 9: doTryCatch(return(expr), name, parentenv, handler)
10: tryCatchOne(expr, names, parentenv, handlers[[1L]])
11: tryCatchList(expr, classes, parentenv, handlers)
12: tryCatch(fun(libname, pkgname), error = identity)
13: runHook(".onAttach", ns, dirname(nspath), nsname)
14: attachNamespace(ns, pos = pos, deps)
15: doTryCatch(return(expr), name, parentenv, handler)
16: tryCatchOne(expr, names, parentenv, handlers[[1L]])
17: tryCatchList(expr, classes, parentenv, handlers)
18: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
19: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)
20: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage"))
21: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE))
22: doTryCatch(return(expr), name, parentenv, handler)
23: tryCatchOne(expr, names, parentenv, handlers[[1L]])
24: tryCatchList(expr, classes, parentenv, handlers)
25: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
26: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE)))
27: tools:::.test_load_package("gert", "/home/viktoriya/R/x86_64-pc-linux-gnu-library/3.4")
An irrecoverable exception occurred. R is aborting now ...
Illegal instruction (core dumped)
ERROR: loading failed
</code>
Please help.
Answer: I'm having the same issue and this fixed it for me. Try
<code>Sys.setenv(USE_SYSTEM_LIBGIT2=1)
install.packages("gert")
</code>
https://github.com/r-lib/gert/issues/117


What can I do about mouse 'lint'?

Question: I play FPS's with a simple optical mouse that has little 'feet' at the base.  I find that the feet regularly pick up 'lint' which changes the movement of the mouse, hence throwing off my aim.  Currently, I have to scratch it off with my fingernails every few rounds, but I would like a solution that would prevent the lint from appearing in the first place.
Are there any simple solutions or is this a very unusual problem?
Answer: Clean the area frequently, and have a clean area to work with.
If you're cleaning your mousing area with a paper towel or a wet wipe, try to make sure you're cleaning with a lint free cloth, or you'll probably just add more stuff to the area.
Comment: On painted/lacquered surfaces, window cleaner instead of plain water works very well, too.
Answer: The gooey part of the lint is mostly dead skin cells so there's not much you can do to avoid it.  Try washing your hands before using the mouse and using a smooth plastic mouse pad instead of a cloth faced one.
Comment: Actually I made the opposite experience: Using a cloth faced mouse pad results in less lint than a plastic or no mouse pad.
Comment: Actually I don't use a mousepad at all
Answer: I used to use an IceMat (frosted glass mouse mat) and it came with some glide tape that you cut up and stuck on your mouse feet. When the lint built up you just peeled it off and stuck another set on.
Looks like ice mat are now Steel Series and they seem to do a range of accessories including the glide stuff. Not a 'free' solution but might be better than scratching the lint off...
Comment: I appreciate the answer, however the scratching off takes ten seconds.  I'm hoping to avoid the build up of lint in the first place.
Comment: Yeah fair enough... what sort of surface do you run your mouse on? Do you use a mouse mat? What type of mouse mat? The glass one I used to use was pretty good for reducing the buildup (as opposed to the cloth/rubber ones), but short of making sure the surface is clean and dust free before you start your gaming session I'm not sure what to suggest :)
Comment: I am playing on a fake wooden desk :-p
Answer: My mouse feet were stickier than normal, so I would apply nail polish remover (or rubbing alcohol) to clean and prolong the collection of lint. And like others have said, I would get a decent mouse pad, since a few bucks will save you constant aggravation of scratching off the mouse feet.

What can I do about mouse 'lint'?


Find $\lim_{n\rightarrow \infty}\frac{(\log n)^a} { n^b}$ when $ a,b >0$.

Question: I need to prove that $(\log n)^a$ will always be smaller than $n^b$ as $n$ get larger (to infinity), also the condition is $a, b > 0$ ($a,b$ are random). I test the graph and it's true but I cant' prove it. I can prove that $\log(n)$ always $< n$, $\log(\sqrt{n}) < \sqrt{n}$ but not the title.
Sorry, I type math on Word but when copying here it didn't work so I plain typing the math function.
Answer: Note that:
\begin{equation} \frac{\log(n)^{a}}{n^{b}}=\left(\frac{\log(n)}{n^{\frac{b}{a}}}\right)^{a} \end{equation}
and consider the function $f(x)=\frac{\log(x)}{x^{\frac{b}{a}}}$ for $x>0$. It follows from L'hopital's rule that
\begin{equation} \lim_{x\to\infty}f(x)=\lim_{x\to\infty}\frac{\frac{1}{x\ln(10)}}{\frac{b}{a}x^{\frac{b}{a}-1}}=\lim_{x\to\infty}\frac{a}{b\ln(10)x^{\frac{b}{a}}}=0 \end{equation}
and because $x\mapsto x^{a}$ is continuous at $x=0$, it then follows that $\lim_{n\to\infty}\frac{\log(n)^{a}}{n^{b}}=0$ as you intuited with what you were trying to prove.
Answer: Since you've established that $\log x < x$ for $x > 0$ you can note that $r \log x = \log x^r < x^r$ for any exponent $r$, and thus
$$\log x < \frac 1r x^r$$ whenever $x$ and $r$ are both positive. If $a > 0$ and $x \ge 1$ you get
$$0 \le (\log x)^a < \frac 1{r^a} x^{ra}$$ and then for any $b$ $$0 \le \frac{(\log x)^a}{x^b} < \frac 1{r^a} x^{ra-b}.$$  Provided that $b > 0$ you can select $r > 0$ small enough that $ra - b < 0$, and then use the squeeze theorem.
Answer: Numerator:
$(\log n) ^a=(\log ((n^{b/a})^{a/b}))^a=$
$((a/b) \log n^{b/a})^a=$
$(a/b)^a (\log n^{b/a}) ^a$
Denominator:
$(n^{b/a})^a$
Putting together:
$(a/b)^a \left (\dfrac {\log n^{b/a}} {n^{b/a}} \right) ^a $
With $k:=(a/b)^a$ and $z:=n^{b/a}$ we have:
$k \left (\dfrac{\log z}{z} \right)^a. $
Take the limit $z \rightarrow \infty. $


How do you build pentagrams?

Question: I have just downloaded the demo of Dungeons and am on the level where you first capture a pentagram and then have to kill heros to get soul power. It then asks me to extend my area of influence by building pentagrams, but I have no idea how.
I cannot find an icon or keyboard shortcut or anything on how to build a pentagram. I hope I dont just have to capture pentagrams because I cannot find any others on the map either...
Anyone know how to do this?
Answer: On the top right corner of your screen you have 5 icons. If I remember correctly, the second one is the pentagram's menu. There you have to chose which pentagrams (which monster) you want.
Hope it helps :)

How do you build pentagrams?


Eclipse shows invalid character or invalid text string or tag not closed properly

Question: Eclipse Neon.3 Release (4.6.3) reports error at this line of code:
<select id="<%=province.id%>" data-placeholder=" " <%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">
</select>

Reported errors are:
Multiple annotations found at this line:
- Start tag (<select>) not closed properly, expected '>'.
- Invalid character used in text string (<%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">).
- Invalid text string (<%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">).

When I remove <%=province.multiple%> from the line, Eclipse stops reporting those errors, but as far as I know, this is valid code. What is wrong with it?
Answer: Should this
<select id="<%=province.id%>" data-placeholder=" " <%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">
be (updated)
<select id="<%=province.id%>" data-placeholder=" " multiple="<%=province.multiple%>" class="chzn-select" style="margin: 1px auto;width:260px;">
Not necessary related in this case but found this also (see details here):

In XHTML, attribute minimization is forbidden, and the multiple
  attribute must be defined as input multiple="multiple"

Then the file suffix might also make Eclipse more critical: if it is .xhtml
 contents propably must be .xhtml.
One good - maybe not directly related - question: What is the difference between creating JSF pages with .jsp or .xhtml or .jsf extension
Comment: Ok, but guess that eclipse complains because it encounters starting  `<` before select tag is closed, maybe an editor bug. Or maybe accidentally inserted hidden char.
Comment: No, `<%=province.multiple%>` echoes `multiple` attribute name or empty string to enable or disable selecting multiple values: https://www.w3schools.com/tags/att_select_multiple.asp


C++: Does the order of using declaration and directive affect the selection?

Question: Below is the sample code
#include <iostream>
using namespace std;

namespace A {
    void f() { cout << "a" << endl; }
}
namespace B {
    void f() { cout << "b" << endl; }
}
namespace C {
    using namespace A;
    using namespace B;
    using A::f;
}
namespace D {
    using A::f;
    using namespace A;
    using namespace B;
}
int main()
{
    C::f();
    D::f();
}

This prints "a" twice when I try in Visual Studio 2015, is this behavior defined by standard or is this implementation specific?
Comment: While this is a perfectly valid language lawyer question, I hope you don't follow this practice in creating real world applications.
Comment: @RSahu too late, I checked-in some code of this sort into some repo
Comment: It's never too late to improve your code :)
Comment: @pasha run... they're loading the shotgun now ... you can still get out of there
Comment: @UKMonkey ....yeah <*nervous laughing*>
Answer: The following two paragraphs from cppreference.com should explain the behavior:

Using-directive [using namespace A;] does not add any names to the declarative region in which it appears (unlike the using-declaration [using A::f;]), and thus does not prevent identical names from being declared.
Using-directives are transitive for the purposes of unqualified lookup: if a scope contains a using-directive that nominates a namespace-name, which itself contains using-directive for some namespace-name-2, the effect is as if the using directives from the second namespace appear within the first. The order in which these transitive namespaces occur does not influence name lookup.

Simply put: using A::f; is as if you declared the function in this namespace. using namespace A; just causes typename lookup to behave as if the current namespace (C or D) in your case were namespaces within A.
This is similar to how
namespace A {
    void f() { cout << "a" << endl; }

    namespace B {
        void f() { cout << "b" << endl; }
    }
}

and
namespace A {
    namespace B {
        void f() { cout << "b" << endl; }
    }

    void f() { cout << "a" << endl; }
}

are equivalent.
Answer: It's defined by the standard (things like this always are). The key thing to realize, is that your various using namespace lines do not have any effect on your program.
using namespace Foo is a "using directive", which affects name lookup which is performed by code within the scope. That is, if some later function in your namespace C {} block tried to find some object named foo, A and B would be among the places that the compiler would search to find a foo. In contrast, it wouldn't change where the compiler would look if later code referred to C::foo. The order of two consecutive using namespaces in a single block is immaterial, since each one has full effect until the end of the block.
The reason you're able to find an f in C or D is the "using declaration" using A::f. A using-declaration, unlike a using-directive, has the effect of injecting a name into a scope, such that other code can refer to the name as being within that scope.
Comment: for anyone checking this answer, please have a look at idmean's answer, it addresses little more on the same topic


Reading and converting an enum type in C

Question: I have defined the following data type:
typedef enum
{
    s=0,
    p=1,
    d=2,
    f=3,
    g=4,
    h=5,
    i=6,
    k=7,
    l=8,
    m=9,
    n=10,
    o=11,
    q=12,
    r=13,
    t=14,
    u=15,
    v=16,
    w=17,
    x=18,
    y=19,
    z=20
} aqn; /* azimuthal quantum number */

I have declared these variables:
aqn l;
int n;
char c;

I have the following data in a file:
2p  ²P°  2.5    2201.333333
2p  ²D   4.5    232287.200000
2p  ²S   0.5    298282.000000
2p  ²P°  2.5    524778.000000
3s  ²S   0.5    1210690.000000
3d  ²D   4.5    1335962.000000
3s  ²P°  2.5    1382990.000000
3p  ²D   4.5    1441942.000000
3p  ²S   0.5    1460910.000000
3s  ²P°  2.5    1486970.000000
3d  ²F°  6.5    1506161.428571
3d  ²P°  2.5    1513486.666667
3p  ²D   2.5    1548850.000000
3p  ²S   0.5    1556590.000000
3d  ²F°  6.5    1597480.000000
3d  ²P°  2.5    1610670.000000
3s  ²D   4.5    1638790.000000
4s  ²S   0.5    1647880.000000
3p  ²F°  6.5    1690802.857143
4d  ²D   4.5    1693830.000000
3d  ²D   2.5    1703280.000000
3d  ²D   2.5    1733900.000000
4p  ²D   4.5    1824376.000000
4d  ²F°  6.5    1847218.571429
5d  ²D   4.5    1858380.000000
6d  ²D   4.5    1946060.000000
4d  ²F°  6.5    1964300.000000
5d  ²F°  6.5    2006054.285714
6d  ²F°  3.5    2092940.000000
5d  ²F°  6.5    2130100.000000

The data is read and parsed.  The first term on each line is stored in a variable called config, which is type char *.
I need to get the numeral into the variable n, which I declared as an int, and the alphabetic character into the variable l, which I declared as an enum type.
I used the following to get n:
sscanf(config,"%d%c",&n,&c);

Now, c is of type char.  Is there a quick and easy way to get it into my enumerated aqn variable l?
Or, is there a quick and easy way to read the config string and assign the value directly to my variable l?
Could some preprocessor #define statements be used?
Or, and I going to need to do a tedious switch and case block?
Bascially, for the first line of my data, I want n=2 and l=p.
For the second line, I want n=2 and l=p.
...
...
For the 30th line, I want n=5 and l=d.
Comment: Aha! So you do have to make a map
Comment: I don't recall any method to convert a string or char to something equivalent to a enum type in C. Enum is used to make the developer life easier, like when working with enumerable sets. If you want to take input from the user, or some file, I believe you'll have to create a correspondence table to do so, and them match
Comment: possible duplicate of [Get enum value by name](http://stackoverflow.com/questions/18070763/get-enum-value-by-name)
Answer: char *table = "spdfghiklmnoqrtuvwxyz";
char *p = strchr(table, c)
if(p!=NULL)
    l= p-table;


subset by at least two out of multiple conditions

Question: I found many questions dealing with subsetting by multiple conditions, but just couldn't find how to subset by at least two out of >2 conditions.
This SO question deals with the same problem, but applies the same condition to all columns:
Select rows with at least two conditions from all conditions
My question is: How can I subset rows by at least two out of three different conditions?
id<-c(1,2,3,4,5)
V1<-c(2,4,4,9,7)
V2<-c(10,20,20,30,20)
V3<-c(0.7,0.1,0.5,0.2,0.9)
df<-data.frame(cbind(id,V1,V2,V3))

I can subset rows that meet all three out of three conditions by looping through like this:
#empty "subset" data.frame
subdf <- cbind(as.character(),as.numeric(),as.numeric(),as.numeric())
colnames(subdf) <- colnames(df)

for (i in 1:nrow(df)){
    if (df$V1[i] <= 4 && df$V2[i] >= 20 && df$V3[i] <= 0.3)
    subdf <- rbind(subdf,df[i,])
    }

Any ideas on how to subset all rows that fulfill either all three, or any combination of two conditions?
Many thanks in advance!
Answer: Here's an extension of LukeA's answer there.
dfNew <- df[rowSums(cbind(df$V1 <= 4, df$V2 >= 20, df$V3 <= 0.3)) > 1,]

which returns
dfNew
  id V1 V2  V3
2  2  4 20 0.1
3  3  4 20 0.5
4  4  9 30 0.2

The idea is to construct a matrix of the logical vectors with cbindand then use rowSums to count the number of TRUE values for each row. The rows of the data.frame can then be subset based on this criterion.
Comment: thanks a lot @lmo, this solution is simple and straightforward!
Answer: I use a trick to do something similar. See if you like it.
The approach is to convert the conditions into text and use eval

id<-c(1,2,3,4,5)
V1<-c(2,4,4,9,7)
V2<-c(10,20,20,30,20)
V3<-c(0.7,0.1,0.5,0.2,0.9)
df<-data.frame(cbind(id,V1,V2,V3))

tests<- c("df$V1 <= 4","df$V2 >= 20" ,"df$V3 <= 0.3")

tests
res<- sapply(tests,FUN = function(txt){eval(parse(text=txt))} )
apply(res,1,sum)
df[apply(res,1,sum) >=2,]

Comment: Thanks! For the record, is there any situation in which you would recommend this solution over the above solution shown by lmo?
Comment: The functions I use are much more complex than gt lt comparisons.


is it possible to play system sound through phone app?

Question: Is there a way to play sound through the iPhone or android phone app. Can I play a sound so the other party can hear a song. Is there API access to the telephone stack.
Comment: Android- you can play the sound over the loudspeakers and hope its picked up.  No way to send it directly to the call.  Also, phone calls use a codec that's optimized for small size and vocals-  it won't transmit music well.
Comment: According to this, the answer is no at least for iOS:

http://stackoverflow.com/questions/7962395/is-it-possible-to-create-a-app-that-makes-phone-calls-and-play-sounds-when-phone/
Comment: Yes I realize it won't be good quality, but at least I wish there was a way to do it
Answer: Android does not allow you to modify the outgoing audio stream during a call. The best you can do is to play whatever you want to over the loudspeaker and hope the microphone picks it up.
Apple doesn't allow you to do anything except initiate calls on iOS, so it isn't possible on that either.
Comment: I can just add that some Android devices' hardware platforms supports playback of audio in the voice call uplink. But since there's no API for in Android there's no way for apps to make use of the functionality. I'm unsure if we'll ever see such an API being added officially, since there are very few use-cases for this functionality if you exclude prank apps (an answering machine app would be the main one, I guess).


Plane vertices from normals and centroid

Question: I am trying to visualize a best fit plane for a set of points which is defined by the normals and the centroid.
I have to find the boundary vertices of the plane given the extent of the plane. Is there any easy algorithm which can help in doing so?
Answer: Find the convex hull and do whatever regression, e.g. linear regression you like.


Set system proxy automatically on connecting to wifi network on ubuntu 18.04 Bionic

Question: How can ubuntu be configured to automatically set the system proxy (for apt, shell commands and for the gui programs) when it connects to a certain wifi?
Use case: Systems broadly fall into three categories
1) Never set the proxy.
2) Set proxy Once and forget about it
3) Change the proxy twice a day, every day, 6 days a week. (laptops that move from work to home)
Use case (3) was slightly irritating before 18.04, but now it's downright unusable because you have to manually edit multiple settings.
What is the most robust and simple way to automate this based on the WiFi SSID?
This implicitly also asks the question of "Is there a simple way of setting the system proxy?"
Answer: The solution I came up with has two parts:
1) A script that is automatically executed when you connect to a network:
Paste this in /etc/NetworkManager/dispatcher.d/ as 05-change_proxy.sh. It should be owned by root and executable.
#!/bin/sh

# Auto Proxy
# Sets the proxy based on the SSID of the wifi network
# place this script in /etc/NetworkManager/dispatcher.d/
# script must be executable and owned by root
# script needs a separate program setproxy to handle setting the proxy

# Parts the user needs to edit have a #EDIT comment next to them

# author:staticd(Sachit) 2018
# this software is released to the public domain

# See man NetworkManager for the parameters passed to a dispatcher script
# $1 is interface that changed; $2 is the specific change that occured; other information is set in the environmental variables of the script

# only run code if the script was called because a new connection was just brought "up"
if [ "$2" != "up" ]; then
    exit
fi

#EDIT SSIDS and the proxy settings
#echo "$CONNECTION_ID" >>/tmp/conlog
case "$CONNECTION_ID" in  # the CONNECTION_ID variable is set by the NetworkManager when it calls the script
    "MyHomeWifi")
        setproxy
        ;;
    "WorkWiFi 1" | "WorkWiFi 2")
        setproxy "proxy.company.com" "3128"
        ;;
    "OtherProxiedWifi")
        setproxy "192.168.0.1" "3128"
        ;;
#    *)                                   # any other connection is made
#        [ "$1" = "wlp3s0" ] && setproxy  # default to no proxy only if the new connection is on the wifi
#        ;;
esac

2) A script setproxy that is to be saved in /usr/local/bin. (also executable and owned by root)
this script can be directly called on the command line as sudo setproxy proxy port to set the proxy
#!/bin/sh

# setproxy
# Sets the proxy settings for
#    /etc/environment
#    /etc/bash.bashrc
#    /etc/apt/apt.conf
#    the gnome proxy settings for all logged in users so running programs are notified of the change

# author:staticd(Sachit) 2018
# this software is released to the public domain

setproxy_help() {
    cat << EOS
Usage: setproxy [server] [port]
Sets the system proxy (apt and environment) and updates the proxy settings of running gui programs
This program must be run as root

With -h or --help prints this message
With no arguments it disables proxying
With two arguments it sets the proxy and port

examples:
  setproxy 192.168.0.1 3128        # sets the proxy
  setproxy proxy.company.com 8080  # sets the proxy
  setproxy                         # disables the proxy
EOS
}

#EDIT this if you don't have the default session manager for example if you have a KDE or LXDE desktop
SESSION_MANAGER=gnome-session-b

unset_proxy() {
    #this function clears the proxy settings
    #delete any lines containing "proxy="
    sed -i "/proxy\=/d" /etc/environment
    #delete old proxy setting lines and unset any outdated environment variables inherited at login time
    sed -i "/proxy\=/d"       /etc/bash.bashrc
    echo "unset http_proxy" >>/etc/bash.bashrc
    echo "unset https_proxy">>/etc/bash.bashrc
    echo "unset ftp_proxy"  >>/etc/bash.bashrc
    echo "unset no_proxy"   >>/etc/bash.bashrc
    #delete any lines containing "Proxy"
    sed -i "/Proxy/d"   /etc/apt/apt.conf
    # ask the already running programs of logged in users to update their settings
    # programs load the get the settings in /etc/environment only when they just start
    for user in $(users | tr ' ' '\n' | sort --unique) ; do
        unset_proxy_logged_in_user "$user"
    done
}

unset_proxy_logged_in_user(){
    USER=$1
    su "$USER" << EOS
    export $(cat /proc/$(pgrep "$SESSION_MANAGER" -u "$USER")/environ|egrep -z '^DBUS_SESSION_BUS_ADDRESS=')
    gsettings set org.gnome.system.proxy mode 'none'
EOS
}

set_proxy() {
    # this function sets the proxy settings for apt and the environment
    # first argument should be server, second is the port
    unset_proxy
    proxy_url='http://'"$1":"$2"
    echo $proxy_url
    # set the default environment
    echo "http_proxy=\"$proxy_url\"" >>/etc/environment
    echo "https_proxy=\"$proxy_url\"">>/etc/environment
    echo "ftp_proxy=\"$proxy_url\""  >>/etc/environment
    echo "no_proxy=localhost,127.0.0.0/8,::1">>/etc/environment
    # set the proxy for all new terminals that are opened. (without this, new terminals that are opened may continue to inherit outdated environment variables from the state of /etc/environment file at login time)
    echo "export http_proxy=\"$proxy_url\"" >>/etc/bash.bashrc
    echo "export https_proxy=\"$proxy_url\"">>/etc/bash.bashrc
    echo "export ftp_proxy=\"$proxy_url\""  >>/etc/bash.bashrc
    echo "export no_proxy=localhost,127.0.0.0/8,::1">>/etc/bash.bashrc
    # set the apt proxy
    echo "Acquire::Http::Proxy \"$proxy_url\";"  >>/etc/apt/apt.conf
    echo "Acquire::Https::Proxy \"$proxy_url\";" >>/etc/apt/apt.conf
    echo "Acquire::Ftp::Proxy \"$proxy_url\";"   >>/etc/apt/apt.conf
    # ask the already running programs of logged in users to update their settings
    # programs load the settings in /etc/environment only when they just start
    for user in $(users | tr ' ' '\n' | sort --unique) ; do
        set_proxy_logged_in_user "$user" $1 $2
    done
}

set_proxy_logged_in_user(){
    USER=$1
    SERVER=$2
    PORT=$3
    su "$USER" << EOS
    export $(cat /proc/$(pgrep "$SESSION_MANAGER" -u "$USER")/environ|egrep -z '^DBUS_SESSION_BUS_ADDRESS=')
    gsettings set org.gnome.system.proxy mode 'manual'
    gsettings set org.gnome.system.proxy.http host $SERVER
    gsettings set org.gnome.system.proxy.http port $PORT
    gsettings set org.gnome.system.proxy.https host $SERVER
    gsettings set org.gnome.system.proxy.https port $PORT
    gsettings set org.gnome.system.proxy.ftp host $SERVER
    gsettings set org.gnome.system.proxy.ftp port $PORT
    gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8' , '::1' ]"
EOS
}

# print help message
if [ $# -eq 1 ] ; then
    case $1 in
    "-h" | "--help" )
        setproxy_help
        exit
        ;;
    *)
        echo "Invalid argument" $1
        echo "call " $(basename $0) "-h for help"
        exit 1
        ;;
    esac
fi

# check if running as root
if ! [ $(id -u) = 0 ]; then
   echo "This script needs to be run as root"
   exit 1
fi

if [ $# -eq 0 ] ; then
    unset_proxy
    exit
fi

if [ $# -eq 2 ] ; then
    set_proxy $1 $2
    exit
fi

# If the execution reached here it was called with too many arguments
echo "too many arguments"
echo "call " $(basename $0) "-h for help"
exit 1


Boot failure dhcp service

Question: Good evening everyone.
My dhcp server stopped working.
I pulled the status and features Failure.
If anyone can help me.
Follows AppendixA error image
Script of service isc-dhcp-server status
<code>root@jhn01:~# service isc-dhcp-server restart
root@jhn01:~# service isc-dhcp-server status
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Qui 2016-01-28 23:58:04 BRST; 6s ago
     Docs: man:dhcpd(8)
  Process: 1252 ExecStart=/bin/sh -ec      CONFIG_FILE=/etc/dhcp/dhcpd.conf;      if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi;      [ -e /var/lib/dhcp/dhcpd.leases ] || touch /var/lib/dhcp/dhcpd.leases;      exec dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACES (code=exited, status=1/FAILURE)
  Process: 1248 ExecStartPre=/bin/chown dhcpd:dhcpd /run/dhcp-server (code=exited, status=0/SUCCESS)
 Main PID: 1252 (code=exited, status=1/FAILURE)

Jan 28 23:58:04 jhn01 sh[1252]: Can't open /var/lib/dhcp/dhcpd.leases for append.
Jan 28 23:58:04 jhn01 sh[1252]: If you think you have received this message due to a bug rather
Jan 28 23:58:04 jhn01 sh[1252]: than a configuration issue please read the section on submitting
Jan 28 23:58:04 jhn01 sh[1252]: bugs on either our web page at www.isc.org or in the README file
Jan 28 23:58:04 jhn01 sh[1252]: before submitting a bug.  These pages explain the proper
Jan 28 23:58:04 jhn01 sh[1252]: process and the information we find helpful for debugging..
Jan 28 23:58:04 jhn01 sh[1252]: exiting.
Jan 28 23:58:04 jhn01 systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, statu...ILURE
Jan 28 23:58:04 jhn01 systemd[1]: isc-dhcp-server.service: Unit entered failed state.
Jan 28 23:58:04 jhn01 systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
</code>
Version S.O :
 Distributor ID:    Ubuntu
Description:    Ubuntu Xenial Xerus (development branch)
Release:    16.04
Codename:   xenial
Comment: It'd be really helpful if you could copy the text in the terminal and paste it into your question instead :).
Answer: It's a bug in isc-dhcp-server/apparmor. See
https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/1543794
for progress and possible workarounds

Boot failure dhcp service


angular2-highcharts drilldown not working

Question: I am using angular2-highcharts in an angular project, and the drilldown is not working.
I have this in my app.module:
import { ChartModule } from 'angular2-highcharts';
import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';
import * as highcharts from 'Highcharts';
import * as drilldown from 'Highcharts/modules/drilldown';
import * as highdata from 'Highcharts/modules/data';

export function highchartsFactory() {
    const hc = highcharts;
    const dd = drilldown;
    const hd = highdata;
    dd(hc);
    hd(hc);

    return hc;
}

imports: [
    BrowserModule,
      HttpModule,
      ChartModule

  ],

providers: [dataService, {provide: HighchartsStatic,
      useFactory: highchartsFactory
  }],

I send data to the chart component by using @Output, with two parameters (series and drilldown) - in app.component:
@Output() currentTestDrilldown=[];
    @Output() currentTestSeries=[];

My chart component is added to app.component like this:
<app-chart-drilldown [data]="currentTestSeries" [drill]="currentTestDrilldown"></app-chart-drilldown>

My example chart-drilldown component:
import {Component, Input, OnChanges, OnInit} from '@angular/core';

@Component({
  selector: 'app-chart-drilldown',
  templateUrl: './chart-drilldown.component.html',
  styleUrls: ['./chart-drilldown.component.css']
})
export class ChartDrilldownComponent implements OnInit, OnChanges {
    @Input() data:any;
    @Input() drill:any;
    chart : any;
    chartOptions: any;
  constructor() { }

    saveInstance(chartInstance) {
        this.chart = chartInstance;
    }

    ngOnChanges(){
        this.drawGraph();
    }

    drawGraph(){
        this.chartOptions = {
            colors: ['#E4EE2B', '#A5D36B', '#67B9AC', '#37A4DD', '#3F8AE2', '#6F6DC8', '#A04FAE', '#D82F90', '#F02E75', '#F4435E', '#F7544C'],
            chart: {
                type: 'column',
                backgroundColor:'transparent',
                animation: {
                    duration: 1000
                }
            },
            plotOptions: {
                series: {
                    groupPadding: 0.05,
                    shadow: {
                        color: 'rgba(0, 0, 0, 0.7)',
                        width: 15
                    },
                    borderColor: 'transparent'
                }
            },
            legend: {
                itemStyle: {
                    color: '#fff',
                },
            },
            title: {
                text: '',
            },
            credits: {
                enabled: false
            },
            xAxis: {
                categories: ['']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            "series": this.data,
            "drilldown": this.drill,
        }
    }

    ngOnInit() {

    }

}

Chart drilldown components HTML:
<chart [options]="chartOptions" style="display:block" type="chart" class="fade-in-chart" (load)="saveInstance($event.context)"></chart>

Thanks for your help!
Answer: Try by using the following code
export function highchartsModules() {
  // apply Highcharts Modules to this array
  return [ drilldown, highdata ];
}

instead.
export function highchartsFactory() {
    const hc = highcharts;
    const dd = drilldown;
    const hd = highdata;
    dd(hc);
    hd(hc);

    return hc;
}

I hope It helps you, and just as recommendation I'm working with the following repository and the drilldown chart works.
Angular-Highcharts


Locking in MongoDB for a Pintrest like website

Question: One of our client projects is a Pinterest like website. It was made with MySQL and CodeIgniter some time back. As they have recently gotten funding and hopefully will get a lot more traffic. We are rebuilding the website and are seriously considering MongoDB as it seems to be one of the more mature NoSQL DB with a big user base.
I know there were some concerns with global locking till version 2.2 post which they were taken care of.
This is my first project with mongodb and NoSQL. I have a question :

Is the write lock still something that I should be worrying about?
Comment: Two recommendations I would add are to first, make sure your data model reflects the shift from a relational db to a document database. See http://docs.mongodb.org/manual/core/data-modeling/#data-modeling-considerations-for-mongodb-applications for some guidance and links to example data models towards the end. Second, I would definitely perform a load test on on the model you choose with as close to real-world data and use cases as possible. I would do this regardless of what database you are considering.
Comment: This is an extremely broad question with that second point, you could write an essay on gotchas for any db in production, let alone MongoDB; however Google is a good friend here searching for "mongodb gotchas" brings up a significant number of informative links. As for locking, it is on database level however, MongoDB does prefer concurrency features over locking, i.e. operations will seceed to other operations when their data is not in RAM etc and operations are designed to hold lock for as little as possible.
Comment: Thanks, got a good reference to gotchas.
Answer: My research in a few other places indicated that it isn't such a bad thing as it initially sounds like.
Video from 10gen talking about the global lock :
http://www.youtube.com/watch?v=PIWVFUtBV1Q ( Skip to 55:00 for the global lock question )
Current version of mongodb : 2.4 -- Global lock removal happened in 2.2
Details: http://blog.serverdensity.com/goodbye-global-lock-mongodb-2-0-vs-2-2/
From watching a couple of other videos on it, the following statements sum up my current understanding of the issue :

"10gen rep : The global lock is something we are very serious about. The server wide lock is gone, now it is a database level lock and in the future we plan to make this to collection level.. "
"If the record you are trying to update is in the RAM, you will not notice the update because its so fast. It sounds really scary but, you shouldn't face too many issues because of this"