text:
Q: Would rather that ... than (to) do I know the right structure is "would rather do something than do something," but when would rather is followed by a clause, what is the correct grammar?
Should there be a "to" before the verb in the following sentence?
I would rather that you wash it yourself than (to) see mom do it for you.

A: I would not use "to".  It is not incorrect, the verb "to see" can be used in this context, but it splices the sentence and from a subjective perspective, makes the sentence rather clunky, especially if "that" is also used.  Examples of everyday use:
I would rather see you wash it yourself than see your mum do it for you.
I would rather that you washed it yourself than see your mum wash it for you.
I'd prefer if you washed it yourself than if you asked your mum to wash it for you.
In order to make the "to" work, break up with a comma splice:
I'd rather that you washed it yourself than see your mum wash it for you.

A:
I would rather you washed it yourself than (you) let your mother do it.
I would rather he washed it himself than (he) let his mother do it.

is a sentence about a hypothetical situation: the reality is you let/he lets your/his mother wash it, and I wish you/he would not act like this.
That is why it contains the auxiliary "will", meaning – here – something like "be happy to see something happening", in the CONDITIONAL SIMPLE, and the verbs "wash" and "let" in the PAST SIMPLE SUBJUNCTIVE, as in Italian!
The past simple in the subjunctive mood cannot be differentiated from the past simple in the indicative mood, except for the verb "to be", which is "were" for all persons: If I were you, etc. ; If he were me, etc.
Your sentence contains an implied if-clause belonging to the second conditional (unreal present) structure:
conditional simple + if + past simple (subjunctive).
So, if I rephrase your sentence,

I would be happier if you/he washed it yourself than (if you/he) let your mother do it.
I would be happier to see you/him washing it yourself/himself than (you/him) letting your mother do it.


text:
Q: How to concatenate "$@" or array to one string I am trying to implement this helper bash function:
ores_simple_push(){(

  set -eo pipefail
  git add .
  git add -A

  args=("$@")

  if [[ ${#args[@]} -lt 1 ]]; then
      args+=('squash-this-commit')
  fi

  git commit -am "'${args[@]}'" || { echo; }
  git push

)}

with: git commit -am 'some stuff here', I really don't like having to enter in quotes, so I am looking to do:
ores_simple_push my git commit message here gets put into a single string

so that would become:
git commit -am 'my git commit message here gets put into a single string'

is there a sane way to do this?

A: In Korn/POSIX-like shells, while "$@" expands to all the positional parameters, separated (in list contexts), "$*" expands to the concatenation of the positional parameters with the first character (byte with some shells) of $IFS¹ or with SPC if $IFS is unset or with nothing if $IFS is set to the empty string.
And in ksh/zsh/bash/yash (the Bourne-like shells with array support), that's the same for "${array[@]}" vs "${array[*]}".
In zsh, "$array" is the same as "${array[*]}" while in ksh/bash, it's the same as "${array[0]}". In yash, that's the same as "${array[@]}".
In zsh, you can join the elements of an array with arbitrary separators with the j parameter expansion flag: "${(j[ ])array}" to join on space for instance. It's not limited to single character/byte strings, you can also do "${(j[ and ])array}" for instance and use the p parameter expansion flag to be able to use escape sequences or variables in the separator specification (like "${(pj[\t])array}" to join on TABs and "${(pj[$var])array}" to join with the contents of $var). See also the F shortcut flag (same as pj[\n]) to join with line-feed.
So here:
ores_simple_push() (
  set -o errexit -o pipefail
  git add .
  git add -A

  args=("$@")

  if [[ ${#args[@]} -lt 1 ]]; then
      args+=('squash-this-commit')
  fi

  IFS=' '
  git commit -am "${args[*]}" || true
  git push
)

Or just POSIXly:
ores_simple_push() (
  set -o errexit
  git add .
  git add -A

  [ "$#" -gt 0 ] || set square-this-commit

  IFS=' '
  git commit -am "$*" || true
  git push
)

With some shells (including bash, ksh93, mksh and bosh but not dash, zsh nor yash), you can also use "${*-square-this-commit}" here.
For completeness, in bash, to join arrays with arbitrary strings (for the equivalent of zsh's joined=${(ps[$sep])array}), you can do:
IFS=
joined="${array[*]/#/$sep}"
joined=${joined#"$sep"}

(that's assuming $sep is  valid text in the locale; if not, there's a chance the second step fails if the contents of $sep ends up forming valid text when concatenated with the rest).

¹ As a historical note, in the Bourne shell, they were joined with SPC regardless of the value of $IFS

A: Actually this seems to work, but I don't know why:
  git commit -am "${args}" || { echo; }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why var_dump of file_get_contents($myFile) return length of my file but empty string? I am stuck on a point that does not allow me to continue in my program.
This point is that my var_dump (file_get_contents ($ myFile)) returns to me string (337) "".
My file is an HTML file. Here is a screenshot of my file :


text:
Q: datatable refreshing while selecting dropdown I am developing JSf project with seam, My version is JSF1.2. I am also using Primefaces for the UI. I am looking for the output for dataTable that uses the list of datas providing by the dropdown id value. It needs to change the dataTable while changing the dropdown value. I am confusing lot with the way JSF1.2, because jsf2 is handling this with the f:ajax.
Can anyone suggest the right way in this to proceed? I am getting the dataTable as empty. Please refer my code below.
My XHTML Page:
                        <h:form class="input-list">
                            <h:selectOneMenu tabindex="1" id="yearId" value="#{transactionListAction.yearId}">
                                <f:selectItems value="#{yearListAction.yearTypeList}" var="year" itemLabel="#{year.year}" itemValue="#{year.yearId}" />
                                <p:ajax event="change" process="@this" partialSubmit="true" update="datatable" listener="#transactionListAction.yearTransactions}" />
                            </h:selectOneMenu>

                            <!-- {RowsPerPageDropdown}-->
                            <p:dataTable id="statementTable" emptyMessage="You dont have Statements in this financial year" value='#{transactionListAction.yearTransactions}' var="transaction" dynamic="false" width="99.9%" loadingMessage="List of Transaction being loaded">

ActionClass:
            @Name("transactionListAction")
            @Stateless
            @AutoCreate
            public class TransactionListActionImpl implements TransactionListAction {

                @In
                protected TransactionService transactionService;

                private Integer yearId;

                private static final long serialVersionUID = 8649412602585430272L;

                public List<Transaction> getTransactionList() {
                    return transactionService.getAllTransactions();
                }

                public List<Transaction> getYearTransactions() {
                    return transactionService.getByYearId(yearId);
                }

                public Integer getYearId() {
                    return yearId;
                }

                public void setYearId(Integer yearId) {
                    this.yearId = yearId;
                }
            }

Error Log:
            16:06:52,625 WARN  [lifecycle] JSF1053: (Listener: org.primefaces.application.PostRestoreViewHandler.afterPhase(), Phase ID: RESTORE_VIEW 1,  View ID: /secure/userhome.xhtml) Exception thrown during phase-listener execution: javax.faces.FacesException: javax.el.ELException: /secure/userhome.xhtml @38,56 value="#{userListAction.usersList}": Error reading 'usersList' on type org.javassist.tmp.java.lang.Object_$$_javassist_seam_29
            16:06:52,625 WARN  [lifecycle] javax.faces.component.UIData.getValue(UIData.java:612)
            javax.faces.component.UIData.getDataModel(UIData.java:1124)
            javax.faces.component.UIData.setRowIndex(UIData.java:451)
            javax.faces.component.UIData.invokeOnComponent(UIData.java:881)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
            javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
            org.primefaces.application.PostRestoreViewHandler.buildPartialView(PostRestoreViewHandler.java:71)
            org.primefaces.application.PostRestoreViewHandler.afterPhase(PostRestoreViewHandler.java:47)
            com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
            com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
            com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
            com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
            javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:374)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
            org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
            org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
            org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
            org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
            org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
            org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
            org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
            org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
            java.lang.Thread.run(Thread.java:662)

            16:06:52,640 ERROR [SeamPhaseListener] swallowing exception
            java.lang.IllegalStateException: No active conversation context
                at org.jboss.seam.pageflow.Pageflow.instance(Pageflow.java:85)
                at org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:38)
                at org.jboss.seam.navigation.Pages.handleOutcome(Pages.java:653)
                at org.jboss.seam.navigation.Page.preRender(Page.java:313)
                at org.jboss.seam.navigation.Pages.preRender(Pages.java:351)
                at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:560)
                at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:471)
                at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:147)
                at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:117)
                at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:374)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                at java.lang.Thread.run(Thread.java:662)

            16:06:52,656 WARN  [Component] Cannot create Seam component, scope is not active: org.jboss.seam.core.conversation(CONVERSATION)
            16:06:52,656 ERROR [viewhandler] Error Rendering View[/secure/userhome.xhtml]
            java.lang.IllegalStateException: No active conversation context
                at org.jboss.seam.core.Conversation.instance(Conversation.java:122)
                at org.jboss.seam.ui.component.UIConversationId.getName(UIConversationId.java:44)
                at org.jboss.seam.ui.util.ViewUrlBuilder.addParameter(ViewUrlBuilder.java:42)
                at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:87)
                at org.jboss.seam.ui.renderkit.LinkRendererBase.doEncodeBegin(LinkRendererBase.java:26)
                at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
                at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
                at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
                at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:374)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                at java.lang.Thread.run(Thread.java:662)
            16:06:52,671 ERROR [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /secure/userhome.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@f1667e]
            16:06:52,671 WARN  [SeamPhaseListener] uncaught exception, passing to exception handler
            java.lang.IllegalStateException: No active conversation context
                at org.jboss.seam.core.Conversation.instance(Conversation.java:122)
                at org.jboss.seam.faces.FacesManager.prepareBackswitch(FacesManager.java:260)
                at org.jboss.seam.jsf.SeamPhaseListener.afterRenderResponse(SeamPhaseListener.java:503)
                at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:248)
                at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)
                at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:374)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                at java.lang.Thread.run(Thread.java:662)
            16:06:52,671 ERROR [SeamPhaseListener] swallowing exception
            java.lang.IllegalStateException: No active conversation context
                at org.jboss.seam.core.Conversation.instance(Conversation.java:122)
                at org.jboss.seam.faces.FacesManager.prepareBackswitch(FacesManager.java:260)
                at org.jboss.seam.jsf.SeamPhaseListener.afterRenderResponse(SeamPhaseListener.java:503)
                at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:248)
                at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:195)
                at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:374)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                at java.lang.Thread.run(Thread.java:662)

A: You can handle it with ajax in jsf 1.2 also with p:ajax provided by primefaces.
First of all remove onChange="document.datsForm.submit()" from h:selectOneMenu and add
as child component of your select menu.
   <p:ajax event="change" process="@this" partialSubit="true" update="datatable"
           listener="#transactionListAction.onYearChange}"/>

You haven't given any id to the form contaning datatable which is not a good practice. Give id to the form and refer datatable as :formId:datatable. Above update="datatable" only works in case if your dropdown and datatable are inside the same form.
Declare method in your action class like
         public void onYearChange()   {
            transActionsList = transactionService.getByYearId(yearId);
         }

declare a variable List<Transaction> transActionsList in your class and bind it to the value of the datatable. You should not perform any action in getter method because jsf framework calls getters and setters multiple times which results in multiple hits to the db.
Hope this helps.


text:
Q: Testing Node Application with mocha I have the following test application based on a template provided by openshift.
server.js:
var express = require('express');

exports.NodeTestApp = function () {
    self.cache_get = function (key) {
            return 'Would be a value here';
    };
}

server_test.js:
var server = require('../server');

describe('Server', function(){
    describe('Startup',function(){
        it('sets up routes during startup',function(){
            var app = server.NodeTestApp();
            app.cache_get('/');

            expect(app.routes.size).to.equals(5);
        })
    })
})

When I run this test I get an error message that cache_get is not defined.
TypeError: Cannot read property 'cache_get' of undefined
    at Context.<anonymous> (test/server_test.js:7:16)
I would have thought that everything that is specified in the NodeTestApp function is available via variable app. IntelliJ even shows me the function as a valid call. Any idea why I get this error ?
Thanks in advance.
Oliver

A: I figured out the problem with above code. To instantiate the app variable the new keyword has to be used. I didn't think that this is required as I would have thought its purely a function call and not a constructor call, which requires the new keyword. Below is the working code for your reference.
var app = new server.NodeTestApp();


text:
Q: Finding the smith number between given range I will get to the point quickly. Basically smith numbers are: Composite number the sum of whose digits is the sum of the digits of its prime factors (excluding 1). (The primes are excluded since they trivially satisfy this condition). One example of a Smith number is the beast number 666=2·3·3·37, since 6+6+6=2+3+3+(3+7)=18.
what i've tried:

*

*In a for loop first i get the sum of the current number's(i) digits

*In same loop i try to get the sum of the number's prime factors digits.

*I've made another method to check if current number that is going to proccessed in for loop is prime or not,if its prime it will be excluded

But my code is seems to not working can you guys help out?
    public static void main(String[] args) {
        smithInrange(1, 50);
    }

    public static void smithInrange(int start_val, int end_val) {

        for (int i = start_val; i < end_val; i++) {
            if(!isPrime(i)) { //since we banned prime numbers from this process i don't include them
            int for_digit_sum = i, digit = 0, digit_sum = 0, for_factor_purpose = i, smith_sum = 0;
            int first = 0, second = 0, last = 0;
            // System.out.println("current number is" + i);
            while (for_digit_sum > 0) { // in this while loop i get the sum of current number's digits

                digit = for_digit_sum % 10;
                digit_sum += digit;
                for_digit_sum /= 10;
            }
            // System.out.println("digit sum is"+digit_sum);

            while (for_factor_purpose % 2 == 0) { // i divide the current number to 2 until it became an odd number
                first += 2;
                for_factor_purpose /= 2;
            }
            // System.out.println("the first sum is " + first);
            for (int j = 3; j < Math.sqrt(for_factor_purpose); j += 2) {
                while (for_factor_purpose % j == 0) { // this while loop is for getting the digit sum of every prime
                                                        // factor that j has
                    int inner_digit = 0, inner_temp = j, inner_digit_sum = 0;
                    while (inner_temp > 0) {
                        inner_digit = inner_temp % 10;
                        second += inner_digit;
                        inner_temp /= 10;
                    }
                    // System.out.println("the second sum is " + second);
                    for_factor_purpose /= j;
                }
            }
            int last_temp = for_factor_purpose, last_digit = 0, last_digit_sum = 0;
            if (for_factor_purpose > 2) {
                while (last_temp > 0) {
                    last_digit = last_temp % 10;
                    last += last_digit;
                    last_temp /= 10;
                }
                // System.out.println("last is " + last);

            }
            smith_sum = first + second + last;
            // System.out.println("smith num is "+ smith_sum);
            // System.out.println(smith_sum);
            if (smith_sum == digit_sum) {
                System.out.println("the num founded is" + i);
            }
        }
        }
    }

    public static boolean isPrime(int i) {
        int sqrt = (int) Math.sqrt(i) + 1;
        for (int k = 2; k < sqrt; k++) {
            if (i % k == 0) {
                // number is perfectly divisible - no prime
                return false;
            }
        }
        return true;
    }

the output is:
the num founded is4
the num founded is9
the num founded is22
the num founded is25
the num founded is27
the num founded is49
how ever the smith number between this range(1 and 50) are:
4, 22 and 27
edit:I_ve found the problem which is :
Math.sqrt(for_factor_purpose) it seems i should add 1 to it to eliminate square numbers. Thanks to you guys i've see sthe solution on other perspectives.
Keep coding!

A: Main loop for printing Smith numbers.
      for (int i = 3; i < 10000; i++) {
         if (isSmith(i)) {
            System.out.println(i + " is a Smith number.");
         }
      }

The test method to determine if the supplied number is a Smith number.  The list of primes is only increased if the last prime is smaller in magnitude than the number under test.

   static boolean isSmith(int v) {
      int sum = 0;
      int save = v;

      int lastPrime = primes.get(primes.size() - 1);
      if (lastPrime < v) {
         genPrimes(v);
      }
      outer:
      for (int p : primes) {
         while (save > 1) {
            if (save % p != 0) {
               continue outer;
            }
            sum += sumOfDigits(p);
            save /= p;
         }
         break;
      }
      return sum == sumOfDigits(v) && !primes.contains(v);
   }

Helper method to sum the digits of a number.
   static int sumOfDigits(int i) {
      return String.valueOf(i).chars().map(c -> c - '0').sum();
   }

And the prime generator.  It uses the list as it is created to determine if a given
number is a prime.

   static List<Integer> primes = new ArrayList<>(List.of(2, 3));
   static void genPrimes(int max) {
      int next = primes.get(primes.size() - 1);
      outer:
      while (next <= max) {
         next += 2;
         for (int p : primes) {
            if (next % p == 0) {
               continue outer;
            }
            if (p * p > next) {
               break;
            }
         }
         primes.add(next);
      }
   }
}

A: I do not want to spoil the answer finding, but just some simpler code snippets,
making everything simpler, and more readable.
public boolean isSmith(int a) {
    if (a < 2) return false;
    int factor = findDivisor(a);
    if (factor == a) return false;

    int sum = digitSum(a);
    // loop:
        a /= factor;
        sum -= digitSum(factor);
    ...
}

boolean isPrime(int a){
    for(int i = 2; i*i <= a; i++) {
        if (a % i == 0) {
            return false;
        }
    }
    return true;
}

int findDivisor(int a){
    for(int i = 2; i*i <= a; i++) {
        if (a % i == 0) {
            return i;
        }
    }
    return a;
}

int digitSum(int a) {
   if (a < 10) {
       return a;
   }
   int digit = a % 10;
   int rest = a / 10;
   return digit + digitSum(rest);
}

As you see integer division 23 / 10 == 2, and modulo (remainder) %: 23 % 10 == 3 can simplify things.
Instead of isPrime, finding factor(s) is more logical. In fact the best solution is not using findDivisor, but immediately find all factors
    int factorsSum = 0;
    int factorsCount = 0;
    for(int i = 2; i*i <= a; i++) {
        while (a % i == 0) {
            factorsSum += digitSum(i);
            a /= i;
            factorsCount++;
        }
    }

    // The remaining factor >= sqrt(original a) must be a prime.
    // (It cannot contain smaller factors.)
    factorsSum += digitSum(a);
    factorsCount++;

A: Here is the code. If you need further help, please let me know. The code is pretty self explanatory and a decent bit was taken from your code but if you need me to explain it let me know.
In short, I created methods to check if a number is a smith number and then checked each int in the range.
import java.util.*;
public class MyClass {
    public static void main(String args[]) {
         System.out.println(smithInRange)
    }
    public int factor;
    public boolean smithInRange(int a, int b){
        for (int i=Math.min(a,b);i<=Math.max(a,b);i++) if(isSmith(i)) return true;
        return false;
    }
    public boolean isSmith(int a){
        if(a<2) return false;
        if(isPrime(a)) return false;
        int digits=0;
        int factors=0;
        String x=a+¨" ";
        for(int i=0;i<x.length()-1;i++) digits+= Integer.parseInt(x.substring(i,i+1));
        ArrayList<Integer> pF = new ArrayList<Integer>();
        pF.add(a);
        while(!aIsPrime(pF)){
            int num = pF.get(pF.size-1)
            pF.remove(pF.size()-1);
            pF.add(factor);
            pF.add(num/factor)
        }
        for(int i: pF){
            if((factors+"").length()==1)factors+= i;
            else{
                String ss= i+" ";
                int nums=0;
                for(int j=0;j<ss.length()-1;j++){
                    nums+=Integer.parseInt(ss.substring(j,j+1));
                }
            }
        }
        return (factors==digits);
    }
    public boolean isPrime(int a){
        for(int i=2;i<=(int)Math.sqrt(a),i++){
            String s = (double)a/(double)i+"";
            if(s.substring(s.length()-2).equals(".0")){
                return false;
                factor = i;
            }
        }
        return true;
    }
    public boolean aIsPrime(ArrayList<int> a){
        for(int i: a) if (!isPrime(a)) return false;
        return true;
    }
}


text:
Q: Recursion - mystery1 Having a tough time with the below code, I have answered the first call correctly as the condition is immediately correct. However, the second call of 4 is causing me great confusion, I came to the answer 2, 1 however it is incorrect- I am clearly getting things mixed up. Can someone explain to me exactly why my answer is wrong and the correct breakdown of the process of Recursive tracing in this example. I do understand elements of recursion however I am having issues following the process of tracing.
public void mystery1(int n) {
    if (n <= 1) {
        System.out.print(n);
    } else {
        mystery1(n / 2);
        System.out.print(", " + n);
    }
}

mystery1(1);
mystery1(4);
mystery1(16);

A: When you call mystery1(4), it goes to the else part and calls mystery1(2) since n>1. The print statement will be executed only after mystery1(2) has finished executing.
The same thing happens for mystery1(2) and it calls mystery1(1). It waits for mystery(1) to finish execution.
When mystery1(1) is called, it prints "1".
Then, mystery1(2) will continue and print ",2".
Finally, mystery1(4) will continue and print ",4".
So your output will be 1,2,4

A: Recursion is beautiful yet very powerful and when it comes to observe it, people get tricked.
Let me explain you how i learnt it when i was preparing for my GATE(Graduate Aptitude Test in Engineering).
Think of each Function call as 2 parts:

*

*Printing

*Calling with halving itself

Now all the operations will be stacked upon the older one until unless we are out of recursion and only Printing is left in the function cycle.
We will print out in stack format i.e FIFO
Example, if we have these elements in stack:
Top:
4
3
7
2
Bottom
It will print 4 3 7 2 .
Now taking your Question:
Lets break your Conditional statements in two halves, 1st will be if condition with Print 2nd will be else with its print.
Note: Only one part i.e 1st will print 1 and that too without commas (,).
I have attached the Image below kindly refer it, think as print statement as on stack, and the lowest print statement will be executed first as we will end out of function calls.

Now combining  mystery1(1),mystery1(4),mystery1(16) the final output will be: 1
1
, 2
, 4
1
, 2
, 4
, 8
, 16
PS: If you are going to give interviews of Amazon , Google or any Reputed Product based company they will ask question with flavor of recursion and that too without using any compiler, they wanna test your concepts via programming.

A: In your method:
public static void mystery1(int n) {
    if (n <= 1) {
        System.out.print(n);
    } else {
        mystery1(n / 2);
        System.out.print(", " + n);
    }
}

try to replace the position of System.out.print(", " + n); before mystery1(n / 2); call.
In the first case, when System.out after mystery1 call, you have result as 1, 2, 4, because, first you have to get result, then print it.
In the second case, when System.out before mystery1 call, you have result as , 4, 21, because, first you print the result, then calculate the next result in function.


text:
Q: What is the geometric interpretation of the following basic result of Euclidean inner product? My linear algebra textbook has this as a theorem:
$u\cdot v = \frac{1}{4}\|u+v\|^2 - \frac{1}{4}\|{u-v}\|^2$
for vectors $u$ and $v.$ All I can see is that the diagonal length of parallelogram made up with $u$ and $v$ is longer than the length of other diagonal when the angle created by $u$ and $v$ is acute. The similar argument goes in case it is obtuse. Is there any other significant geometric interpretation?

A: Suppose that $\|u\|=\|v\|=1$. Then the length of each diagonal of the parallelogram that you mentioned lies between $0$ and $2$. So, if you compute the square of the length of the diagonal made up with $u$ and $v$ and then you subtract from it the square of the length of the other diagonal, you get a number between $-4$ and $4$. The equality from your question means that if you divide this number by $4$ (thereby getting a number in $[-1,1]$), then what you get is the cosine of the angle between $u$ and $v$.


text:
Q: How to design a user reputation table I am busy scoping out an application and one of the requirement is user feedback for services rendered.
I was thinking of creating a reputation system for this: using up votes and down votes for a given service.
Having never created something like this, I am looking for help with the database design:
User Story:
Service provider provides a painting service to Customer. On completion of the work, each has an opportunity to rate each other. The rating will contribute towards further work for the service provider as well as further workers for the client.
Table structure:
User:
{
    "User Id": 1,
    "Name": "Service Provider"
  },{
    "User Id": 2,
    "Name": "Customer"
  },

Reputation:
{
    "Reputation Id": 1,
    "user_rating":1,  //i.e. doing the rating
    "user_rated":2,   //i.e. being rated
    "Rating": 1,
    "Service Identity": 123
    "Comment": "Nice customer to work for..."
  },
{
    "Reputation Id": 2,
    "user_rating":2,
    "user_rated":1,
    "Rating": 1,
    "Service Identity": 123
    "Comment": "Great Service Received..."
  },

Service
  {
        "Service Id": 123,
        "Description": "Paint the house..."
      },

How could this be made more extensive or more useful?
Is the design too simple or should it be more extensive?
I don't want people abusing the system, perhaps a specific reputation is required before a user can vote or leave comments etc.
Any ideas or thoughts would be appreciated!


text:
Q: Is it possible to launch a file's default editor from a batch file? Background:
We can use a combination of PATHEXT and the Windows file associations to do the Command Prompt equivalent of right-clicking a file in Explorer and clicking Open, e.g.:
C:\code\python> echo print "Hello, StackOverflow!" >hello.py

C:\code\python> hello
Hello, StackOverflow!

Similarly, I could use this to launch Photoshop by typing:
C:\art\source> StackOverflowLogo.PDF

The Actual Problem:
I need the command prompt equivalent of right-clicking the file in Explorer and selecting Edit instead.
With my hello(.py) above, that would likely bring up Python's Idle editor.  However, I need a universal solution that uses the OS-level association for the file type.  I can't assume it.
The simplest possible example of what I'd like to do would be this hypothetical EDIT.BAT file, which would do nothing but launch the editor for the given filename:
@InsertMagic /Here %1

Thanks!  (I hope.)

Aaand... the solution:
Alex K. suggests Powershell, which is of course a great solution.  So to write my EDIT.BAT above, I could do this:
@powershell -command "start -verb edit '%1'"

(That's slightly naïve, since there are potential quoting issues, but you get the idea.)
Cheers for the speedy answer.  :)

A: Those items on the right-click menu are called Shell Verbs, they can be invoked by name for a target file but not with any direct batch or windows command.
Win7/2k8r2 upwards you can use PowerShell to do it from your batch file:
powershell -command "start -verb edit 'C:\art\source\StackOverflowLogo.PDF'"


text:
Q: swaping and rotate 2D arrays I need to implement two methods that work with 2D arrays:

*

*grayAndFlipLeftToRight - This method converts the image into a 2D array of gray scale values and then flips it left to right. That is, an object that was facing left will now be facing right. The elements on the left most column will be swapped with those in the right-most column and so on.

*grayAndRotate90 - This method converts the image into a 2D array of gray scale values and then rotates it 90 degrees clockwise (lays it on its right side).
Code:
public class PictureUtil
{
    /**
     * Gets a version of the given Picture in gray scale and flipped left to right
     * @param pic the Picture to convert to gray scale and flip
     * @return a version of the original Picture in gray scale and flipped
     * left to right.
     */
    public static Picture grayAndFlipLeftToRight( Picture pic)
    {
        int[][] pixels = pic.getGrayLevels();

        for (int i = 0; i < pixels.length; i++) {
            for (int fromStart = 0; fromStart < pixels[0].length; fromStart++) {
                int fromEnd = pixels[0].length-1;

                while (fromEnd >= 0) {
                    int saved = pixels[i][fromStart];
                    pixels[i][fromStart] = pixels[i][fromEnd];
                    pixels[i][fromEnd] = saved;

                    fromEnd--;
                }
            }
        }

        return new Picture(pixels);
    }

    /**
     * Gets a version of the given Picture in gray scale and rotated 90 degrees clockwise
     * @param pic the Picture to convert to gray scale and rotate 90 degrees clockwise
     * @return a version of the original Picture in gray scale and rotated 90 degrees clockwise
     */
    public static Picture grayAndRotate90( Picture pic)
    {
        int[][] pixels = pic.getGrayLevels();

        int numberOfColums = pixels.length;
        int numberOfRows = pixels[0].length;
        int[][] rotate = new int[numberOfRows][numberOfColums];

        for (int i = 0; i < pixels.length; i++) {
            int seek = 0;
            for (int j = 0; j < pixels[0].length; j++) {
                pixels[i][j] = rotate[seek][numberOfColums - 1];
                seek++;
            }
        }

        return new Picture(rotate);
    }
}

My implementation doesn't work correctly for both methods.

*

*How to solve this issue?

A: I think you messed up with the looping a bit. This should get your work done:
public static Picture grayAndFlipLeftToRight( Picture pic)
{
    int[][] pixels = pic.getGrayLevels();

    for (int i = 0; i < pixels.length; i++) {
        for (int curr = 0; curr < (pixels[0].length + 1) / 2; curr++) {

            int saved = pixels[i][curr];
            pixels[i][curr] = pixels[i][pixels[0].length - 1 - curr];
            pixels[i][pixels[0].length - 1 - curr] = saved;
        }
    }

    return new Picture(pixels);
}

public static Picture grayAndRotate90( Picture pic)
{
    int[][] pixels = pic.getGrayLevels();

    int[][] rotate = new int[pixels[0].length][pixels.length];

    for (int i = 0; i < pixels[0].length; i++) {
        for (int j = 0; j < pixels.length; j++) {
            rotate[i][pixels.length - 1 - j] = pixels[j][i];
        }
    }
    return new Picture(rotate);
}

A blunder in your code is the line(in rotate method) :
pixels[i][j] = rotate[seek][numberOfColums - 1];

You were modifying contents of the input array itself and doing nothing with rotate, the output.

A: Interestingly, if you want to rotate counter-clockwise 90 the code looks like this:
public static Picture grayAndRotate90CC( Picture pic)
{
    int[][] pixels = pic.getGrayLevels();

    int[][] rotateCC = new int[pixels[0].length][pixels.length];

    for (int i = 0; i < pixels[0].length; i++) {
        for (int j = 0; j < pixels.length; j++) {
            rotateCC[i][j] = pixels[j][i];  //rotates 90 counter-clockwise!
        }
    }
    return new Picture(rotateCC);
}


text:
Q: Epson ESCPOS thermal print with special Danish character I am using python-escpos version 2.2.0 for printing text on my Epson TM-T88V thermal receipt printer. My printer is configured:

*

*Using international character set called "DENMARK II"

*Using code page WPC1252
I have troubles in printing the extended Danish character æ, ø and å. I have verfied that they exists in WPC1252. Below is my code python code
from escpos import printer

printer_ipAddress = "192.168.0.200"
p = printer.Network(printer_ipAddress)
p.set(align = 'LEFT', width = 2, height = 2)
text = 'æ,ø,å'
p.text(text)
p.cut()

When I execute above code I get some strange looking character output instead of the Danish character æ, ø and å.

A: As suggested by @kunif the codepage was set inconsistently. I added
p.codepage = 'CP858'

before the p.set command and the issue was solved.


text:
Q: C# HashSet read-only workaround Here is this sample code:
static class Store
{
    private static List<String> strList = new List<string>();
    private static HashSet<String> strHashSet = new HashSet<string>();

    public static List<String> NormalList
    {
        get { return strList; }
    }

    public static HashSet<String> NormalHashSet
    {
        get { return strHashSet; }
    }

    public static IReadOnlyList<String> ReadonlyList
    {
        get { return (IReadOnlyList<String>)strList; }
    }

    public static IReadOnlyCollection<String> ReadonlyHashSet
    {
        get { return (IReadOnlyCollection<String>)strHashSet; }
    }

    public static IReadOnlyList<String> Real_ReadonlyList
    {
        get { return (IReadOnlyList<String>)strList.AsReadOnly(); }
    }

    public static IReadOnlyCollection<String> Real_ReadonlyHashSet
    {
        get
        {
            List<String> tmpList = new List<String>(strHashSet);
            return (IReadOnlyList<String>)(tmpList).AsReadOnly();
        }
    }
}

And here is a test code:
// normal behaviour
// you can modify the list and the hashset

Store.NormalList.Add("some string 1");

Store.NormalHashSet.Add("some string 1");

// tricky behaviour
// you can still modify the list and the hashset

((List<String>)Store.ReadonlyList).Add("some string 2");

((HashSet<String>)Store.ReadonlyHashSet).Add("some string 2");

// expected read-only behaviour
// you can NOT modify

// throws InvalidCastException
((List<String>)Store.Real_ReadonlyList).Add("some string 3");
// throws InvalidCastException
((HashSet<String>)Store.Real_ReadonlyHashSet).Add("some string 3");

My questions are these:
Is there a better solution for the "Real_ReadonlyHashSet" property?
Will Microsoft some day implement the "AsReadOnly" method to the HashSet<T>?

A: Starting from .NET 5, the HashSet<T> class now implements the IReadOnlySet<T> interface. There is no built-in ReadOnlySet<T> wrapper though, analogous to the existing ReadOnlyDictionary<TKey, TValue> class for dictionaries, but implementing one is trivial:
public class ReadOnlySet<T> : IReadOnlySet<T>
{
    private readonly ISet<T> _set;
    public ReadOnlySet(ISet<T> set) { ArgumentNullException.ThrowIfNull(set); _set = set; }

    public int Count => _set.Count;
    public bool Contains(T item) => _set.Contains(item);
    public bool IsProperSubsetOf(IEnumerable<T> other) => _set.IsProperSubsetOf(other);
    public bool IsProperSupersetOf(IEnumerable<T> other) => _set.IsProperSupersetOf(other);
    public bool IsSubsetOf(IEnumerable<T> other) => _set.IsSubsetOf(other);
    public bool IsSupersetOf(IEnumerable<T> other) => _set.IsSupersetOf(other);
    public bool Overlaps(IEnumerable<T> other) => _set.Overlaps(other);
    public bool SetEquals(IEnumerable<T> other) => _set.SetEquals(other);
    public IEnumerator<T> GetEnumerator() => _set.GetEnumerator();
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

The upcoming .NET 7 will also feature a new AsReadOnly extension method for IDictionary<TKey,TValue>s, so let's make one for ISet<T>s too:
public static ReadOnlySet<T> AsReadOnly<T>(this ISet<T> set) => new ReadOnlySet<T>(set);

Usage example:
HashSet<Item> items = new();
ReadOnlySet<Item> readOnlyItems = items.AsReadOnly();

A: Here is the entirety of the code of .AsReadOnly()
public ReadOnlyCollection<T> AsReadOnly() {
    Contract.Ensures(Contract.Result<ReadOnlyCollection<T>>() != null);
    return new ReadOnlyCollection<T>(this);
}

The first line is not even necessary if you are not using CodeContracts. However, ReadOnlyCollection<T> only supports IList<T> which HashSet<T> does not support.
What I would do is make your own ReadOnlySet<T> class that takes in a ISet<T> and only passes through the read operations like ReadOnlyCollection<T> does internally.
UPDATE:
Here is a fully fleshed out ReadOnlySet<T> I quickly wrote up along with a extension method that adds a .AsReadOnly() on to anything that implements ISet<T>
public static class SetExtensionMethods
{
    public static ReadOnlySet<T> AsReadOnly<T>(this ISet<T> set)
    {
        return new ReadOnlySet<T>(set);
    }
}

public class ReadOnlySet<T> : IReadOnlyCollection<T>, ISet<T>
{
    private readonly ISet<T> _set;
    public ReadOnlySet(ISet<T> set)
    {
        _set = set;
    }

    public IEnumerator<T> GetEnumerator()
    {
        return _set.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return ((IEnumerable) _set).GetEnumerator();
    }

    void ICollection<T>.Add(T item)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public void UnionWith(IEnumerable<T> other)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public void IntersectWith(IEnumerable<T> other)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public void ExceptWith(IEnumerable<T> other)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public void SymmetricExceptWith(IEnumerable<T> other)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public bool IsSubsetOf(IEnumerable<T> other)
    {
        return _set.IsSubsetOf(other);
    }

    public bool IsSupersetOf(IEnumerable<T> other)
    {
        return _set.IsSupersetOf(other);
    }

    public bool IsProperSupersetOf(IEnumerable<T> other)
    {
        return _set.IsProperSupersetOf(other);
    }

    public bool IsProperSubsetOf(IEnumerable<T> other)
    {
        return _set.IsProperSubsetOf(other);
    }

    public bool Overlaps(IEnumerable<T> other)
    {
        return _set.Overlaps(other);
    }

    public bool SetEquals(IEnumerable<T> other)
    {
        return _set.SetEquals(other);
    }

    public bool Add(T item)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public void Clear()
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public bool Contains(T item)
    {
        return _set.Contains(item);
    }

    public void CopyTo(T[] array, int arrayIndex)
    {
        _set.CopyTo(array, arrayIndex);
    }

    public bool Remove(T item)
    {
        throw new NotSupportedException("Set is a read only set.");
    }

    public int Count
    {
        get { return _set.Count; }
    }

    public bool IsReadOnly
    {
        get { return true; }
    }
}

A: You could write your own implementation of an IReadOnlyCollection<T> that wraps an IEnumerable<T> and a count:
public sealed class ReadOnlyCollectionFromEnumerable<T>: IReadOnlyCollection<T>
{
    readonly IEnumerable<T> _data;

    public ReadOnlyCollectionFromEnumerable(IEnumerable<T> data, int count)
    {
        _data = data;
        Count = count;
    }

    public IEnumerator<T> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }

    public int Count { get; }
}

Then you declare your ReadonlyHashSet property like this:
public static IReadOnlyCollection<String> ReadonlyHashSet
{
    get { return new ReadOnlyCollectionFromEnumerable<string>(strHashSet, strHashSet.Count); }
}

I think that would solve the issue.

A:
HashSet implements the IReadOnlyCollection interface starting
  with the .NET Framework 4.6; in previous versions of the .NET
  Framework, the HashSet class did not implement this interface.

Read in learn.microsoft.com

A: In .NET Framework 4.6 release, the HashSet implements IReadOnlyCollection interface along with the ISet interface.   link...
It does seem to.
You could also do this but maybe take a performance hit:
var foo = (IReadOnlyCollection<string>) mySet.toList();


text:
Q: Can you use Jquery to simulate the click-event on an item in a select list? Currently I have written a jQuery statement which "highlights" a specific item in a drop down.
$('#mylist>option:eq(2)').prop('selected', true);

The above will highlight the second item and have it appear at the top of the list.
There's still a problem though, because subsequent code that I have written is behaving as though no option was chosen from the list.
Is there a way, using jQuery, to simulate the actual "clicking" on an item in a select list?

A: After the line you have above, you should try $('#myList').trigger('click'); I don't know if that will fix your problem, but that triggers a click event on this element.

A: As directly from the jQuery docs you can simulate as follows:
$( "#target" ).click();

See: http://api.jquery.com/click/


text:
Q: why processTicksAndRejections() task_queues.js#L67 spending significant time on cpu One of my nodejs application performing heavy load work at a given time where more than 4/5 requests being processed by nodejs . Each of these requests contain, http & DB exit calls which are performing well in ms. However, if I check the flame graph https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/lib/internal/process/task_queues.js#L67 , this specific code from a node is utilizing 70% of CPU time.
I am wondering if I can insight into these internal functions of node and understand the technicality of these methods in order to understand the current bottleneck.

1)https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/lib/internal/process/task_queues.js#L67
2)https://github.com/nodejs/node/blob/5fad0b93667ffc6e4def52996b9529ac99b26319/lib/internal/process/promises.js#L220


text:
Q: LiveCode Repeat I am trying to use repeat to display the "Species" node of each of the "XmlNode"s. However, I keep getting an error. I am a new to LiveCode and have tried everything I can think of.
XML CODE:
<ArrayOfXmlNode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.petango.com/">
  <XmlNode>
    <adoptableSearch xmlns="">
      <ID>12063964</ID>
      <Name>152217</Name>
      <Species>Dog</Species>
      <Sex>Male</Sex>
      <PrimaryBreed>Doberman Pinscher</PrimaryBreed>
      <SecondaryBreed>Mix</SecondaryBreed>
      <SN>Neutered</SN>
      <Age>70</Age>
      <Photo>
        http://www.petango.com/sms/photos/119/6cd81b69-357c-4272-b064-    d3fb3038985e_TN1.jpg
      </Photo>
      <Location>Adoption</Location>
      <OnHold>No</OnHold>
      <SpecialNeeds></SpecialNeeds>
      <NoDogs></NoDogs>
      <NoCats></NoCats>
      <NoKids></NoKids>
      <BehaviorResult></BehaviorResult>
      <MemoList/>
      <ARN></ARN>
      <BehaviorTestList></BehaviorTestList>
      <Stage>Available</Stage>
      <AnimalType>Dog</AnimalType>
      <AgeGroup>Adult</AgeGroup>
      <WildlifeIntakeInjury></WildlifeIntakeInjury>
      <WildlifeIntakeCause></WildlifeIntakeCause>
      <BuddyID>0</BuddyID>
      <Featured>No</Featured>
      <Sublocation>K27</Sublocation>
      <ChipNumber>0A12047D2B</ChipNumber>
    </adoptableSearch>
  </XmlNode>
  <XmlNode>
    <adoptableSearch xmlns="">
      <ID>13423810</ID>
      <Name>145957</Name>
      <Species>Dog</Species>
      <Sex>Male</Sex>
      <PrimaryBreed>Chihuahua, Short Coat</PrimaryBreed>
      <SecondaryBreed>Mix</SecondaryBreed>
      <SN>Neutered</SN>
      <Age>99</Age>
      <Photo>
        http://www.petango.com/sms/photos/119/5839bd2b-f15e-4e40-b5e1-9a20331de212_TN1.jpg
      </Photo>
      <Location>Stray Room</Location>
      <OnHold>No</OnHold>
      <SpecialNeeds></SpecialNeeds>
      <NoDogs></NoDogs>
      <NoCats></NoCats>
      <NoKids></NoKids>
      <BehaviorResult></BehaviorResult>
      <MemoList/>
      <ARN></ARN>
      <BehaviorTestList></BehaviorTestList>
      <Stage>72 hour hold</Stage>
      <AnimalType>Dog</AnimalType>
      <AgeGroup>Baby</AgeGroup>
      <WildlifeIntakeInjury></WildlifeIntakeInjury>
      <WildlifeIntakeCause></WildlifeIntakeCause>
      <BuddyID>0</BuddyID>
      <Featured>No</Featured>
      <Sublocation>Stray Room 8</Sublocation>
      <ChipNumber>0A123F1156</ChipNumber>
    </adoptableSearch>
  </XmlNode>

LIVECODE CODE:
on mouseUp
 put url "http://www.petango.com/webservices/wsadoption.asmx/AdoptableSearch?authkey=XXXXXX&speciesID=&sex=&ageGroup=&location=&site=&onHold=&orderBy=&primaryBreed=&secondaryBreed=&specialNeeds=&noDogs=&noCats=&noKids=&stageID=" into  tURL
 put revCreateXMLTree( tURL, true, true, false) into tInfo

 put revXMLChildNames( tInfo, "ArrayOfXmlNode", return, , true) into tChildren
 repeat for each line tChild in tChildren
  put revXMLNodeContents( tInfo, "ArrayOfXmlNode/" & tChild & "/Species") &
  return after tSpecies
 end repeat

 put tSpecies
end mouseUp

A: Could you please try the following which includes adoptableSearch in the node path:
on mouseUp
 put url "http://www.petango.com/webservices/wsadoption.asmx/AdoptableSearch?authkey=XXXXXX&speciesID=&sex=&ageGroup=&location=&site=&onHold=&orderBy=&primaryBreed=&secondaryBreed=&specialNeeds=&noDogs=&noCats=&noKids=&stageID=" into  tURL
 put revCreateXMLTree( tURL, true, true, false) into tInfo

 put revXMLChildNames( tInfo, "ArrayOfXmlNode", return, , true) into tChildren
 repeat for each line tChild in tChildren
  put revXMLNodeContents( tInfo, "ArrayOfXmlNode/" & tChild & "/adoptableSearch/Species") &
  return after tSpecies
 end repeat

 put tSpecies
end mouseUp


text:
Q: Ifelse statement in R: One value cannot equal another I have a dataframe with two columns: df$user and df$type. The users are a list of different user names and the type category has two values: 'high_user' and 'small_user'
I want to create some code so that one user cannot be both types. For example if the user is high_user he cannot also be a small_user.
head(df$user)

[1] RompnStomp       Vladiman         Celticdreamer54  Crimea is Russia shrek1978third   annietattooface

head(df$type)

"high_user" "high_user" "small_user" "high_user" "high_user" "small_user"

Any help would be greatly appreciated.

A: One way would be to assign the first value of User to all the values of it's type.
df$new_type <- df$type[match(df$User, unique(df$User))]
df

#  User       type   new_type
#1    a  high_user  high_user
#2    b  high_user  high_user
#3    a small_user  high_user
#4    c small_user small_user
#5    c  high_user small_user

This can also be done using grouped operations.
library(dplyr)
df %>% group_by(User) %>% mutate(new_type = first(type))

data
df <- data.frame(User = c('a', 'b', 'a', 'c', 'c'),
      type = c('high_user', 'high_user', 'small_user', 'small_user', 'high_user'))

A: An option with base R
df$new_type <- with(df, ave(type, User, FUN = function(x) x[1]))

data
df <- data.frame(User = c('a', 'b', 'a', 'c', 'c'),
      type = c('high_user', 'high_user', 'small_user', 'small_user', 'high_user'))


text:
Q: How to use _Layout.cshtml design across the application I am creating a solution where I want consistent design across the solution.
My design is in _Layout.cshtml and I want to use the same design in different page but I am not getting the same design.
i supplied Layout = "~/Views/Shared/_Layout.cshtml"; in other page and thought it would work but no luck.
Please help and guide me what I am missing here.
This the page Where I want to use the design
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

Employee

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

            @Html.LabelFor(model => model.EmpName, htmlAttributes: new { @class = "control-label col-md-2" })

                @Html.EditorFor(model => model.EmpName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.EmpName, "", new { @class = "text-danger" })

                <input type="submit" value="Create" class="btn btn-default" />

}

    @Html.ActionLink("Back to List", "Index")

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

And _Layout.cshtml
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

    <link href="css/sb-admin-2.min.css" rel="stylesheet">

                    Dashboard

                    Attendace

Attendace:

                    Reports

                <button class="rounded-circle border-0" id="sidebarToggle"></button>

                    <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">

                    </button>

                    <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">

                            <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">

                                <button class="btn btn-primary" type="button">

                                </button>

                    </form>

Dashboard

                         Generate Report

                                            @RenderBody()

                © @DateTime.Now.Year - Sikh Limited

    @*@Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")*@
    @RenderSection("scripts", required: false)


text:
Q: Why do some scripts omit the closing PHP tag, '?>'? In some scripts I see that they omit writing a closing tag ?> for the script. Why is it and should I do this as well?
(I'm sure they have not forgotten it.)

A: From PHP: Instruction Separation

The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include() or require(), so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.

A: CodeIgniter Framework suggests to omit closing tags for

"... can cause unwanted output, PHP errors or blank pages".

You can read it here.

A: Modern versions of PHP set the output_buffering flag in php.ini. If output buffering is enabled, you can set HTTP headers and cookies after outputting HTML, because the returned code is not sent to the browser immediately.
Are the examples still valid in this context?

A: php.net on PHP tags:

If a file is pure PHP code, it is preferable to omit the PHP closing
  tag at the end of the file. This prevents accidental whitespace or new
  lines being added after the PHP closing tag, which may cause unwanted
  effects because PHP will start output buffering when there is no
  intention from the programmer to send any output at that point in the
  script.

A: Well, omitting the closing tag is just one solution for avoiding blanks and other characters at the end of file. For example any char which is accidentally added behind the closing tag would trigger an error when trying to modify header info later.
Removing the closing tag is kind of "good practice" referring to many coding guidelines.

A: They do it to avoid risking to have whitespaces after the closing tag which may stop headers to work.
This is, of course, true for PHP-only files.

A: *

*It shows unwanted white space / blank page. HTTP headers do not work for those unwanted whitespace.

*Most JavaScript injection is made at the end of the file. It will show an error message and breaks the code, injected JavaScript code does not get executed.


text:
Q: G++ 4.9.2 and 8.2.0 - final binary's dependency with default lib path searching ./../lib directory (implicit RPATH issue) I encountered an odd difference between the binary produced by a 4.9.2 G++ and a 8.2.0 G++ on a Linux, when upgrading from the former to the latter. I was able to narrow it down to the below minimized snippet
//main.cpp
int main(){}

//emptylib.cpp

#!/bin/sh
#to build and verify output
rm -rf bin lib *.o

gcc_bin=/path/to/gcc_4.9.2/bin
#gcc_bin=/path/to/gcc_8.2.0/bin

${gcc_bin}/g++ -B${gcc_bin} -c main.cpp
${gcc_bin}/g++ -B${gcc_bin} -c emptylib.cpp
${gcc_bin}/g++ -B${gcc_bin} -shared emptylib.o -o libemptylib.so
${gcc_bin}/g++ -B${gcc_bin} main.o -o main -L. -lemptylib

mkdir bin
mkdir lib
mv libemptylib.so lib/
mv main bin/

ldd bin/main

The result is a bit strange, because I have provided no -rpath=../lib, but all the same, with the 4.9.2 compiler driver I end up with (in the output of ldd):
libemptylib.so => /path/to/bin/../lib/libemptylib.so

and with 8.2.0
libemptylib.so => not found

the lib does not resolve, as I would expect. I haven't been able to see any documentation that hints at a search for ../lib in any version, but I would not expect this to be a behavior by any version. Was this a bug in 4.9.2 or some earlier version or something that shouldn't have happened in the first place?
As a side note, the 8.2.0 and the 4.9.2 don't have an ld inside of their bin directory (despite me putting the -B in the code snippet), so both compiler drivers are using the /usr/bin/ld (I've verified as much) and producing different results based on the compiler driver alone.
Update:
On request, I ran readelf -d bin/main on both binaries and I did receive different output for rpath. GCC 4.9.2 gave me:
0x000000000000000f (RPATH)    Library rpath: [$ORIGIN:$ORIGIN/../lib64:$ORIGIN/../lib:/path/to/gcc_libs/lib64:/path/to/gcc_libs/lib:/path/to/gcc_4.9.2/lib64:/path/to/gcc_4.9.2/lib]

where 8.2.0 did not have that
0x0000000000000001 (NEEDED)   Shared Library: [libemptylib.so]

So I guess I have an answer to what happened. So how did this end up in my binary in 4.9.2, and why did it change between the two versions where now it doesn't in 8.2.0?

A:
I did receive different output for rpath.
  rpath: [$ORIGIN:$ORIGIN/../lib64:$ORIGIN/../lib:/path/to/gcc_libs/lib64:/path/to/gcc_libs/lib:/path/to/gcc_4.9.2/lib64:/path/to/gcc_4.9.2/lib]

So the difference is in how GCC 4.9.2 vs. 8.2.0 were configured.
I am guessing that 8.2 came from your distribution (or at least was configured with default installation paths), whereas 4.9 was configured to be installed into /path/to/gcc_4.9.2.
That explains why 4.9 adds -rpath with /path/to/gcc_4.9.2/lib64 for a 64-bit builds. It does not however explain where $ORIGIN of /path/to/gcc_4.9.2/lib (the latter shouldn't be part of a 64-bit build) come from.
Configuring GCC so that it puts exactly what's necessary, no more and no less, is a bit of a black magic. I wouldn't be surprised if 4.9 had some bugs in that area.


text:
Q: Testing object method return values I have an object under test and want to verify it was configured correctly by testing the return values of methods. Is there a way to do this without creating one test per method?
I'm imagining something like:
assertThat(obj).fieldIs(Obj::methodA, "value1").fieldIs(Obj::methodB, "value1");

A: You can make a big test method that tests all fields of the object are as they should be, you aren't limited to one assertSomething() per method.
Example:
@Test
public void testFields() {
    Object someObj = theObjInstance;
    assertEquals("value1", someObj.methodA());
    assertEquals("value2", someObj.methodB());
    // ...
}


text:
Q: Changed build number is not shown at the environment where application was deployed I have build that is used as release pipeline written in yaml. It takes resources out of the build pipeline and deploys it to an environment.
Build details after running update build task
Inside the build I'm runnig this task that is able to change build number.
##vso[build.updatebuildnumber]$versionValue
However in the env view it shows build number in default format #20230131.3 on BuildName
Environment view
If I run this request:
$releaseUri = "https://dev.azure.com/$($organization)/$($project)/\_apis/build/builds/4577?api-version=7.0"
Invoke-RestMethod -Uri $releaseUri -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

I'm getting correct build number
buildNumber                  : rel-2023.1.30-4448-7a8e9f4
But why it is not shown on environment overview for a given deployment?
I tried updating manually buildNumber
[$updateBuildUri = "https://dev.azure.com/$($organization)/$($project)/_apis/build/builds/4595?api-version=7.0"
$body = "{
  `"buildNumber`": `"Adam1234`"
    }"

Invoke-RestMethod -Uri $updateBuildUri -Method PATCH -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}  -Body $body][1]

but without any results at the environment view.


text:
Q: Why is selected value null in wpf listbox? I have connected to a database using entity framework and put the make and model of cars into a listbox in the format: Make - Model.
When I select an item from the listbox I would like to get the ID of that object to use it in another query which will display full details of that specific car(row in database) in a textblock.
When I select an item from the listbox it throws back a null value at:

int id = (int)ltbxAvailableCars.SelectedValue;

In XAML, I have specified:

Listbox SelectedValuePath="ID"

Are there any obvious mistakes here that I'm just not seeing?
Thank you in advance.
public partial class MainWindow : Window
{
    CarRentalDBEntities db = new CarRentalDBEntities();

    public enum CarType { All, Small, Medium, Large }

    public MainWindow()
    {
        InitializeComponent();

        cbxCarType.ItemsSource = Enum.GetValues(typeof(CarType));
    }

    private void btnSearch_Click(object sender, RoutedEventArgs e)
    {
        CarType type;
        Enum.TryParse<CarType>(cbxCarType.SelectedValue.ToString(), out type);

        string carType = type.ToString();

        if (carType == "All")
        {
            ltbxAvailableCars.Items.Clear();
            var cars = from c in db.Cars
                       select new
                       {
                           c.ID,
                           c.Make,
                           c.Model,
                           c.Size
                       };

            foreach (var car in cars)
            {
                ltbxAvailableCars.Items.Add(car.Make + " - " + car.Model);
            }
        }
        else
        {
            ltbxAvailableCars.Items.Clear();
            var cars = from c in db.Cars
                       where c.Size == carType
                       select new
                       {
                           c.ID,
                           c.Make,
                           c.Model,
                           c.Size
                       };

            foreach (var car in cars)
            {
                ltbxAvailableCars.Items.Add(car.Make + " - " + car.Model);
            }
        }
    }

    private void ltbxAvailableCars_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        int id = (int)ltbxAvailableCars.SelectedValue;

        CarRentalDBEntities db = new CarRentalDBEntities();

        var query = from c in db.Cars
                    where c.ID == id
                    select new
                    {
                        c.ID,
                        c.Make,
                        c.Model,
                        c.Size
                    };

        tblkSelectedCarDetails.Text = query.ToString();
    }
}

A: Here is approach for your case. But on my opinion mentioned by you databinding with ObservableCollection seems more elegantly and even easily
Create class for keeping needed values in the Listbox items
public class Car
{
    public Int32 ID { get; set; }
    public DateTime Make { get; set; }
    public String Model { get; set; }

    public override string ToString()
    {
       return String.Format("{0} - {1}", this.Make, this.Model);
    }
}

ToString will be override and return string which you want be shown in the listbox.
ListBox call .ToString() method of the item for displayed text
Then in the LINQ query create instances of that class and add them to the listbox
ltbxAvailableCars.Items.Clear();
var cars = from c in db.Cars
           where c.Size == carType
           select new Car
           {
               ID = c.ID,
               Make = c.Make,
               Model = c.Model
           };

foreach (Car car in cars)
{
    ltbxAvailableCars.Items.Add(car);
}

And use it in the SelectionChanged event handler
private void ltbxAvailableCars_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    Car temp = (Car)ltbxAvailableCars.SelectedItem;
    Int32 id = temp.ID
    CarRentalDBEntities db = new CarRentalDBEntities();

    var query = from c in db.Cars
                where c.ID == id
                select new
                {
                    c.ID,
                    c.Make,
                    c.Model,
                    c.Size
                };

    tblkSelectedCarDetails.Text = query.ToString();
}

A: Pertinent to your case, you may try to use e.AddedItems (args passed to your method ltbxAvailableCars_SelectionChanged) and extract the value from it, as detailed in MSDN online: https://msdn.microsoft.com/en-us/library/system.windows.controls.selectionchangedeventargs%28v=vs.110%29.aspx
Hope this may help. Best regards,


text:
Q: Why does my React app say 404 not found when I refresh a page? I have a React app deployed with Nginx in a AWS EC2 instance and it runs well when I use navigation bar to open a page.
But when I refresh a page, it says 404 not found even though it works correctly with navigation.

Both front-end(React) and back-end(Node) services are running in the server.
And my Nginx configuration is below.

A:
This is my index.js route in Node back-end.
And imported it to app.js in the root folder.
var indexRouter = require('./routes/index');

And Jade is installed, but never used.
Please let me know any updates for this issue.


text:
Q: How to execute an sql view in mvc C# and store its result in a list? I am working on an asp.net mvc application using C#. For database, I am using Entity Framework and code-first approach. I have an sql view that I need to execute and store its result in a list. I know how to query data from DB using ApplicationDbContext, stored procedure and inline queries. But now I want to do the same using a view.
The view looks like this
CREATE VIEW [dbo].[GenresView]
AS SELECT * FROM Genres

I have a Genre class that has the same properties that the view will return.

A: Steps to handle a view:

*

*Create a GenresView class with properties mapped to view columns. You can use EF features like virtual properties and ForeignKey annotations to be able to load entities related to the view in your queries.

*Add the created entity as a new property DbSet GenresView to your database context.

*Add new migration using Package Manager Console and add migration command.
As you can notice, the generated migration contains statements for creating a new table for the GenresView in the Up() method. Delete this code and replace it with Sql(@"CREATE VIEW dbo.GenresView AS SELECT * FROM Genres") statement.

IMPORTANT!!! It is better to define all fields which you want to get instead of  * .

*

*You should also replace the code in the Down() method to be able to revert the migrations properly. Its code should contain call to Sql(@"DROP VIEW dbo.GenresView").

*Update the database.

*Now you can use the new entity in your LINQ statements as it were a regular table (e.g. dbContext.GenresView.).


text:
Q: How to prevent backspace from deleting text in a disabled textArea in Edge browser? There seems to be a bug in Edge browser with disabled textBoxes and textAreas.
I'm facing this issue in my App, they accept the backspace (also delete key) and delete the text!
I tried to use e.preventDefault() in keydown and keypress but it didn't work.
Any suggestions on how to workaround this bug?
You can see the issue here (on Edge):
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea_disabled
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_text_disabled2
Update:
This issue seems to be fixed, but still not flighted according to this link
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13396475/
But here's my workaround for now:
make it readonly with some css to make it look disabled, and use "return false;" to prevent the browser from going to previous page.
<textarea readonly onkeydown="return false;" style="background: #f1f1f1" >test .....</textarea>

A: This issue has been fixed in Edge browser, and readonly workaround can be also useful if needed


text:
Q: subset data rows in a data frame that is within a 100km radius of a specific lat/long point in R I want to subset from the df the rows in which the corresponding lat/long fall within a 100km radius from the following coordinate point:
lat = 25.70 long = 75.80
It should select at least 4 data rows, I guess by looking at the map.
library(ggplot2)
library(ggmap)

df <- data.frame(
id = as.numeric(c(1:18)),
latitude = as.numeric(c(22.24, 23.20, 24.22, 25.02, 25.88, 26.13, 25.05, 23.93, 22.55, 26.18, 25.45, 24.01, 22.88, 26.13, 25.63, 24.43, 23.41, 26.20)),
longitude = as.numeric(c(-79.68, -79.84, -80.15, -80.01, -80.18, -78.55, -78.37, -78.24, -77.94, -76.13, -76.08, -76.13, -76.11, -75.17, -75.19, -75.29, -75.23, -75.66)))

area1 = get_map(location = c(lon = -77.9407, lat = 24.5774), zoom = 7, maptype = "satellite")

map1 = ggmap(area1, extent = "panel", legend = "bottomright")

map1+geom_point(aes(x = longitude, y = latitude), data = df, color = "#ff0000")

I am trying to do this task but unfortunately I still didn't find a way to manage this. Maybe you guys more experienced can help me to work out this data manipulation issue.


text:
Q: How to update a field-List in MongoDB using Mongoose and Nodehs? Hello dear Stackoverflow team.
I am trying to patch a user, which can handle several "devices". I am using nodeJs with Express and Mongoose (MongoDB). My User model is the following:
const userSchema = new Schema({
     name: {type: String, required: true},
     lastname: {type: String, required: true},
     email: {type: String, required: true, trim: true, lowercase: true, unique:
            true},
     password: {type: String, required: true, minlength: 5},
     userTyp: {type: String, required: true,
     enum: {values: ['Administrator', 'Doctor','Patient','Optiker'], message:
           '{VALUE} is not supported' }},
     image: {type: String},
     devices: [ {device: {type: Schema.Types.ObjectId, ref: "Device"}} ]
    });

and I want to have something like this everytime i do a patch:
{
"user": {
    "_id": "6138cd30ffc5239bba72e6c0",
    "name": "Fernando",
    "lastname": "Gonzalez",
    "email": "f.gonzalez@unitransferklinik.de",
    "password": "Hol087+/*",
    "userTyp": "Administrator",
    "image": "sdsadsadsa/asdfasdas",
    "devices": [
        {
            "device": "6138c7587ab4b5fc4d369230"
        },
        {
            "device": "6138c7587ab4b5fc4d365210"
        }
    ],
    }
}

How can I implement in my function:
const updateUser = async (req, res, next) => {
const { name, lastname, email, password, userTyp, device } = req.body;
    const userID = req.params.userID;
    let updatedUser;
    try {
        updatedUser = await User.findById(userID);
    }catch(err){
        console.log(err);
        return next(new HttpError('Something happend.', 500));
    }

    updatedUser.name = name;
    updatedUser.devices = [device, ...updatedUser.devices];
    try{
             updatedUser.save();
        }catch (err) {
            return next(new HttpError('It could not uodate device.', 500));
        }
    });

    res.status(200).json({user: updatedUser.toObject( {getters: true} )});
};

In easy words, I want to updated the list everytime that i do a patch with a new device, and I can fetch later all the device list per user.
Thanks a lot!
regards,
Eliot

A: You can use findOneAndUpdate function of mongoose library
const dynamicModel = libMongoose.model(collection_name, userSchema);
var filter = { userID: req.params.userID };
var update = { name: name, devices : [...device, ...updatedUser.devices]};
//callback approach
dynamicModel.findOneAndUpdate(filter, update, (err, resp) => {
    if(err) {
        console.log("Error while updating record " + JSON.stringify(err));
    }
    if(!resp) {
        console.log("Couldn't find record");
    } else {
        console.log("Updated data to DB");
    }
});

You can also refer here for async await, Hope this helps!


text:
Q: The difference between datetime data in SQL how can i find the difference between two dateTime store in a MySQL database
e.g the difference in hours between 2016-03-09 04:30:00 and 2016-03-10 03:00:00.
i have tried dateDiff() but it does not compare the hours that is need to see the difference between (2016-03-09 04:30:00) - (2016-03-10 03:10:00).
the order is year-month-day time

The output i need is the number of hours between these times also considering the time as well.

A: You can use TIMESTAMPDIFF to find the difference between two timestamps
SELECT TIMESTAMPDIFF(HOUR,'2009-05-18 10:00','2009-05-18 11:00');

If you want fraction(eg: 1.5 hrs) hours you can do like below
SELECT (UNIX_TIMESTAMP('2012-10-30 10:40')-UNIX_TIMESTAMP('2012-10-30 10:30'))/3600 hour_diff

A: One simple method is to use to_seconds():
select to_seconds(dt1) - to_seconds(dt2)

This gives the difference in seconds.  Then you can divide by 60*60 to get hours or 24*60*60 for days.


text:
Q: Date copmarison in SumIfs Formula not working I try to compare the current date to dates in one column but it gives me "0" all the time.
Before I added the date comparison within the "SumIfs" formula it worked well.
Dim ClaimR As Workbook

With ClaimR.Sheets(1).Columns(10) 'Column "J"
    .NumberFormat = "DD.MM.YY"
End With

Dim today As Date
today = Format(Date)

    HoursAmount = Application.WorksheetFunction.SumIfs(ClaimR.Sheets(1).Range("I:I"), ClaimR.Sheets(1).Range("G:G"), serial, ClaimR.Sheets(1).Range("U:U"), "Vacation", ClaimR.Sheets(1).Range("J:J"), "<=" & today)

I've read some related issues but I don't get what's wrong with my code.


text:
Q: exsisting database synchronize with laravel migration I have designed a database using mysql workbench and synchronize, then my mysql database exists @ phpmyadmin . then how can I use this database with laravel.. I mean I need to create migration files for existing database and continue editing..

A: You should write the migration files, so your schema can be built from zero without a manual intervention. But if you can't or you don't want to do it, you can start your migrations from your desired point:
php artisan make:migration blablabla

Write the new schema and:
php artisan migrate

And so on.

A: You could you this package
Migrations Generator

*

*Include it in your project(via composer or directly downloading it    into your vendor folder) and configure service providers.

*run: php artisan migrate:generate to generate the migrations for all the tables in you current database. To generate the migrations for specific tables, run php artisan migrate:generate table1,table2,table3,table4,table5.

A: while in developing stage you can use : https://github.com/awssat/laravel-sync-migration
by using :
php artisan migrate:sync

but I won't recommend use it for production since you can't track the migrations changes

A: My situation was the following:

*

*I had hundreds of migration classes in the database/migrations folder.

*My classes had already been migrated, but at some point I imported an old
version of my migration table by accident.

*My migrations table had fewer records than my classes.

After trying everything, I decided to walk the extra mile and solve my problem like this:
I created a method in a temporary controller. Basically, it checks through all my migration classes in database/migrations folder and then checks if they exist in the migrations table. If not, insert them into the table. Called the method from the browser and now everything is synched
 public function syncMigration(){
        $migrations_folder = database_path('migrations');
        $filesInFolder = File::files($migrations_folder);
        $lastMigration = DB::table('migrations')->orderBy('batch', 'desc')->limit(1)->first();
        var_dump($lastMigration);

        $batch = $lastMigration->batch +1;

        foreach($filesInFolder as $path) {
            $file = pathinfo($path);
            $migration = DB::table('migrations')->where('migration', $file['filename'])->first();
            if(!$migration){
                DB::table('migrations')->insert(
                    [
                        'migration' => $file['filename'],
                        'batch' => $batch
                    ]
                );
            }
        }
    }


text:
Q: Series expansion not possible for more than two variables? My problem is simple. I want to evaluate the series
Series[(1 + x*b - x*a)/(1 + 2*x*c - 2*x*a), {a, 0, 2}, {b, 0, 2}, {c,
0, 2}].

Mathematica output looks like this:

The third variable (c) stays blue. The documentation claims that shouldn't be the case. What am I missing?

A: Do you want a Seriesexpansion or a Taylorpolynom of 2. degree?
With Mathematicas Series you get:
Series[(1 + x*b - x*a)/(1 + 2*x*c - 2*x*a), {a, 0, 2}, {b, 0, 2}, {c, 0, 2}] // Normal // Expand

1 + a x + b x - 2 c x + 2 a^2 x^2 + 2 a b x^2 - 6 a c x^2 -
 2 b c x^2 + 4 c^2 x^2 + 4 a^2 b x^3 - 16 a^2 c x^3 - 8 a b c x^3 +
 20 a c^2 x^3 + 4 b c^2 x^3 - 24 a^2 b c x^4 + 72 a^2 c^2 x^4 +
 24 a b c^2 x^4 + 96 a^2 b c^2 x^5

With Taylor expansion:
taylor = (vars - point).# &;
init := D[f[vars], {vars, j}] /. Thread[vars -> point];
taylorPoly[m_] := Sum[1/j! Nest[taylor, init, j], {j, 0, m}]

vars = {a, b, c};
point = {0, 0, 0};
f[vars_] = (1 + x*b - x*a)/(1 + 2*x*c - 2*x*a);
taylorPoly[2] // Expand

1 + a x + b x - 2 c x + 2 a^2 x^2 + 2 a b x^2 - 6 a c x^2 - 2 b c x^2 + 4 c^2 x^2

or another method:
f[a_,b_,c_] = (1 + x*b - x*a)/(1 + 2*x*c - 2*x*a);
n = {a - a0, b - b0, c - c0};
grad = Grad[f[a0, b0, c0], {a0, b0, c0}];
hesse = D[f[a0, b0, c0], {{a0, b0, c0}, 2}];
taylor = f[a0, b0, c0] + n.grad + 1/2 n.hesse.n /. {a0 -> 0, b0 ->0, c0 -> 0} // Expand

1 + a x + b x - 2 c x + 2 a^2 x^2 + 2 a b x^2 - 6 a c x^2 - 2 b c x^2 + 4 c^2 x^2

As Kuba commented your code works fine in Mathematica 10.3.1


text:
Q: Aliasing of NEON vector data types Does NEON support aliasing of the vector data types with their scalar components?
E.g.(Intel SSE)
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));

The above will allow me to do:
__m128i* somePtr;
somePtr++;//advance to the next block

Aliasing a la Intel it will allow to advance my pointer to the next block I want to process
without managing extra counts and indexes.

A: The __may_alias__ attribute on __m128i should be viewed as a work-around which makes it possible to write strict-aliasing-correct code even though Intel completely screwed up the signatures of some of the SEE load/store intrinsics. (The 8-byte loading _mm_loadl_epi64(const __m128i*) is the most hilarious example, but there are others). ARM got their intrinsics right, so __may_alias__ isn't needed.
Just use pointers to the element type, and use explicit loads and stores. In my experience that leads to better code being generated, and is probably also more portable. (Does the ARM C language spec even allow pointers to NEON types? I wouldn't be surprised if they didn't).

A: NEON intrinsics implementation does NOT support aliasing of the vector data types with their scalar components.

A: GCC supports a bunch of intrinsics when you specify -mfpu_neon.  One of the ones you'd be interested in, I'm guessing, is int32x4_t.  More info about all the types available can be found on the ARM site.