Q: javax.el.ELException: Property 'askQuestiοn' not found on type trainforjava.domain.Questiοn My problem is the following. I've a list which i s well created, but I can't manage to display it on my web page.
Here is the pojo :
package trainforjava.domain;

public class Question {

    public int id;
    public String askedQuestion;
    public String proposal;

    public Question() {
        super();

    }

    public Question(int id, String askedQuestion, String proposal) {
        super();
        this.id = id;
        this.askedQuestion = askedQuestion;
        this.proposal = proposal;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setAskedQuestion(String askedQuestion) {
        this.askedQuestion = askedQuestion;
    }

    public String getAskedQuestion() {
        return askedQuestion;
    }

    public void setQuestion(String askedQuestion) {
        this.askedQuestion = askedQuestion;
    }

    public String getProposal() {
        return proposal;
    }

    public void setProposal(String proposal) {
        this.proposal = proposal;
    }

    @Override
    public String toString() {
        return "Question [id=" + id + ", askedQuestion=" + askedQuestion + "]";
    }

}

Here is the managed bean :
package trainforjava.domain;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import trainforjava.util.QuestionCreator;

@ManagedBean
public class QuestionBean {

    public List<String> proposals;
    public List<Question> questions;
    public QuestionCreator creator = new QuestionCreator();

    public QuestionBean() {

        System.out.println("beforecreate");
        questions = creator.createQuestions();
        System.out.println(questions);
//      proposals = creator.createProposals(0);

    }

    public List<String> getProposals() {
        return proposals;
    }
    public void setProposals(List<String> proposals) {
        this.proposals = proposals;
    }
    public List<Question> getQuestions() {
        return questions;
    }
    public void setQuestions(List<Question> questions) {
        this.questions = questions;
    }

}

Here is the pojo creating from a properties file :
package trainforjava.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.springframework.stereotype.Component;

import trainforjava.domain.Question;

public class QuestionCreator {

List<Question> questions =new ArrayList<Question>();
    List<String> proposals = new ArrayList<String>();

    public List<Question> createQuestions() {
        final Properties properties = new Properties();
        InputStream input = null;
        System.out.println("createQuestions");

        try {

            input = getClass().getResourceAsStream("/questions.properties");
            // load a properties file
            properties.load(input);

            // get the property value and print it out
            for (int i = 0; i < properties.size(); i++) {

                Question question = new Question();
                StringBuilder sb = new StringBuilder();
                sb.append("question-").append(i);
                String askedQuestion = properties.getProperty(sb.toString());
                question.setAskedQuestion(askedQuestion);
                question.setId(i);
                questions.add(question);

            }

        } catch (final IOException ex) {
            ex.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
        }

        return questions;

    }

    public List<String> createProposals(int key) {
        final Properties properties = new Properties();
        InputStream input = null;
        System.out.println("createProposals");
        try {

            input = getClass().getResourceAsStream("/proposals.properties");
            // load a properties file
            properties.load(input);

            for(int i =0 ; i < proposals.size(); i++){

            int idQuestion = key;
            System.out.println("createProposals id" + idQuestion);
            StringBuilder sb = new StringBuilder();
            sb.append("proposal-").append(idQuestion).append("-").append(i);
            String proposal = properties.getProperty(sb.toString());
            proposals.add(proposal);
            System.out.println(proposals);

            }

        } catch (final IOException ex) {
            ex.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
        }

        return proposals;

    }

}

The console print me the list created, which name is "questions", but also print me a stacktrace :
beforecreate
createQuestions
[Question [id=0, askedQuestion=Quelle interface est implémentée par la Classe ArrayList ?], Question [id=1, askedQuestion=Quelle interface est implémentée par la Classe HashMap ?], Question [id=2, askedQuestion=Quelle interface est implémentée par la Classe Vector ?]]
août 23, 2016 2:29:19 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
GRAVE: Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
    at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
    at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

août 23, 2016 2:29:19 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: JSF1073 : javax.el.ELException intercepté durant le traitement de RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=/index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
août 23, 2016 2:29:19 AM com.sun.faces.context.ExceptionHandlerImpl log
1100: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
javax.el.ELException: /index.xhtml: Property 'askQuestion' not found on type trainforjava.domain.Question
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
    at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
    at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

And then, the index.xhtml which is supposed to display this list :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Test</title>
</h:head>

<h:body>

    Question :
    <h:form>

        <h:dataTable value="#{questionBean.questions}" var="question">
            <h:column>
            #{question.askQuestion}
            </h:column>
        </h:dataTable>

    </h:form>

</h:body>
</html>

Can someone help me please ?

A: The property name is actually askedQuestion, and not askQuestion.


Q: Space Complexity of generating all possible binary search trees I used the following recursion algorithm to calculate the possible cases of binary search trees given its number of nodes being n
public List<TreeNode> generateTrees(int n) {
    if(n == 0){
        List<TreeNode> empty = new ArrayList<TreeNode>();
        return empty;
    }
    return recurHelper(1, n);
}
public List<TreeNode> recurHelper(int start, int end){
    if(start > end){
        TreeNode nan = null;
        List<TreeNode> empty = new ArrayList<TreeNode>();
        empty.add(nan);
        return empty;
    }
    List<TreeNode> result = new ArrayList<TreeNode>();
    for(int i = start; i <= end; i++){
        List<TreeNode> left = recurHelper(start, i-1);
        List<TreeNode> right = recurHelper(i+1, end);
        for(TreeNode leftBranch:left){
            for(TreeNode rightBranch:right){
                TreeNode tree = new TreeNode(i);
                tree.left = leftBranch;
                tree.right = rightBranch;
                result.add(tree);
            }
        }
    }
    return result;
}

I wonder what is the space complexity for the recursion, should it be O(h), where h is the height of the tree?
I do not think so because at each level we are storing a result consisting of O(lG_l) elements, where l stands for the level and G_l stands for the number of possible trees with l nodes.
Then it seems to me that the space complexity of the recursion should be nG_n + ... + 1G_1.


Q: zypper dependency resolution I am facing problem while installing an "Company-hardening-1.0-1.noarch.rpm" RPM through zypper. There are 2 systems involved. Both are SUSE-Linux-Enterprise-Server-11-SP3 VMs.
System 1: (working)
In this system I am able to install the rpm, in this case, zypper is automatically resolving the dependency.
susevm1:~ # zypper install Company-hardening-1.0-1.noarch.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW packages are going to be installed:
  Company-hardening openscap-engine-sce

The following packages are not supported by their vendor:
  Company-hardening openscap-engine-sce

2 new packages to install.
Overall download size: 195.0 KiB. After the operation, additional 1.0 MiB will be used.
Continue? [y/n/?] (y): n

System 2: (Not working)
In this system RPM is not getting installed, as zypper is not able to resolve the dependency.
linux-g33k:~/Desktop/RPMS # zypper install Company-hardening-1.0-1.noarch.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: nothing provides openscap-engine-sce >= 1.2.5-2 needed by Company-hardening-1.0-1.noarch
 Solution 1: do not install Company-hardening-1.0-1.noarch
 Solution 2: break Company-hardening-1.0-1.noarch by ignoring some of its dependencies

Choose from above solutions by number or cancel [1/2/c] (c): c

Note that, both system are having same version of zypper. I know, this might a simple and silly question. :) This might be because  of some repository diff.
Thanks,
Hemant

A: It means you don't have the same repositories activated on both machines. Comparing the output of
zypper lr -u

on both machines should show you which repository to add or enable.


Q: Black bar when increasing window size in WPF I have a small program with two checkboxes.
The window height is 120. When one of them is checked the windows height should increase to 180. If both are checked it should increse to 220. If you uncheck them they should decrease to 180 for 1 checkbox and 120 if none are checked.
I make it smooth, that means i calculate the windowHeightOld and windowHeightNew difference, divide it through 30 and increase it in 30 small steps so it seems smooth.
The problem is that the decrease to a smaller window size looks great, the increase gives on the area that increases a black bar for a few milliseconds, then dissapears again. Sadly i could not make a screenshot because of how short its there.
I dont know where that comes from and how that could be fixed.
Here a code snipped from the increase/decrase of the window height:
private void CheckBoxSetup_Click(object sender, RoutedEventArgs e)
    {

if (CheckBoxSetup.IsChecked == false && CheckBoxUpdate.IsChecked == false)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 180;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
}
if (CheckBoxSetup.IsChecked == true || CheckBoxUpdate.IsChecked == true)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 220;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
    //MainWindow1.MinHeight = 220;

}
if (CheckBoxSetup.IsChecked == true && CheckBoxUpdate.IsChecked == true)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 260;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
    //MainWindow1.MinHeight = 260;

}

if (CheckBoxSetup.IsChecked == true)
{
    LabelDestinationSetup.Visibility = Visibility.Visible;
    TextBoxDestinationpathSetup.Visibility = Visibility.Visible;
    CheckCountSetup++;
}
else
{
    LabelDestinationSetup.Visibility = Visibility.Hidden;
    TextBoxDestinationpathSetup.Visibility = Visibility.Hidden;
    CheckCountSetup--;
}
if (CheckCountSetup == 1)
{
    LabelDestinationSetup.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop1, 0, 0);

    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(160, thickTop2, 0, 0);
}
if (CheckCountSetup == 0 && CheckCountUpdate == 1)
{
    LabelDestinationSetup.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop2, 0, 0);

    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(160, thickTop1, 0, 0);
}
if (CheckCountSetup == 0)
{
    LabelDestinationSetup.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop2, 0, 0);

    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(160, thickTop1, 0, 0);
}
}

private void CheckBoxUpdate_Click(object sender, RoutedEventArgs e)
{
if(CheckBoxUpdate.IsChecked == true && CheckBoxFTP.IsChecked == false){
    CheckBox64Bit.IsEnabled = true;
}else if(CheckBoxUpdate.IsChecked == false){
    CheckBox64Bit.IsEnabled = false;
    CheckBox64Bit.IsChecked = false;
}
if (CheckBoxSetup.IsChecked == false && CheckBoxUpdate.IsChecked == false)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 180;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
    //MainWindow1.MinHeight = 180;

}
if (CheckBoxSetup.IsChecked == true || CheckBoxUpdate.IsChecked == true)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 220;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
    //MainWindow1.MinHeight = 220;

}
if (CheckBoxSetup.IsChecked == true && CheckBoxUpdate.IsChecked == true)
{
    MainWindow1.MinHeight = 50;

    OldWindowHeight = MainWindow1.Height;
    int NewWindowHeigth = 260;
    WindowDiff = NewWindowHeigth - OldWindowHeight;
    WindowDiff = WindowDiff / 30;
    for (int a = 0; a < 30; a++)
    {
        OldWindowHeight = OldWindowHeight + WindowDiff;
        MainWindow1.Height = OldWindowHeight;
        MainWindow1.MinHeight = OldWindowHeight;

    }
    //MainWindow1.MinHeight = 260;

}
if (CheckBoxUpdate.IsChecked == true)
{
    LabelDestinationUpdatepackage.Visibility = Visibility.Visible;
    TextBoxDestinationpathUpdatePackage.Visibility = Visibility.Visible;
    CheckCountUpdate++;
}
else
{
    LabelDestinationUpdatepackage.Visibility = Visibility.Hidden;
    TextBoxDestinationpathUpdatePackage.Visibility = Visibility.Hidden;
    CheckCountUpdate--;
}
if (CheckCountUpdate == 1)
{
    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(160, thickTop1, 0, 0);

    LabelDestinationSetup.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop2, 0, 0);
}
if (CheckCountSetup == 1 && CheckCountUpdate == 0)
{
    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(160, thickTop2, 0, 0);

    LabelDestinationSetup.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop1, 0, 0);
}
if (CheckCountUpdate == 0)
{
    LabelDestinationUpdatepackage.Margin = new Thickness(24, thickTop2, 0, 0);
    TextBoxDestinationpathUpdatePackage.Margin = new Thickness(181, thickTop2, 0, 0);

    LabelDestinationSetup.Margin = new Thickness(24, thickTop1, 0, 0);
    TextBoxDestinationpathSetup.Margin = new Thickness(160, thickTop1, 0, 0);
}
}

Sorry for the long line of code but i thought it to be nessecary to have insight.
Basically it checks if these two are checked or not in different combinations. And increases or decreases the window height according to it. And because i also have textboxes there (thats the reason i do it. When checkboxes are checked i want to show the according textbox) which i set visible or invisible according to the checkboxes.
So basically its two methods (click Checkbox1 and click Checkbox2) and both are build the same. When one is clicked it checks for the combination, sets the window height accordingly and shows or sets the according textboxes invisible.
0 Checkboxes checked:

1 Checkbox checked:

2 Checkboxes checked:

I hope i explained it good enough.

A: XAML:
<Window x:Class=.........
        DataContext="{StaticResource MainViewModel}"
        Name="MyWindow"
        >

    <Window.Triggers >
        <EventTrigger  RoutedEvent="CheckBox.Unchecked" >
            <BeginStoryboard  >
                <Storyboard   >
                    <DoubleAnimation  Storyboard.TargetName="MyWindow" Storyboard.TargetProperty = "(Window.Height)" Duration="0:0:0.5" To="{Binding WindowHeight}"  RepeatBehavior="1x" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
        <EventTrigger  RoutedEvent="CheckBox.Checked"  >
            <BeginStoryboard  >
                <Storyboard   >
                    <DoubleAnimation  Storyboard.TargetName="MyWindow" Storyboard.TargetProperty = "(Window.Height)" Duration="0:0:0.5" To="{Binding WindowHeight}"  RepeatBehavior="1x" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Window.Triggers>

    <Grid Row="0" >
        ............
        <CheckBox   Grid.Column="4"
                    Content="UpadatePack"
                    IsChecked="{Binding PackegeCheck, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
                    Name="CheckUpadatePack" />
        <CheckBox   Grid.Column="5"
                    Content="Setup"
                    IsChecked="{Binding SetupCheck, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
                    Name="CheckSetup"  />
        ......
    </Grid>
    <Grid Row="5" Visibility="{Binding SetupDestinationVisibility, Converter={StaticResource BoolToVisibilityConverter}}" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="120"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Label Content="Setup Destination" Margin="5" Grid.Column="0"/>
        <TextBox  Margin="5" Grid.Column="1"/>
    </Grid>
    <Grid Row="6" Visibility="{Binding PackageDestinationVisibility, Converter={StaticResource BoolToVisibilityConverter}}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="120"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Label Content="Package Destination" Margin="5" Grid.Column="0"/>
        <TextBox  Margin="5" Grid.Column="1"/>
    </Grid>

</Window>

MainViewModel:
public class MainViewModel : ViewModelBase
{

    private bool _sixtyFourBitCheck;
    private bool _packegeCheck;
    private bool _setupCheck;
    private bool _ftpUploadCheck;
    public int _windowHeight;
    public int _origSize = 200;

    public bool SixtyFourBitCheck
    {
        get => _sixtyFourBitCheck;
        set
        {
            if (value == _sixtyFourBitCheck) return;
            _sixtyFourBitCheck = value;
            OnPropertyChanged();
        }
    }

    public bool PackegeCheck
    {
        get => _packegeCheck;
        set
        {
            if (value == _packegeCheck) return;
            _packegeCheck = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(PackageDestinationVisibility));
            ChangeWindowsHeght();
        }
    }

    public bool SetupCheck
    {
        get => _setupCheck;
        set
        {
            if (value == _setupCheck) return;
            _setupCheck = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(SetupDestinationVisibility));
            ChangeWindowsHeght();
        }
    }

    public bool FtpUploadCheck
    {
        get => _ftpUploadCheck;
        set
        {
            if (value == _ftpUploadCheck) return;
            _ftpUploadCheck = value;
            OnPropertyChanged();
        }
    }

    public bool SetupDestinationVisibility => SetupCheck;

    public bool PackageDestinationVisibility => PackegeCheck;

    public int WindowHeight
    {
        get => _windowHeight;
        set
        {
            if (value == _windowHeight) return;
            _windowHeight = value;
            OnPropertyChanged();
        }
    }

    public MainViewModel()
    {
        WindowHeight = _origSize;
    }

    private void ChangeWindowsHeght()
    {
        WindowHeight = _origSize;
        if (PackageDestinationVisibility)
            WindowHeight += 35;
        if (SetupDestinationVisibility)
            WindowHeight += 35;
        OnPropertyChanged(nameof(WindowHeight));
    }
}


Q: Split from list in python In my list I have few items, i.e.,
List=['a/c/d/eww/d/df/rr/e.jpg', 'ss/dds/ert/eww/ees/err/err.jpg','fds/aaa/eww/err/dd.jpg']

I want to keep only from 'eww' till last '/'
Modified_list=['eww/d/df/rr/', 'eww/ees/err/err.jpg','eww/err/']

A: Use find(sub_str) function.
new_list = [item[item.find("eww"):] for item in List]
print(new_list)

Output:
['eww/d/df/rr/e.jpg', 'eww/ees/err/err.jpg', 'eww/err/dd.jpg']

A: new_list2=[item[item.find('eww'):item.rfind('/')+1] for item in List]
print(new_list2)

output=   ['eww/d/df/rr/', 'eww/ees/err/', 'eww/err/']

A: Here are the steps I would do:

*

*split the string after eww
assuming that each string contains 'eww' you can split the string like this: split = 'eww'+string.split('eww')[1]

*Now, you have to loop over each character in the remaining string and save the index of the last /

*Remove everything after the last / with the index from step 3: split = split[:splitIndex]

*Now, you just have to put everything in a loop that iterates over the list and execute each of the steps above on each element of the list and save the modified string to the ModiefiedList list.

A: You can use a regex in a list comprehension.
A perfect use case for the new walrus operator (python ≥3.8):
List=['a/c/d/eww/d/df/rr/e.jpg',
      'ss/dds/ert/eww/ees/err/err.jpg',
      'fds/aaa/eww/err/dd.jpg']

import re
out = [m.group() if (m:=re.search('eww/(.*)/', s)) else s
       for s in List]

output:
['eww/d/df/rr/', 'eww/ees/err/', 'eww/err/']

NB. this keeps the original string in case of no match, if you rather want to drop it:
out = [m.group() for s in List if (m:=re.search('eww/(.*)/', s))]


Q: One Click at .click(function() Not Working in Ajax I want to open another page on my site with this ajax:

OPEN

But these pages can only be loaded with a double-click. What is wrong in my code, can you help me? thanks ..

A: Change your code to this and it will work:

OPEN


Q: Neo4j 1 to 1 Relationship I have two nodes, "client" and "builder". I want to find only the relationships where the client only has 1 builder, and that builder only has that one client so a 1-1 relationship. So far my query is
MERGE(b:Person{name:csv.name)
MERGE(c:Person{name:csv.name})
WITH collect(distinct b) as builder, collect(distinct c) as client
UNWIND builder as builders
UNWIND client as clients
WITH builders, clients
WHERE builders = 1 and clients = 1
MATCH (builders:Person)-[bu:builder_for]->(clients:Person)
WITH builders,clients, count(distinct bu) as builds
WHERE builds=1

RETURN distinct builders, clients

This only returns though a 1 to many relationship and is still showing duplicates in my client list.
The highlighted are the ones I would want to return
UPDATE cybersam implementation worked, thank you so much!

A: Assuming you want to get all the builder/client pairs that only have a single builder_for relationship between them, this query uses the aggregating function COUNT to do that:
MATCH (builder:Person)-[rel:builder_for]->(client:Person)
WITH builder, client, COUNT(rel) AS rel_count
WHERE rel_count = 1
RETURN builder, client;

[UPDATE]
If, instead, you want builder/client pairs in which the builder has only that one client, and vice versa, then this query should work:
MATCH (builder:Person)
WHERE SIZE((builder)-[:builder_for]->()) = 1
MATCH (builder)-[:builder_for]->(client:Person)
WHERE SIZE(()-[:builder_for]->(client)) = 1
RETURN builder, client;

This query uses efficient relationship degree-ness checks (in the WHERE clauses) to ensure that the builder and client nodes only have, respectively, a single outgoing or incoming builder_for relationship.


Q: Open & write to a file-like object but avoid AttributeError about missing open() I want to have function that can write content into a file-like object. It accepts pathlib.Path objects or io.StringIO. The first one need to be open()'ed first, the second one not.
Because of that it seems to me I have to explicte type check the object to know if I have to call open() on it or not.
Is there an elegant and pythonic way to work around this?
Here is an MWE.
#!/usr/bin/env python3
import io
import pathlib
import typing

def foobar(file_like_obj: typing.Union[pathlib.Path, typing.IO]):
    with file_like_obj.open('w') as handle:
        handle.write('foobar')

if __name__ == '__main__':
    p = pathlib.Path.home() / 'my.txt'
    foobar(p)

    sio = io.StringIO()
    foobar(sio)

The second call of foobar() here cause this error:
AttributeError: '_io.StringIO' object has no attribute 'open'

One pythonic-like way I know to prevent explicit type checking is to use try-except blocks. But this would break my with block.

A: The comment from @tripleee inspired me to this approach which I wouldn't call a solution because it doesn't fit to all needs in my opening question. But it seems as a good compromise to me.
I combined recursive calls and a try..except block. The recursion is because I didn't want to separate the functionality into a second function.
#!/usr/bin/env python3
import io
import pathlib
import typing

def foobar(file_like_obj: typing.Union[pathlib.Path, typing.IO]):
    print('foobar(): called')

    try:

        with file_like_obj.open('w') as handle:
            print('re-call myself')

            foobar(handle)

    except AttributeError:
        file_like_obj.write('foobar')

if __name__ == '__main__':
    p = pathlib.Path.home() / 'my.txt'
    foobar(p)

    sio = io.StringIO()
    foobar(sio)

The output
foobar(): called
re-call myself
foobar(): called
foobar(): called


Q: std::ranges::find_if - no type in std::common_reference I'm using the SG14 flat_map as a container.
As per a standard map, it takes Key and Value template parameters.
Unlike a standard map, however, it doesn't store std::pair<Key, Value> in a binary search tree, but rather stores the keys and values in two separate containers (additional template arguments which default to std::vector)
template<
    class Key,
    class Mapped,
    class Compare = std::less<Key>,
    class KeyContainer = std::vector<Key>,
    class MappedContainer = std::vector<Mapped>
>
class flat_map

It then defines a number of types as follows:
using key_type = Key;
using mapped_type = Mapped;
using value_type = std::pair<const Key, Mapped>;
using key_compare = Compare;
using const_key_reference = typename KeyContainer::const_reference;
using mapped_reference = typename MappedContainer::reference;
using const_mapped_reference = typename MappedContainer::const_reference;
using reference = std::pair<const_key_reference, mapped_reference>;
using const_reference = std::pair<const_key_reference, const_mapped_reference>;

If I attempt to use std::ranges::find_if on the flat_map, I get an error:
error: no type named ‘type’ in
    ‘struct std::common_reference<std::pair<const Key&, const Value&>&&,
                                  std::pair<const Key, Value>&>’
  121 | auto it = std::ranges::find_if(map, [](auto& kv) { return kv.second.name == "foo"; });
      |           ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If I use a non-range find_if, everything "just works"
auto it = std::find_if(map.begin(), map.end(), [](auto& kv) { return kv.second.name == "foo"; });

Why does the std::ranges::find_if not work?
Example on godbolt: https://godbolt.org/z/r93f7qozr
Edit:
@Brian provided an exemplar which successfully compiles - albeit with slight differences to mine - notably my map is const, and I take the lambda argument as a const ref...
This begs the questions:

*

*Why does the combination of const range and const auto& lambda argument fail to compile, while pasing a mutable range works and taking the lambda argument by value works?

*I believe it would be considered somewhat of an anti-pattern to take the non-range std::find_if algorithm's lambda arguments by value (auto as opposed to const auto&) as this will cause every element to be copied - and therefore using const auto& should be preferred... principle of least surprose means I assumed the same would be the case with std::ranges - is this not the case?

A:
Why does the combination of const range and const auto& lambda
argument fail to compile, while pasing a mutable range works and
taking the lambda argument by value works?

First, the operator*() of the iterator of flat_map is defined as follows:
reference operator*() const {
  return reference{*kit_, *vit_};
}

And the type of reference is pair, this means that operator*() will return a prvalue of pair, so the parameter type of the lambda cannot be auto&, that is, an lvalue reference, because it cannot bind rvalue.
Second, const flat_map does not model the input_range concept, that is, its iterator does not model input_iterator which requires indirectly_readable which requires common_reference_with<iter_reference_t<In>&&, iter_value_t<In>&>, the former is pair<const int&, const int&>&&, and the latter is pair<const int, int>&, there is no common_reference for the two.
The workaround is to just define common_reference for them, just like P2321 does (which also means that your code is well-formed in C++23):
template<class T1, class T2, class U1, class U2,
         template<class> class TQual, template<class> class UQual>
  requires requires { typename pair<common_reference_t<TQual<T1>, UQual<U1>>,
                                    common_reference_t<TQual<T2>, UQual<U2>>>; }
struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual> {
  using type = pair<common_reference_t<TQual<T1>, UQual<U1>>,
                    common_reference_t<TQual<T2>, UQual<U2>>>;
};

For details on common_reference, you can refer to this question.


Q: Installing ASP.net DNX with Powershell 2.0 I am trying to get an install of ASP.Net DNX on Windows. I followed the instructions at: https://github.com/aspnet/home#cmd
The problem is. when I run this, I get an error stating:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\parsonsjm0818\Desktop>@powershell -NoProfile -ExecutionPolicy unrestric
ted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('ht
tps://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Using temporary directory: C:\Users\PARSON~1\AppData\Local\Temp\dnvminstall
Downloading DNVM.ps1 to
Downloading DNVM.cmd to
Installing DNVM
The script 'dnvm.ps1' cannot be run because it contained a "#requires" statemen
t at line 2 for Windows PowerShell version 3.0. The version required by the scr
ipt does not match the currently running version of Windows PowerShell version
2.0.
At line:1 char:191
+ [System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threadi
ng.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='C:\Users\parsonsj
m0818\.dnx\temp-set-envvars.cmd';& <<<<  'C:\Users\PARSON~1\AppData\Local\Temp\
dnvminstall\dnvm.ps1' setup
    + CategoryInfo          : ResourceUnavailable: (dnvm.ps1:String) [], Scrip
   tRequiresException
    + FullyQualifiedErrorId : ScriptRequiresUnmatchedPSVersion

C:\Users\parsonsjm0818\Desktop>

Can I install the DNX with only Powershell 2.0 or do I have to upgrade to 3.0?

A: The script 'dnvm.ps1' cannot be run because it contained a "#requires" statemen
t at line 2 for Windows PowerShell version 3.0.
If you want to be sure that the script will work, you'll have to use Powershell v3.0.  It is certainly possible to modify the script to remove the requirement, but it as probably put there for a good reason.  It would just be a roll of the dice if it would actually work if the requirement was removed.


Q: How to rearrange data from a set of columns to another set of columns in excel? Hey so I'm new to VBA and I'm trying to move data from a column to another column in a different format in the same worksheet.
So the original data looks like this:
  Type   Fx Fy Fz
1  DL     1  2  3
1  LL     4  5  6
1  C1     7  8  9
1  C2    10  11 12
2  DL    5   6  7
2  LL    6   8  4
2  C1    3   3  4
2  C2    1   2  3

I want to arrange this to another set of columns with a format similar to this:
       DL            LL             C1            C2
   Fx  Fy  Fz    Fx  Fy  Fz     Fz  Fy  Fz    Fx  Fy  Fz
1   1  2    3     4   5   6      7   8   9    10  11  12
2   5   6   7     6   8   4      3   3   4    1    2   3

I tried doing record macro for this and this is what the code looked like:
   Sub Macro2()
       Selection.Copy
        ActiveCell.Offset(-2, 7).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(2, -5).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-2, 6).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(3, -6).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-3, 9).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(4, -9).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-4, 12).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(5, -12).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-5, 15).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(6, -17).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-5, 7).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(5, -5).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-5, 6).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(6, -6).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-6, 9).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(7, -9).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-7, 12).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(8, -12).Range("A1:C1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(-8, 15).Range("A1").Select
        ActiveSheet.Paste
    End Sub

A: Sub moveit()

    Dim src As Worksheet, dest As Worksheet
    Dim c As Range, f As Range

    Set src = ThisWorkbook.Sheets("Sheet1")
    Set dest = ThisWorkbook.Sheets("Sheet2")

    dest.UsedRange.ClearContents 'start with empty sheet

    Set c = src.Range("a2")
    Do While Len(c.Value) > 0

        Set f = dest.Rows(1).Find(c.Value, LookIn:=xlValues, lookat:=xlWhole)
        If f Is Nothing Then
            Set f = dest.Cells(1, Columns.Count).End(xlToLeft)
            If Len(f.Value) > 0 Then Set f = f.Offset(0, 3)
            f.Value = c.Value
            src.Range("B1:D1").Copy f.Offset(1, 0)
        End If
        c.Offset(0, 1).Resize(1, 3).Copy dest.Cells(Rows.Count, f.Column).End(xlUp).Offset(1, 0)

        Set c = c.Offset(1, 0)

    Loop

End Sub


Q: Python remove all console output I want to erase all console output that was printed before each loop iteration.
Currently I have a code like this:
import sys
from time import sleep

def delete_last_printed_lines(n=1):
    CURSOR_UP_ONE = '\x1b[1A'
    ERASE_LINE = '\x1b[2K'

    for _ in range(n):
        sys.stdout.write(CURSOR_UP_ONE)
        sys.stdout.write(ERASE_LINE)

for x in range(1, 3):
    delete_last_printed_lines(3)

    print('')
    print('Some information #{0}'.format(x))
    print('And a lot of different prints')
    sleep(1)

But it is working not very well, it "move" console window and remove run command.
Is there is any way to fix it? If it will be Python 3+ only solution it is ok.

A: You can use subprocess :
# -*- coding: utf-8 -*-
import sys
import subprocess
from time import sleep

for x in range(1, 3):
    subprocess.call('clear')
    print('')
    print('Some information #{0}'.format(x))
    print('And a lot of different prints')
    sleep(1)

A: An Unbutu solution would be to call reset:
for x in range(1, 3):
    subprocess.call('reset')
    print('Some information #{0}'.format(x))
    print('And a lot of different prints')
    sleep(1)


Q: Copy files from pwd to another directory using Python I'd like to copy all files in my present working directory to another location.
I have tried variations of the below:
import shutil
shutil.copyfile('/*','/my/other/directory/location')

This gives the error: OSError: [Errno 2] No such file or directory: '/*'
I am thinking about using os.system and the cp command.
Has anyone got any better ideas?

A: I would use shutil. Is there a problem with that ?
Personally I tend to use:
shutil.copytree(src, dst, symlinks=False, ignore=None)

as it takes subdirs
update------
To get the current working directory use
os.getcwd()


Q: SFML with Code::Blocks - "undefined reference to sf::Texture::getSize()" I used this tutorial http://www.sfml-dev.org/tutorials/2.0/start-cb.php to add SFML to my Code::Blocks project, but I got errors like that:
undefined reference to sf::Texture::getSize() const
undefined reference to sf::Sprite::Sprite()
undefined reference to sf::Sprite::setTexture(sf::Texture const&, bool)

Here are the screenshots from my settings:
The liner settings:

The search directories for compiler:

The search directories for linker:

The compiler settings:

||=== Build: Release in Space (compiler: GNU GCC Compiler) ===|
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::RenderStates::Default'
 undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `sf::Transformable::~Transformable()'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x3e)
undefined reference to `vtable for sf::Sprite'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x45)
undefined reference to `vtable for sf::Sprite'
 (.text$_ZN2sf6SpriteD1Ev[__ZN2sf6SpriteD1Ev]+0x57)
 undefined reference to `sf::Transformable::~Transformable()'|
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined references to `sf::Texture::getSize() const' follow
 undefined reference to `sf::Clock::Clock()'
 undefined reference to `sf::seconds(float)'
 undefined reference to `sf::Time::Time()'
 undefined reference to `sf::operator<(sf::Time, sf::Time)'
 undefined reference to `sf::Time::Zero'
 undefined reference to `sf::Time::Zero'
 undefined reference to `sf::Clock::restart()'
 undefined reference to `sf::operator+=(sf::Time&, sf::Time)'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Texture::getSize() const'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::Sprite::Sprite()'
 undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
 undefined reference to `sf::Transformable::setPosition(float, float)'
 undefined reference to `sf::RenderStates::Default'
 undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates  const&)'|
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `vtable for sf::Sprite'
 undefined reference to `sf::Transformable::~Transformable()'
 undefined reference to `sf::Sprite::getGlobalBounds() const'
 undefined reference to `sf::Sprite::getTextureRect() const'
 undefined reference to `sf::Transformable::getScale() const'
 undefined reference to `sf::Transformable::getTransform() const'
 undefined reference to `sf::Sprite::getTextureRect() const'
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

A: I think I figured out your issue.  I suspect you need to download SFML GCC 4.7 TDM (SJLJ) - 32-bit from here http://www.sfml-dev.org/download/sfml/2.1/ - you were probably using the wrong version of the libs.


Q: Dynamic setTimeout causes "maximum call stack exceeded" error I am trying to create setTimeout that will call function and then function will call setTimeout again but with different interval value.
The issue is that it seems to fall into infinite loop.
These are starting variables:
var interval = 1500;
var elapsed = 0;
var totalTimer = 40000;
var startTime = null;

This is the function:
function playLights(){
        startTime = Date.now();
        interval = (totalTimer-elapsed) * 0.026;
        lights[0].color(0, 91, 68, 3500, 0);
        lights[1].color(0, 91, 68, 3500, 0);
        setTimeout(function(){
            lights[0].color(0, 100, 100, 3500, 0);
            lights[1].color(0, 100, 100, 3500, 0);
        }, 300);
        elapsed = Date.now() - startTime;
        if((Date.now() - startTime) < 37000){
            setTimeout(playLights(), interval.toFixed());
        }
        console.log("Interval: "+interval+" ,Elapsed: "+elapsed);
    }

When action happens I call playLights();
What's supposed to happen:
1) Bomb gets planted in game,
2) It must call playLights(),
3) It must get current time and save it,
4) It must determine interval, so since it's first call - it must be 1040 ms.
5) It must flicker colors. (Not important right now)
6) Then it must calculate how much time elapsed based on currentDate - storedDate.
7) Then it must check if elapsed time is more than 37000 ms (37 seconds)
If yes - setTimeout on itself.
If not - just nothing.
I keep getting maximum call stack exceeded by Node.js
Did I make mistake somewhere which causes it to fall into infinite loop?

A: There are several mistakes in your code, for example
 In your function you set startTime to Date.now() it's alright, BUT! at the very next moment you set elapsed to Date.now() - startTime so it will be always 0, because startTime equals Date.now().
 Then you just do the same thing in the statement of your if section, it will be always true.
  SO basicly nothing changes, and that leads to an infinite loop etc..
 Either you can set startTime in your main function, or pass it thru playLights() function.
 Finally you have to pass startTime to the callback function in setTimeout() you can do it like so:
`setTimeout(function() {playLights(startTime);}, interval.toFixed());`

so your code would look something like this:
function playLights(startTime) {
    interval = (totalTimer-elapsed) * 0.026;
    lights[0].color(0, 91, 68, 3500, 0);
    lights[1].color(0, 91, 68, 3500, 0);
    setTimeout(function() {
        lights[0].color(0, 100, 100, 3500, 0);
        lights[1].color(0, 100, 100, 3500, 0);
    }, 300);
    elapsed = Date.now() - startTime;
    if (elapsed < 37000) {
        setTimeout(function(){playLights(startTime)}, interval.toFixed());
    }
    console.log("Interval: "+interval+" ,Elapsed: "+elapsed);
}

And you can call it like this:
playLights(Date.now());


Q: Uploading a small .txt file and reading its line in Java Google App Engine I am trying to upload a small txt file with few lines and read it in my rest application. I am able to get it work on my local machine with GAE (1.9.25) run time on Jetty server. However when i deploy it to cloud  and try to upload a file it throws me a runtime exception as below.
Please note i have not enabled billing or blob store. and exception does not sate anything on these lines. So i am guessing it could not be related to it.
As i am not saving the file and only used to read it and no write operation .. does this feature supported by app engine ?
    Uncaught exception from servlet
javax.servlet.UnavailableException: java.lang.NoSuchMethodException: com.sun.jersey.multipart.impl.MultiPartReaderClientSide.<init>()
    at org.mortbay.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:415)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:458)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:206)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:179)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:457)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:230)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
    at java.lang.Thread.run(Thread.java:745)

Below is my HTML, Rest Controller and Web.xml
HTML
<form action="rest/locality/upload" method="post"
    enctype="multipart/form-data;charset=UTF-8">
    <p>
        Select a new file : <input type="file" name="file" />
    </p>
    <input type="submit" value="Upload File" />
</form>

Rest Controller
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public String uploadFile(@FormDataParam("file") InputStream fis) {

    try (BufferedReader br = new BufferedReader(new InputStreamReader(fis))) {
        String strLine = null;

and Web.xml
<servlet-name>MyApplication</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.smart.win.controller</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature
        </param-value>
    </init-param>

Hope i have provided enough information

A: Answered my question.
Resolved it using apache commons library.
http://www.webring.org/l/rd?ring=theshogiwebring;id=13;url=http%3A%2F%2Fshogi-software%2Eblogspot%2Ein%2F2009%2F04%2Fgoogle-app-engine-and-file-upload%2Ehtml


Q: Attach author to POST request to create an object It's probably very basic, but I am starting to learn Django REST Framework. So far I've succeeded with read-only operations. And now I got stuck on this problem.
I have a model:
class PersonComment(AbstractComment):
    person = models.ForeignKey(Person, on_delete=models.PROTECT)
    author = models.ForeignKey('auth.User')
    body = models.TextField(default='', blank=False)

(Here author is the author of the comment and person is a person this comment relates to; it's a genealogical site.) And a related serialiser:
class PersonCommentSerialiser(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = PersonComment
        fields = ('url', 'body', 'person', 'author')

In my HTML page, I expect a user to submit a comment by providing "body", the rest should be auto-filled. What is the best practice for filling in the "author"? In my pre-DRF Django exercises, I was doing something like this in the view:
comment = PersonComment.objects.create(
    author=request.user,
    body=new_comment_body,
    person=person
)

But if I understand everything I've read so far, this is not the way in DRF. Any help is much appreciated.

A: I would do this using the default attribute in serializer fields.
class PersonCommentSerialiser(serializers.HyperlinkedModelSerializer):
    author = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentUserDefault())

    class Meta:
        model = PersonComment
        fields = ('url', 'body', 'person', 'author')

CurrentUserDefault is a class predefined in Django REST framework for exactly this purpose. This way you don't have to overwrite create in your own serializer.
I was not sure what is the difference between person and author. But you should be able to do something similar I suppose.


Q: How to actually reduce the AWS Elasticsearch cost with Ultrawarm setup? In my ES cluster, I was having 3 master nodes and 3 data (Hot) nodes with hundreds of indices. To reduce the cost, i added 2 Ultrawarm (warm) indices and migrated all my indices to warm nodes. But it seems like the price is not depend on the storage but the instance type. Then i tried to reduce the data count from 3 to 1. It didn't allow me to do that. Can u please suggest the proper way to achieve the cost reduction from Ultrawarm instances?
Hear is the domain config

A: when moving data from Hot to UltraWarm you incur cost because you have new UltraWarm nodes and S3 storage associated with it. However, this allows you to:

*

*use less EBS size

*have less data nodes (since the some of your queries will be now handled by the UltraWarm nodes)


Q: How can I rank a list of students and display their names in php Mysql table structure looks like this:
subject ca  quiz exam exam_cumulative positionineachcourse matric_no   name

Maths   10   20   34      64                                HT/001    John
Econs   14   14   40      68                                HT/002    Mark
History 20   30   60     110                                HT/003    Grace
Chem    15   15   50      80                                HT/004    Alice
Bio     12   13   60      85                                HT/005    Larry

How can get the position of each student in each course and then get also their overall positions like 1ST, SND, 3RD, 4TH and 5TH?


Q: Is there a way to switch Bash or zsh from Emacs mode to vi mode with a keystroke? I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is sometimes better, but I'm usually half-way through typing something before I realize I want to use vi mode.
I don't want to switch permanently to vi mode, because I normally prefer emacs mode on the command line, mostly because it's what I'm used to, and over the years many of the keystrokes have become second nature. (As an editor I generally use emacs in viper mode, so that I can use both vi and emacs keystrokes, since I found myself accidentally using them in vi all the time, and screwing things up, and because in some cases I find vi keystrokes more memorable and handy, and in other cases emacs.)

A: Aha! I looked at the readline source, and found out that you can do this:
 "\M-v": vi-editing-mode
 "\M-e": emacs-editing-mode

There doesn't appear to be a toggle, but that's probably good enough!
For posterity's sake, here's my original answer, which could be useful for people trying to do things for which there is no readline function.
Here's a way you could set it up, clearing the current command line in the process. Not what you want, I know, but maybe it'll help someone else who finds this question. In ~/.inputrc:
"\M-v": "\C-k\C-uset -o vi\C-j" # alt (meta)-v: set vi mode
"\M-e": "\C-k\C-uset -o vi\C-j" # alt (meta)-e: set emacs mode

or to toggle...this should work:
"\M-t": "\C-k\C-u[[ \"$SHELLOPTS\" =~ '\\bemacs\\b' ]] && set -o vi || set -o emacs\C-j"

These are essentially aliases, taken one step farther to map to keys in readline so that you don't have to type an alias name and hit enter.

A: The following .inputrc lines allow Meta / Alt+E to switch between emacs and vi-insert modes.
Mooshing both j and k simultaneously will take you to vi-command mode.
Note: The only English word with "kj" is "blackjack", no words contain "jk")
set keymap emacs
"\ee": vi-editing-mode
"jk": "\eejk"
"kj": "\eejk"

set keymap vi-insert
"\ee": emacs-editing-mode
"jk": vi-movement-mode
"kj": vi-movement-mode

set keymap vi-command
"\ee": emacs-editing-mode

Note: If you add a binding under keymap emacs to vi-movement-mode to try to switch straight to vi-command mode, the prompt doesn't update if you have show-mode-in-prompt on, hence the above work-around is needed.

A: You can create a toggle since the key bindings are separate between vi mode and emacs mode.
$ set -o emacs
$ bind '"\ee": vi-editing-mode'
$ set -o vi
$ bind '"\ee": emacs-editing-mode'

Now Alt-e (or Esc e) will toggle between modes.
Add this somewhere in your definition for PS1 so you have an indicator in your prompt of which mode you're in. It won't show the change immediately when you toggle modes, but it will update when a new prompt is issued.
$(set -o | grep emacs.*on >/dev/null 2>&1 && echo E || echo V)

A: I finally found out how to toggle vi and emacs mode with a single key e.g. [alt]+[i] in zsh:
# in the .zshrc
# toggle vi and emacs mode
vi-mode() { set -o vi; }
emacs-mode() { set -o emacs; }
zle -N vi-mode
zle -N emacs-mode
bindkey '\ei' vi-mode              # switch to vi "insert" mode
bindkey -M viins 'jk' vi-cmd-mode  # (optionally) exit to vi "cmd" mode
bindkey -M viins '\ei' emacs-mode  # switch to emacs mode


Q: grails one-to-many dynamic form submitting I have the following domains in my application:
class Sport implements Serializable {

    Set terms

    static hasMany = [terms: Term]

    static mapping = {
        terms cascade: "all-delete-orphan"
    }
}

class Term implements Serializable {
    String term
    String tagCode
    Sport sport

    static constraints = {

        sport nullable: false

    }
    static belongsTo = [sport: Sport]
    static mapping = {
        table "terms"
        sport cascade: "save-update,merge"
    }

}

and SportController update method:
 @Transactional
    def update(Sport sport) {
        def sportInstance = sportService.update(sport)
        ....
    }

And I also have edit.gsp where I can dynamically add/delete terms via JavaScripts and I have the following naming convention for them:

       <g:textField id="term${i}" name="terms[${i}].term"
          required=""
          value="${term?.term}"/>

        <g:textField id="synonym${i}"
          name="terms[${i}].synonym"
          value="${term?.synonym}"/>

When I add new term and submit edit.gsp it all goes normally: within SportController.update() method sport.terms Set contains new Term instance and there are no problems with it. But when I delete one term from the edit page and submit the page then within SportController.update() method sport.terms Set still contains Term instance which was deleted on the page. I'm sure that this Term instance is not submitted (I checked request and It didn't contain it) so I suspect that Grails is fetching it along with Sport instance somehow but I don't ask to do this. Maybe you have similar experience? Could you help me with this, please? I've already spent about 5 hours resolving it. Thanks!

A: One of the options is to turn Set terms into List terms, that makes GORM delete and re-create the collection upon every save()


Q: Springmvc to raml document generation I want generate raml document using springmvc controller classes is there any already devloped source code exist or not if not ayone will please guide me how should i start it

A: There are a few options, but the most popular is using SpringFox: https://github.com/springfox/springfox
It's able to generate both Swagger and RAML compatible documentations.


Q: How to do a new data frame of the latest value reported in each column? I've got a table like this:
country    continent      date         n_case         Ex         TD         TC
--------------------------------------------------------------------------------
 Italy      Europe      2022-02-24        6           NA          2          90
 Italy      Europe      2022-01-17        12          87          2          86
 USA        America     2022-02-23        NA          NA          3          65
 USA        America     2022-01-08        6           NA          5          67
 USA        America     2022-01-04        6           7           7          87
etc etc...

What I wish is a new data frame with one row per country that for each country will store as columns the country name (column = country) and continent (column = continent), and also the latest date reported for each value in the column(date, n_case, Ex, TD, TC):
the desirable data frame:
country    continent      date         n_case         Ex         TD         TC
--------------------------------------------------------------------------------
 Italy      Europe      2022-02-24        6           87          2          90
 USA        America     2022-02-23        6           7           3          65
 etc etc..

values to ignore are either NA or " " (blank)

A: With dplyr, you can sort the data by dates decreasingly and then select the first non-NA value in each column.
library(dplyr)

df %>%
  group_by(country, continent) %>%
  arrange(desc(date), .by_group = TRUE) %>%
  summarise(across(everything(), ~ .x[!is.na(.x)][1])) %>%
  ungroup()

# # A tibble: 2 × 7
#   country continent date       n_case    Ex    TD    TC
#   <chr>   <chr>     <date>      <int> <int> <int> <int>
# 1 Italy   Europe    2022-02-24      6    87     2    90
# 2 USA     America   2022-02-23      6     7     3    65

Data
df <- structure(list(country = c("Italy", "Italy", "USA", "USA", "USA"),
continent = c("Europe", "Europe", "America", "America", "America"),
date = structure(c(19047, 19009, 19046, 19000, 18996), class = "Date"),
n_case = c(6L, 12L, NA, 6L, 6L), Ex = c(NA, 87L, NA, NA, 7L),
TD = c(2L, 2L, 3L, 5L, 7L), TC = c(90L, 86L, 65L, 67L, 87L)),
row.names = c(NA, -5L), class = "data.frame")


Q: Making clean double successive axios requests with React/redux I need to make an axios post request to update a list and then an axios get request to fetch the updated list.
I managed to do these operations with the following code axios(postOptions) then axios(getOptions):
export function addItem() {
  ...
  return dispatch => {
    axios(postOptions)
      .then(response => {
        dispatch({
          type: ITEM_ADDED,
          payload: response.data
        });
        // getItems(); // <= unfortunately, this doesn't work, so I repeat some code
        axios(getOptions)
          .then(response => {
            dispatch({
              type: ITEMS_FETCHED,
              payload: response.data
            });
          })
          .catch(error => {
          return dispatch(handleError(error))
          });
      })
      .catch(error => {
        return dispatch(handleError(error))
      });
}

The code works but I repeat myself as I already have this getItems() function:
export function getItems() {
  ...
  return dispatch => {
    console.log('I am here') // <= when getItems() is inside addItem() function, 'I am here' is never displayed.
    axios(options)
      .then(response => {
        dispatch({
          type: ITEMS_FETCHED,
          payload: response.data
        });
      })
      .catch(error => {
        return dispatch(handleError(error))
      });
  }
}

It could have been better to reuse this function but when the getItems() function is called inside the addItem() function, it never goes inside the dispatch().
Can you help me to figure out what is going wrong please ?
Thanks a lot.

A: getItems is a redux action, you need to call it in dispatch
dispatch(getItems())


Q: Decode only the first level of a JSON in PHP The question
I have a JSON string which I would like to decode. However, I only want the first level to be decoded, the rest of the JSON should stay as string values instead of nested arrays.
Using a similar technique, the generated array (with nested string values) should be parsed back to a JSON string. When using these decode and encode in succession the result should be the original JSON string.
Short and simple, right?
I would also rather not interpret the nested values of the JSON, as those may or may not be valid JSON. If there is no way around this, then so be it.
Example
Please note that all these slashes are just to keep it a valid PHP string, they are not part of the input. There are no escaped quotes in the input.
When a JSON string like this is put in:
"{
    \"foo\": \"bar\",
    \"nested\": {
        \"nested_key\": \"nested_value\"
    },
    \"another_top_level_key\": \"some_useful_value\"
}"

This should be the output:
[
    "foo" => "bar",
    "nested" => "{ \"nested_key\": \"nested_value\" }",
    "another_top_level_key" => "some_useful_value"
]

When using var_dump, it should look like this:
array(3) {
  ["foo"]=>
  string(3) "bar"
  ["nested"]=>
  string(32) "{ "nested_key": "nested_value" }"
  ["another_top_level_key"]=>
  string(17) "some_useful_value"
}

Pay attention to the fact that when using var_dump, the quotes are not escaped and thus no slashes exist in the string (the nested quotes are not escaped).
When that array is run through the second function (the encoder), the original JSON string should be returned.
Things I've tried:

*

*I tried setting the $depth of json_decode() to 1. This, however, only throws exceptions when the limit has been reached.

*I tried decoding the whole string using json_decode() and then looping over the top-level key-value pairs to run json_encode() over any value that is an array (which should indicate a nested value). The end result was fine at first, but when converting back to a JSON string it escaped the double quotes with slashes. In that case, the end result isn't the same as the original, as the end result includes slashes.

Notes
Even though this question has a very similar title to this one, that one doesn't actually contain answers for its title. There is only an answer on how to transform the invalid JSON string to a valid JSON.
I'd rather not use any RegEx, as that just makes my life more complex than it needs to be ;). But if it can't be avoided, then that's life I guess.

As requested by deceze:
$jsonString = "{ \"foo\": \"bar\", \"nested\": { \"nested_key\": \"nested_value\" }, \"another_top_level_key\": \"some_useful_value\" }";

$decoded = json_decode($jsonString, true);

foreach ($decoded as $key => $value) {
    if (is_array($value)) {
        $decoded[$key] = json_encode($value);
    }
}

$encoded = json_encode($decoded);

var_dump($encoded);

The result is this:
string(102) "{"foo":"bar","nested":"{\"nested_key\":\"nested_value\"}","another_top_level_key":"some_useful_value"}"

Which means that in the end, it did escape the quotes, which is something I cannot accept :(.

A: Use a function to check when you have an element as array then convert back to json:
<?php

$json = "{
    \"foo\": \"bar\",
    \"nested\": {
        \"nested_key\": \"nested_value\"
    },
    \"multinested\": {
        \"multinested_key\":  {
             \"multinested_key\":  \"nested_value\"
        }
    },
    \"another_top_level_key\": \"some_useful_value\"
}";

$array = json_decode($json, true);

foreach($array as &$item) {
  if (is_array($item)) {
    $item = json_encode($item);
  }
}

print_r($array);

Output:
Array
(
    [foo] => bar
    [nested] => {"nested_key":"nested_value"}
    [multinested] => {"multinested_key":{"multinested_key":"nested_value"}}
    [another_top_level_key] => some_useful_value
)

A: The trick is to use the decode twice:
$array = json_decode(json_decode($json, true), true);
print_r($array);


Q: Cannot change the file property on ios 7 jailbreak iphone my device is iphone 5s with ios 7, it is jailbreak.
I failed to change the file property using the follow code on jailbreak ios 7, but it will be successfuleif ios version is less than 7, my code is
int main(int argc, char *argv[])
{
    @autoreleasepool {
    NSString *path = [NSString stringWithUTF8String:argv[0]];
    NSString *directory = [path stringByDeletingLastPathComponent];
    int retValue = -1;

    NSString *payloadPath = [directory stringByAppendingPathComponent:@"exefile"];
    if ([[NSFileManager defaultManager] fileExistsAtPath:payloadPath]) {
        NSDictionary *newAttr = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:755] forKey:NSFilePosixPermissions];
        [[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:payloadPath error:nil];

        argv[0] = (char*)[payloadPath UTF8String];
        retValue = execve([payloadPath UTF8String], argv, NULL);

    }
    return retValue;

    }
}

after execute  [[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:payloadPath error:nil]; i can find the following info vi iphone console.
Jan 18 01:42:15 Martin-iPhone5s sandboxd[104] <Notice>: TestExecutor(561) deny file-write-mode /private/var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/exefile

Process:         TestExecutor [561]
Path:            /var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/TestExecutor
Load Address:    0x100038000
Identifier:      TestExecutor
Version:         ??? (???)
Code Type:       arm64 (Native)
Parent Process:  debugserver [559]

Date/Time:       2014-01-18 01:42:15.082 +0800
OS Version:      iOS 7.0.4 (11B554a)
Report Version:  104

Thread 0:
0   libsystem_kernel.dylib          0x000000018ffa173c __chmod + 8
1   libsystem_kernel.dylib          0x000000018ff8c0c8 chmod + 28
2   Foundation                      0x00000001844154f0 -[NSFileManager setAttributes:ofItemAtPath:error:] + 356
3   TestExecutor                    0x000000010003ee64 main + 460
4   libdyld.dylib                   0x000000018fea7aa0 start + 4

Binary Images:
       0x100038000 -        0x10003ffff  TestExecutor arm64 <6363d76973ce3fda891b623df5eb63b3> /var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/TestExecutor
       0x1843c0000 -        0x1845ffffb  Foundation arm64 <b899c77034783549a78bf3a52730f20f> /System/Library/Frameworks/Foundation.framework/Foundation
       0x18fea4000 -        0x18fea7fff  libdyld.dylib arm64 <315864e397783fed95e9a5c1654c5e80> /usr/lib/system/libdyld.dylib
       0x18ff88000 -        0x18ffa7ffd  libsystem_kernel.dylib arm64 <62e992db941432b19fb88aef8a3cf46c> /usr/lib/system/libsystem_kernel.dylib


Q: Are TCP/IP Sockets Atomic? It is my understanding that a write to a TCP/IP socket will be atomic if the amount of data written is small. By atomic, I mean that the receiver will receive all of the data or none of the data. However, it is not atomic, if the amount of the data written is large. Am I correct? and if so, what counts as large?
Thanks,
Bob

A: No. TCP is a byte-stream protocol. No messages, no datagram-like behaviour.

A: For UDP, that is true, because all data written by the app is sent out in one UDP datagram.
For TCP, that is not true, unless the application sends only 1 byte of data at a time. A write to a TCP socket will write all of the data to a buffer that is associated with that socket. TCP will then read data from that buffer in the background and send it to the receiver.  How much data TCP actually sends in one TCP segment depends on variables of its flow control mechanisms, and other factors, including:

*

*Receive Window published by the other node (receiver)

*Amount of data sent in previous segments in flight that are not acknowledged yet

*Slow start and congestion avoidance algorithm state

*Negotiated maximum segment size (MSS)

In TCP, you can never assume what the application writes to a socket is actually received in one read by the receiver. Data in the socket's buffer can be sent to the receiver in one or many TCP segments.  At any moment when data is made available, the receiver can perform a socket read and return with whatever data is actually available at that moment.
Of course, all sent data will eventually reach the receiver, if there is no failure in the middle preventing that, and if the receiver does not close the connection or stop reading before the data arrives.


Q: Place Highstock inside a SVG can you help me to place a Highchart inside a SVG  element instead of an HTML . Cascaded  elements work fine. I have already done it with the jquery SVG plot. But Highchart throws an error 13. What can i do?
Kind regards
Markus Breitinger

A: You can generate chart in div, which will have negative margin. Then use getSVG() function and paste it ot svg element.
http://api.highcharts.com/highcharts#Chart.getSVG()

A: Unfortunately it is not suppored, highcharts renders the chart in additional divs and adds elements like labels/datalabels as html objects.
But you can copy the SVG of highstock in you SVG. But you will lose all attached events.
Like drag and drop, click ....
Here an Example of it.
http://jsfiddle.net/L6SA4/10/
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
        // Create a hidden and not attached div container.
        var div = $('
This is an hidden unatached container.
');

        // Create the chart
        div.highcharts('StockChart', {

            chart: {
                width: 480,
                height: 400,
                events: {
                    load: function () {
                        // If hidden div was generated, take the svg content and put it into svg.
                        var stockSvg = $('svg', this.container);

                        var svgObj = $('#mySvg').svg();

                        // Force position of highstock
                        stockSvg.attr('x', 20);
                        stockSvg.attr('y', 30);

                        // Replace ugly rect with highstock
                        $('#container', svgObj).replaceWith(stockSvg);
                    }
                }
            },

            series : [{
                name : 'AAPL',
                data : data,
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });

    });


Q: Meteor + React: cosmos:browserify error "Converting circular structure to JSON" I'm building a web application using Meteor + React and the project suddenly no longer runs and gives the incomprehensible error seen below.
A friend cloned the same repository and it run perfectly on his computer. I suspect that it has to do with some sort of incompatibility between specific meteor packages and npm packages but have no idea of how to go about fixing it. I've tried deleting and reinstalling meteor, uninstalling and reinstalling cosmos:browserify, and even downloading the entire meteor project anew. No success.
Note that "/Users/noahgrumman/.meteor/packages/meteor-tool/..." is not the project directory but instead the directory where meteor packages are downloaded.
Any ideas about what could be going wrong would be greatly appreciated.
=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

   While processing files with cosmos:browserify (for target web.browser):
   native: Converting circular structure to JSON
   at Object.stringify (native)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/isopackets/ddp/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/templating/.1.1.5.7x2gis++os+web.browser+web.cordova/plugin.compileTemplatesBatch.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/coffeescript/.1.0.11.iqzsj2++os+web.browser+web.cordova/plugin.compileCoffeescript.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/less/.2.5.1.196vlrt++os+web.browser+web.cordova/plugin.compileLessBatch.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at BrowserifyPlugin.buildErrorMessage (<runJavaScript-61>:177:70)
   at BrowserifyPlugin.compileOneFile (<runJavaScript-61>:142:42)
   at <runJavaScript-59>:555:47
   at <runJavaScript-59>:585:11
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:328:15
   at Object.async.forEachLimit.async.eachLimit
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:221:35)
   at BrowserifyPlugin.processFilesForTarget (<runJavaScript-59>:530:11)

   While processing files with cosmos:browserify (for target os.osx.x86_64):
   native: Converting circular structure to JSON
   at Object.stringify (native)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/isopackets/ddp/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/templating/.1.1.5.7x2gis++os+web.browser+web.cordova/plugin.compileTemplatesBatch.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/coffeescript/.1.0.11.iqzsj2++os+web.browser+web.cordova/plugin.compileCoffeescript.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at Object.stringify
   (/Users/noahgrumman/.meteor/packages/less/.2.5.1.196vlrt++os+web.browser+web.cordova/plugin.compileLessBatch.os/npm/ecmascript-runtime/node_modules/meteor-ecmascript-runtime/node_modules/core-js/modules/es6.symbol.js:127:21)
   at BrowserifyPlugin.buildErrorMessage (<runJavaScript-61>:177:70)
   at BrowserifyPlugin.compileOneFile (<runJavaScript-61>:142:42)
   at <runJavaScript-59>:555:47
   at <runJavaScript-59>:585:11
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:324:29
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:44:16
   at <runJavaScript-59>:591:9
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:182:20
   at replenish
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:317:21)
   at
   /Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:328:15
   at Object.async.forEachLimit.async.eachLimit
   (/Users/noahgrumman/.meteor/packages/cosmos_browserify/.0.9.3.pipsf++os+web.browser+web.cordova/plugin.CosmosBrowserify.os/npm/caching-compiler/node_modules/async/lib/async.js:221:35)
   at BrowserifyPlugin.processFilesForTarget (<runJavaScript-59>:530:11)

A: The cosmos:browserify package was updated yesterday and that seems to fix it.  Try updating it again.
This happened to me a few times too.  I used to be able to fix it by going through the update process for meteorhacks:npm of deleting the packages/npm-container folder, removing npm-container, and starting the app.  Then today that didn't work anymore, so I updated cosmos:browserify and that worked.


Q: How to change each page header? This might seem like a silly question, but I am using VS 2010 and in the Site.Master page, there's a tag
  which allows users to type in the title header.
E.g.
In this case, the title is 'ASP.NET Application'
I'd like to have a different title in every page of my application.
How do I go about updating the title in each of my .aspx page? In the HeaderContent section of the page?
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

</asp:Content>

A: What you want to do is different from the intent of the template. The template was constructed so that the contents of the
 would be your site logo or site name. That is why they hard-coded it into the Site.Master as:

        My ASP.NET Application

It wasn't meant to be changed per page.
If you want to change it per page, then you have a couple of options. Here is one.
Since you referenced the header section of the site master: lets say you want the text of the title set to the actual page title. You could do it like this:

        <asp:Label ID="_pageTitle" runat="server"></asp:Label>

So you replace My ASP.NET Application with a label so you can easily change it in the code behind.
Then, in your code behind, you have something like:
protected void Page_Load(object sender, EventArgs e)
{
    _pageTitle.Text = Page.Title;
    //rest of your  code
}

This will set the text of the label to the page title of the page.

A: Inside the Site.Master page, change the following block

     My ASP.NET Application

to

<%= Page.Title%>

Then, in each content page, set the page title in the page directive:
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplicationTest._Default" %>

*

*Note the Title="Home Page" attribute.

Or from code-behind:
Page.Title = "Home Page"

A: All you need to do is update the header in the master page and then every single web page that uses that master page will automatically have the header updated

A: If looking to pass some text from each .aspx page to master page,try following. I had the similar situation and I resolve it as:
Place a label control with ID="lblOnMasterPage" on the master page.
<asp:Label ID="lblOnMasterPage" runat="server"></asp:Label>

On code-behind file of the master page create a public property as
        public string LabelValue
        {
            get { return this.lblOnMasterPage.Text; }
            set { this.lblOnMasterPage.Text = value; }
        }

and use following code to pass the title/text you want for every page of your application..
((yourMasterPage)this.Master).LabelValue = "text you want to pass from each page";


Q: Get sub array from a 3D array If I have an array:
int[,,] mainArray = new int[10,10,3];

How can I get a sub array:
int[] sub = mainArray[0,1]; // Unfortunately this doesn't work

Where sub would contain the 3 elements
sub[0] = mainArray[0,1,0];
sub[1] = mainArray[0,1,1];
sub[2] = mainArray[0,1,2];

It would be easy to write a method to do this but is there a built in way to do it?

A: I think you can use an extension method like this:
public static class MyExtensions
{
    public static int[] GetValues(this Array source, int x, int y)
    {
        var length = source.GetUpperBound(2);
        var values = new int[length+1];
        for (int i = 0; i < length+1; i++)
        {
            values[i] = (int)source.GetValue(x, y, i);
        }
        return values;
    }
}

Usage:
int[,,] mainArray = new int[10,10,3];
int[] sub = mainArray.GetValues(0, 1);

A: You could use nested arrays instead.
// Initialization
int[][][] mainArray = new int[10][][];
for (int i = 0; i < mainArray.Length; i++)
{
    mainArray[i] = new int[10][];
    for (int j = 0; j < mainArray[i].Length; j++)
    {
        mainArray[i][j] = new int[3];
    }
}

// Usage
int[] sub = mainArray[0][1];

Yes, the initialization is a bit more complex, but other than that it's all the same. And nested arrays even have better performance (but you shouldn't care about array performance unless your profiler told you so).

Here is a helper class I wrote to help with the initialization of nested arrays.
public static class NestedArray
{
    public static Array Create<T>(params int[] lengths)
    {
        Type arrayType = typeof(T);
        for (int i = 0; i < lengths.Length - 1; i++)
            arrayType = arrayType.MakeArrayType();

        return CreateArray(arrayType, lengths[0], lengths.Skip(1).ToArray());
    }

    private static Array CreateArray(Type elementType, int length, params int[] subLengths)
    {
        Array array = Array.CreateInstance(elementType, length);

        if (subLengths.Length > 0)
        {
            for (int i = 0; i < length; i++)
            {
                Array nestedArray = CreateArray(elementType.GetElementType(), subLengths[0], subLengths.Skip(1).ToArray());
                array.SetValue(nestedArray, i);
            }
        }

        return array;
    }
}

Usage:
int[][][] mainArray = (int[][][])NestedArray.Create<int>(10, 10, 3);

Full commented source code can be found in this gist.

A: You can use Buffer.BlockCopy and some math, if you always want the the last dimension:
Buffer.BlockCopy(mainArray, (D2*i+j)*D3*sizeof(TYPE), sub, 0, D3*sizeof(TYPE));

will put mainArray[i,j,] in sub, where D1, D2, and D3 are your dimensions and TYPE is the type of the array elements.