text:
Q: WHERE IN clause in SqlServer with Millions of parameters - C# Q: I need to pass Millions of parameters in WHERE IN clause, below is the scenario mentioned:
I've two database servers SourceDB-server & DestinationDB-server,
I need to Sync data from SourceDB TO DestinationDB, so I'm generating query dynamically through C# code, final query is mentioned below:
SelectQuery = "SELECT
[tbltest01details].[testdetailsid],
[tbltest01details].[name],
[tbltest01details].[testid]
FROM
    [SourceServer].[SourceDB].[dbo]. [tbltest01details]  with (nolock)
    WHERE
    (
        [tbltest01details].[testid]
        IN
        (1,2,3.,.,.,......,80-million)
    )";

WHERE IN Clause can be GUID OR Integer.
Above query will be executed on SourceServer through below method:
GetData(SourceConnectionString, SelectQuery, SourceTimeOut);

I've only Read-Access on SourceDB-Server, ie., I can only use SELECT query to get data from server.
NOTE: Some may suggest using TEMPORARY table, but I cannot make TEMPORARY table on SourceDB-Server. Because I've only READ-Access on SourceDB-Server.

A: You can't.
But you can use a SELECT inside the IN clause
SELECT * FROM TABLE1 WHERE MYFK IN (SELECT ID FROM TABLE2)

Or... since you have to deal with MILLIONS of rows, can't you just select them all and then filter those needed by application code? If you need 80M rows in a 100M rows table that may be the easiest approach. if your table has 80 billions rows instead it might be not a good approach instead.

A: If the [tbltest01details].[testid] is actually just a numerical value that you want your query to check against, you can use BETWEEN. If they are real distinct non-numerical parameters, there's literally no feasible way for you to do what you want to accomplish, and you need to re-think what you are actually doing.
i.e.
SelectQuery = "SELECT
[tbltest01details].[testdetailsid],
[tbltest01details].[name],
[tbltest01details].[testid]
FROM
[SourceServer].[SourceDB].[dbo]. [tbltest01details]  with (nolock)
WHERE
(
    [tbltest01details].[testid]
    BETWEEN 1 AND 80000000
)";

A: Few solutions to the question asked:

*

*Create a temporary table and fill it with values, any user can create temporary tables (https://msdn.microsoft.com/en-us/library/ms174979.aspx#Permissions)

*Read Sommarskogs short article about arrays http://www.sommarskog.se/arrays-in-sql.html and send chunks of values to SQL Server using a varchar(MAX) parameter.

*Use User Defined Table Valued Parameters, also very nice resource of Sommarskog http://www.sommarskog.se/arrays-in-sql-2005.html#TVP

*Export the values to a CSV file and then import them into a staging table

In combination of any of these you would then perform a regular join with the data you wish to extract.


text:
Q: Store text input as variable in R shiny I want to take a user's input and store it as a variable that will be used in a plotting function. My code:
ui <- fluidPage(
 mainPanel(
           plotlyOutput("plot", width = '100%'),
           br(),
           textAreaInput("list", "Input List", ""),
           actionButton("submit", "Submit", icon = icon("refresh"), style="float:right")
))

server <- function(input, output, session) {
my_text <<- renderText({
    req(input$submit)
    return(isolate(input$list))
    my_text ->> subv
  })
bindEvent(my_text,
output$plot <- renderPlotly({
#my very long plot code goes here which takes subv as input. This part has been tested outside of shiny and I know works.
}

I am trying to store the text in the subv variable as it will dictate what the renderPlotly will generate. When I hit submit nothing happens and the variable is only created after the session ends. The newly created subv variable in my environment does not show the text that was inputted but lists subv as an empty function i.e. subv function(...)

A: Below you can find a working prototype of what you would like to achieve with some information on what the issues were
First, we need to have a textOutput where our text will be shown. I understand this may not be necessary for the actual use case but it is important for this answer's demonstration purposes.
Next, we should not need to set variables to global via <<- or ->>. This is generally not good practice. Instead, we should store our result in a reactive. See also reactiveVals (but this is harder to follow when the app gets complex).
Since we need to only get the value when we click submit, we should use an event bind to only run when we click submit. This is essentially similar to eventReactive.
Finally, we can use bindCache to cache our result on the input list.
ui <- fluidPage(
  mainPanel(
    plotlyOutput("plot", width = '100%'),
    br(),
    textAreaInput("list", "Input List", ""),
    actionButton("submit", "Submit", icon = icon("refresh"),
                 style="float:right"),
    textOutput("hello_out")
  ))

server <- function(input, output, session) {
  my_text <- reactive({
    input$list

  }) %>%
    shiny::bindCache(input$list
                     ) %>%
    shiny::bindEvent(input$submit)
  output$hello_out  <- renderText({
    my_text()
  })
}

shinyApp(ui, server)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Populate matrix from linear system What is the strategy to populate a matrix from a linear system of equations?
As a toy example, I have some scary, complicated math, that generates eq1 and eq2. I can solve this, linear, system using Solve. I want to inspect the matrix that is made before the Solve step. In my application I expect this to be a system to be over defined.
eq1 = a x + y;
eq2 = b x - y;
Solve[{eq1 == 7, eq2 == 1}, {x, y}]

In the toy example, it would be this matrix:
( {
   {a, 1},
   {b, -1}
  } ) // MatrixForm

I could imagine parsing the text or something wacky like that.

A: CoefficientArrays[{eq1, eq2}, {x, y}][[2]] // Normal

{{a, 1}, {b, -1}}


text:
Q: How does NSImage's data retaining behaviour work? I have a method that constantly loads new image data from the web. Whenever all data for an image has arrived, it is forwarded to a delegate like this:
NSImage *img = [[NSImage alloc] initWithData:dataDownloadedFromWeb];
if([[self delegate] respondsToSelector:@selector(imageArrived:)]) {
    [[self delegate] imageArrived:img];
}
[img release];

In imageArrived: the image data is assigned to an NSImageView:
- (void)imageArrived:(NSImage *)img
{
    [imageView1 setImage:img];
}

This works nicely, the image is being displayed and updated with every new download cycle. I have profiled my application with Instruments to ensure that there is no leaking - it doesn't show any leaking. However, if I check with Instruments' Activity Monitor, I can see my application grabbing more and more memory with time, roughly increasing by the size of the downloaded images. If I omit [imageView1 setImage:img], memory usage stays constant. My question is: how is that happening? Is my code leaking? How does the NSImage instance within NSImageView determine when to release its data? Thanks for your answers!

A: When you do initWithData, the retain count on the data is incremented by one. Releasing the image does not change the retain count on the data. That's where your memory is going. The image structures are coming and going the way you want, but the data chunks are accumulating.
save the data handle separately and clean that out after disposing of the nsimage, and all should be well:
(id) olddata = 0; // global or something with persistence
your_routine
{
    (id) newdata = dataDownloadedFromWeb;
    NSImage *img = [[NSImage alloc] initWithData: newdata];
    if([[self delegate] respondsToSelector:@selector(imageArrived:)])
    {
        [[self delegate] imageArrived:img];
    }
    [img release];
    if (olddata) [olddata release];
    olddata = newdata;
}

cleanup
{
    if (olddata) [olddata release];
    olddata = 0;
}


text:
Q: HTML over flash without stopping interaction with flash I have a html div layered on top of an interactive flash movie, but when the mouse moves over the div, it can't interact with the flash (the view changes as the mouse moves or is clicked). Is there a way to have the flash recieve the mouse movements and clicks but leaving the html visible?
I can't modify the flash SWF file.
Edit: To make it clearer, this is an layer of information sitting on top of Google Street View (flash), the trouble is that I can't move the street view around where the layer overlaps.

A: Try something like this:
<object>
    <param name="wmode" value="transparent" />
    <embed src="example.swf" wmode="transparent"></embed>
</object>

The main things to note are the <param /> tag with the transparent attribute, and the wmode="transparent" in the embed tag. You'll also need to run the following javascript code to make this work across all browsers:
theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
    theObjects[i].outerHTML = theObjects[i].outerHTML;
}

This code should be run when the document is loaded. The site I got this code from claims that it must be run from an external file in order to work (although I haven't tested that).
I got this answer from here, where you can get more detail and a working example:
http://www.cssplay.co.uk/menus/flyout_flash.html

A: I believe the short answer is: No.
Sorry.
However, If you had complete control over how the Flash object is authored - you might be able to expose a public API to the javascript - allowing it to "manually" forward live mouse-coordinate, and mouse-button information into the flash, as you operate the mouse on top of the HTML overlay.
It might be worth checking, if Google's street-view Flash object exposes a public javascript API that might allow you to take some control of the flash - based on mouse-events picked up by your HTML overlay.
Expect the skies to fall, if you try this. :-)

A: should be aware that wmode=transparent will kill use of scroll wheel in firefox. this is true even in FP10


text:
Q: Configure build path problem in eclipse - java I upgraded the elastic search from version 5.5 to 7.7, everything is working as expected.
But when I try to get the Total hits, I get the following error
searchResponse.getHits().getTotalHits()

The type org.apache.lucene.search.TotalHits cannot be resolved. It is indirectly referenced from required .class files
We are not using the lucene library but still, it says it refers to the lucene,
Any help is appreciated to fix this.

Maven pom.xml :
I have only these two Jars,
<dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>7.7.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.1</version>
        </dependency>

Thanks,
Harry

A: As mentioned this link, you probably need to add the below dependency:
<repository>
    <id>elastic-lucene-snapshots</id>
    <name>Elastic Lucene Snapshots</name>
    <url>https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>false</enabled></snapshots>
</repository>

Also as per this link, you may also need to add Log4j dependency as well:
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.11.1</version>
</dependency>

That should do the trick.
Alternatively you can also add the below lucene dependency with the exact version you can see if you just do http://<hostname>:9200, however I suggest the above approach and go as per their documentation.
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
    <version>8.5.1</version>
</dependency>

Hope that helps!


text:
Q: How to create an array for UI elements with children in unity I am trying to make a system for when you press a button it instantiates a random card for a card game, but I can't figure out how to create an array for the cards (the cards are just ui images with some text on them (the image being a parent)) although using the refrence "Gameobject" although since the cards are ui elements not acctual game objects it didn't work so i tried using the refrence "Image" but then it only instantiated the actual image part. - pls help i know its a bit confusing but if u can help pls do i have only been programming for just over a year now so i am not very good with problems like this /:
code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CardMasterScript : MonoBehaviour
{
    public Image[] CardArray = new Image[8];
    public float RollNumber;
    public Canvas ParentCanvas;

    public void RollCard()
    {
        RollNumber = Random.Range(0.1f, 100);

        Debug.Log("Number Rolled: " + RollNumber);

        if(RollNumber <= 47.9)
        {
            var card = Instantiate(CardArray[0]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if(RollNumber > 47.9 && RollNumber <= 77.9)
        {
            var card = Instantiate(CardArray[1]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if( RollNumber > 77.9 && RollNumber <= 87.9)
        {
            var card = Instantiate(CardArray[2]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if(RollNumber > 87.9 && RollNumber <= 94.9)
        {
            var card = Instantiate(CardArray[3]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if(RollNumber > 94.9 && RollNumber <= 97.9)
        {
            var card = Instantiate(CardArray[4]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if(RollNumber > 97.9 && RollNumber <= 99.4)
        {
            var card = Instantiate(CardArray[5]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if(RollNumber > 99.4 && RollNumber <= 99.9)
        {
            var card = Instantiate(CardArray[6]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        } else if (RollNumber > 99.9 && RollNumber <= 100)
        {
            var card = Instantiate(CardArray[7]);
            card.transform.SetParent(ParentCanvas.transform);
            Destroy(card, 0.5f);
        }
    }
}

Thank you in advance!
i have tried changing the refrence in the array to image, i expected unity to just instantiate the image and its children aswell but it only instantiated the image.

A: I don't see why you can't create 8 GameObjects that have an image attached to them and have your CardArray be a GameObject array instead. Also the Instantiate function may have a transform argument to set its parent to.
For instance you can replace
var card = Instantiate(CardArray[0]);
 card.transform.SetParent(ParentCanvas.transform);

by
var card = Instantiate(CardArray[0], ParentCanvas.transform);

An Image alone doesn't have any children, it needs to be attached to an object that has some. That is why you can't instantiate an Image and expect it to have children
Hope that helps,


text:
Q: Method call from init() - Java I have been teaching myself Java for the past week or so. I'm brand new to programming. My code compiles just fine, but the applet does not display any text fields and the genRandomNumbers() method is not being invoked. So the question prompting the user to multiply two numbers is not displayed on the applet.
In my code, genRandomNumber() is being invoked from init(). Could that cause an issue? I tried to do this from paint() instead. That caused bigger issues - none of the text fields were displaying on the applet. So I moved the call to genRandomNumber() back to init().
The applet window shows "Start: applet window not initialized" in the Status area.
Could you point me in the right direction? Any help is greatly appreciated!
Here is my code:
 //Generate 2 random numbers
 //Post a question to multiply the two numbers
 //Verify the answer entered
 //Post a new question if the solution is correct

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class LearnMultiplication extends JApplet implements ActionListener
{

   JLabel answerLabel;
   JTextField answerTextField, commentTextField, questionTextField;
   int random1, random2;

   public void init()
   {
   Container c = getContentPane();
   c.setLayout(new FlowLayout() );

   JTextField questionTextField = new JTextField(30);
   c.add(questionTextField);

   JLabel answerLabel = new JLabel("Enter you answer here");
   c.add(answerLabel);

   JTextField answerTextField = new JTextField(5);
   answerTextField.addActionListener(this);
   c.add(answerTextField);

   JTextField commentTextField = new JTextField(30);
   c.add(commentTextField);

   genRandomNumbers(); // invoke method to generate 2 random numbers
   }

   public void actionPerformed (ActionEvent e)
   {
      int a = Integer.parseInt(e.getActionCommand() );
      verifyAnswer(a); // invoke method to verify the product
   }

   //method to generate 2 random numbers
   public void genRandomNumbers()
   {
        random1= 1 + (int)(Math.random() * 9    );
        random2 = 1 + (int)(Math.random() * 9   );
        questionTextField.setText("Multiply " + Integer.toString(random1) + "and " + Integer.toString(random2) + ".");

  }

   // method to verify the product of the 2 random numbers
   public void verifyAnswer(int answer)
   {
      int correctAnswer = random1 * random2;

      if ( correctAnswer == answer)
      {
         commentTextField.setText("Very Good!");
         genRandomNumbers(); //call the method again to generate 2 new random numbers
      }
      else
      {
         commentTextField.setText("No, try again!!");
      }

    }
}

A: Basically, you have a series of NullPointerExceptions.  This is one of the reasons why applets aren't a great place to get started with programming, because unless you have the Java console enabled, you won't get any output from your program which might be useful...
Any way...
You declare the following instance variables...
JTextField answerTextField, commentTextField, questionTextField;

Then in you init method you do this...
public void init() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    // Re-decleared/shadowed variable...
    JTextField questionTextField = new JTextField(30);
    c.add(questionTextField);

    JLabel answerLabel = new JLabel("Enter you answer here");
    c.add(answerLabel);

    // Re-decleared/shadowed variable...
    JTextField answerTextField = new JTextField(5);
    answerTextField.addActionListener(this);
    c.add(answerTextField);

    // Re-decleared/shadowed variable...
    JTextField commentTextField = new JTextField(30);
    c.add(commentTextField);

    genRandomNumbers(); // invoke method to generate 2 random numbers
}

You declare the questionTextField, answerTextField and commentTextField as local variables.  This is commonly known as shadowing.  Basically, when you think the instance variables have being initialised, they haven't, because you've used local variables instead...
If, instead, you do something more like...
public void init() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    questionTextField = new JTextField(30);
    c.add(questionTextField);

    JLabel answerLabel = new JLabel("Enter you answer here");
    c.add(answerLabel);

    answerTextField = new JTextField(5);
    answerTextField.addActionListener(this);
    c.add(answerTextField);

    commentTextField = new JTextField(30);
    c.add(commentTextField);

    genRandomNumbers(); // invoke method to generate 2 random numbers
}

You should now find your instance variables have being intialised and are now accessiable as expected from the other parts of your class...


text:
Q: Hiding elements with javascript On button click, I want to hide the div. How do i do it?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<form>

heya

<input type="button" id='approve' value="approve" onclick="button()"/>
<input type="button" id="reject" value="reject"/>
</form>

SORRY FOR ASKING AGAIN...BUT COULDN'T FIND A BETTER METHOD. THANKS

A: document.getElementById('hide').style.display = 'none';

This sets the CSS code display: none; on the div, which causes the browser's rendering engine to act like the element is not even on the page (e.g. it does not occupy any space). See the CSS standard for the official description.

A: You can just use Jquery to make things super easy:
$("#approve").click( function() {
    $("div#hide").hide()   //you can just use $("#hide") if you want
});

You can show the element whenever you want with $("div#hide").show(). This will save you from having to deal with browser inconsistencies and other crap so you can just focus on producing great readable code. :)

A: If you use jQuery:
$(document).ready(function() {
  $('#approve').click(function() {
    $('#hide').hide();
  });
});


text:
Q: D3 text in alignment with rect I have rect and a description text above chart -

Issue is description text is not getting properly aligned with rects. Description is getting mixed into rects. I want to start text after rect ends.
I have below code -
var legend = svgColorCode.selectAll(".legend")
             .data(keys)
             .enter().append("g")
             .attr("class", "legend")
             .attr("transform", function (d, i) { return "translate(" +  (((keys.length-(i))*-25)) + "," + (height -190) + ")"; })
             .attr("fill", function (d, i) { return colors[i]; });

legend.append("rect")
            .attr("x", (x,i)=> (padding.top * 2 + labHeight * (i))+40)
            .attr("width", 18)
            .attr("height", 18)
            .style("fill", function (d, i) { return colors[i]; })

legend.append("text")
            .attr("x", (x,i)=> (padding.top * 2 + labHeight * i)+110)
            .attr("y", 9)
            .attr("font-size","0.5rem")
            .attr("dy", ".35em")
            .style("text-anchor", "end")
            .text(function (d) { return d; });

HTML getting generated for color rect and description text -
<svg>
  <g class="legend" transform="translate(-100,10)">
    <rect x="100" width="18" height="18"></rect>
    <text x="170" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: end;">
      description text1
    </text>
  </g>
  <g class="legend" transform="translate(-75,10)" style="/* width: 10rem; */">
    <rect x="150" width="18" height="18"></rect>
    <text
      x="220"
      y="9"
      font-size="0.5rem"
      dy=".35em"
      style="text-anchor: end;/* margin-left: 29rem; *//* padding-left: 1rem; */"
    >
      description text2
    </text>
  </g>
  <g class="legend" transform="translate(-50,10)">
    <rect x="200" width="18" height="18"></rect>
    <text x="270" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: end;">
      description text3
    </text>
  </g>
  <g class="legend" transform="translate(-25,10)">
    <rect x="250" width="18" height="18"></rect>
    <text x="320" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: end;">
      description text4
    </text>
  </g>
</svg>;

How can I avoid mixing of color rect and description text ? and simply start description text after color rect?

A: Change this to have text anchor as 'start'. You are putting the anchor of text at end so that is why text shifted left to align to end
Try reducing (padding.top * 2 + labHeight * i)+110) by around 50-60px and have text-anchor start for the text element. You can adjust the margins based on style you want

<svg>
  <g class="legend" transform="translate(-100,10)">
    <rect x="100" width="18" height="18"></rect>
    <text x="120" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: start;">
      description text1
    </text>
  </g>
  <g class="legend" transform="translate(-75,10)" style="/* width: 10rem; */">
    <rect x="150" width="18" height="18"></rect>
    <text
      x="170"
      y="9"
      font-size="0.5rem"
      dy=".35em"
      style="text-anchor: start;/* margin-left: 29rem; *//* padding-left: 1rem; */"
    >
      description text2
    </text>
  </g>
  <g class="legend" transform="translate(-50,10)">
    <rect x="200" width="18" height="18"></rect>
    <text x="220" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: start;">
      description text3
    </text>
  </g>
  <g class="legend" transform="translate(-25,10)">
    <rect x="250" width="18" height="18"></rect>
    <text x="270" y="9" font-size="0.5rem" dy=".35em" style="text-anchor: start;">
      description text4
    </text>
  </g>
</svg>;


text:
Q: How home my code doesn't display any feature image? Looping through post from a taxonomy and not getting feature images back The only thing I am trying to do is just to display each post from Services that belongs to the taxonomy called 'national'  and display its title and its featured image. So far it displays each title correctly but for some reason Featured images are simply not working.

        <?php
        $args = array(
            'post_type' => 'services',
            'posts_per_page' => 30,
            'state' => 'national'
        );
        $the_query = new WP_Query( $args ); ?>
        <?php if ( $the_query->have_posts() ) : ?>
        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                    <?php the_post_thumbnail(); ?>
                    <?php the_title( '
', '
' ); ?>

        <?php endwhile; ?>
        <?php endif ?>


text:
Q: Loading dynamic layout in Android I'm currently making an application that uses a dynamic layout. It's my first time doing this and I'm doing it solely for the purpose of learning it. I managed to get it to load most of the data and show it correctly, but I'm having issues with the first item. For some reason it skips it and start with the 2nd item. It loads it into a variable but for some reason it isn't shown. I believe it has something to do with layout parameters but I can not find a reason for it behaving that way.
This is how it looks (take note, it should start with 141- ... item. It is loaded into a variable tho but not shown)

This is the code I'm using to load the items according to the variables
for (int i = 0; i <= id_l; i++)
            {
                RelativeLayout container = (RelativeLayout)findViewById(R.id.popisLinija);
                View item_layout = getLayoutInflater().inflate(R.layout.item_layout, null);
                Integer l = id_l;
                Log.d("id length: ", l.toString());
                Log.d("ID: ", id[i].toString());
                Log.d("Linija br: ", broj_linije[i]);
                Integer i2 = i;
                Log.d("i= ", i2.toString());

                item_layout.setId(i);
                item_layout.setTag("View");

                final Integer h = item_layout.getId();

                // fill in any details dynamically here
                assert item_layout != null;
                TextView textView = (TextView) item_layout.findViewById(R.id.item_text);

                if(broj_linije[i].equals("000"))
                {
                    textView.setText(naziv_linije[i]);
                }
                else
                {
                    textView.setText(broj_linije[i] + " - " + naziv_linije[i]);
                }

                textView.setTag("Text");

                RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                if(i == 0)
                {
                    if (rlp != null) {
                        rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, container.getId());
                    }
                }
                if(i > 0)
                {
                    if (rlp != null) {
                        rlp.addRule(RelativeLayout.BELOW, i-1);
                    }
                }

                FrameLayout item_button = (FrameLayout) item_layout.findViewById(R.id.item_button);
                item_button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0)
                    {
                        Integer a =  h;
                        Toast.makeText(getApplicationContext(), "Clicked me", Toast.LENGTH_SHORT).show();
                        Log.d("clicked", h.toString());
                    }
                });

                item_layout.setLayoutParams(rlp);
                container.addView(item_layout);
            }

I have checked if the item is loaded
> 05-02 07:09:00.116  21204-21204/com.example.app D/ID:﹕ 0 05-02 <<< ITEM 141 VARIABLE
> 07:09:00.116  21204-21204/com.example.app D/Linija br:﹕ 141 05-02 <<< ITEM 141 VARIABLE
> 07:09:00.116  21204-21204/com.example.app D/i=﹕ 0 05-02 07:09:00.166  <<< ITEM 141 VARIABLE
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.166
> 21204-21204/com.example.app D/ID:﹕ 1 05-02 07:09:00.166
> 21204-21204/com.example.app D/Linija br:﹕ 142 05-02 07:09:00.166
> 21204-21204/com.example.app D/i=﹕ 1 05-02 07:09:00.176
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.176
> 21204-21204/com.example.app D/ID:﹕ 2 05-02 07:09:00.176
> 21204-21204/com.example.app D/Linija br:﹕ 143 05-02 07:09:00.176
> 21204-21204/com.example.app D/i=﹕ 2 05-02 07:09:00.206
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.206
> 21204-21204/com.example.app D/ID:﹕ 3 05-02 07:09:00.206
> 21204-21204/com.example.app D/Linija br:﹕ 144 05-02 07:09:00.206
> 21204-21204/com.example.app D/i=﹕ 3 05-02 07:09:00.216
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.216
> 21204-21204/com.example.app D/ID:﹕ 4 05-02 07:09:00.216
> 21204-21204/com.example.app D/Linija br:﹕ 145 05-02 07:09:00.216
> 21204-21204/com.example.app D/i=﹕ 4 05-02 07:09:00.226
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.226
> 21204-21204/com.example.app D/ID:﹕ 5 05-02 07:09:00.226
> 21204-21204/com.example.app D/Linija br:﹕ 146 05-02 07:09:00.226
> 21204-21204/com.example.app D/i=﹕ 5 05-02 07:09:00.246
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.246
> 21204-21204/com.example.app D/ID:﹕ 6 05-02 07:09:00.246
> 21204-21204/com.example.app D/Linija br:﹕ 147 05-02 07:09:00.246
> 21204-21204/com.example.app D/i=﹕ 6 05-02 07:09:00.276
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.276
> 21204-21204/com.example.app D/ID:﹕ 7 05-02 07:09:00.276
> 21204-21204/com.example.app D/Linija br:﹕ 148 05-02 07:09:00.276
> 21204-21204/com.example.app D/i=﹕ 7 05-02 07:09:00.316
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.316
> 21204-21204/com.example.app D/ID:﹕ 8 05-02 07:09:00.316
> 21204-21204/com.example.app D/Linija br:﹕ 149 05-02 07:09:00.316
> 21204-21204/com.example.app D/i=﹕ 8 05-02 07:09:00.316
> 21204-21208/com.example.app D/dalvikvm﹕ GC_CONCURRENT freed 949K, 37%
> free 7958K/12524K, paused 9ms+17ms, total 92ms 05-02 07:09:00.326
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.326
> 21204-21204/com.example.app D/ID:﹕ 9 05-02 07:09:00.326
> 21204-21204/com.example.app D/Linija br:﹕ 150 05-02 07:09:00.326
> 21204-21204/com.example.app D/i=﹕ 9 05-02 07:09:00.336
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.336
> 21204-21204/com.example.app D/ID:﹕ 10 05-02 07:09:00.336
> 21204-21204/com.example.app D/Linija br:﹕ 150A 05-02 07:09:00.336
> 21204-21204/com.example.app D/i=﹕ 10 05-02 07:09:00.346
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.346
> 21204-21204/com.example.app D/ID:﹕ 11 05-02 07:09:00.346
> 21204-21204/com.example.app D/Linija br:﹕ 151 05-02 07:09:00.346
> 21204-21204/com.example.app D/i=﹕ 11 05-02 07:09:00.366
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.366
> 21204-21204/com.example.app D/ID:﹕ 12 05-02 07:09:00.366
> 21204-21204/com.example.app D/Linija br:﹕ 153 05-02 07:09:00.366
> 21204-21204/com.example.app D/i=﹕ 12 05-02 07:09:00.376
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.376
> 21204-21204/com.example.app D/ID:﹕ 13 05-02 07:09:00.376
> 21204-21204/com.example.app D/Linija br:﹕ 155 05-02 07:09:00.376
> 21204-21204/com.example.app D/i=﹕ 13 05-02 07:09:00.386
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.386
> 21204-21204/com.example.app D/ID:﹕ 14 05-02 07:09:00.386
> 21204-21204/com.example.app D/Linija br:﹕ 156 05-02 07:09:00.386
> 21204-21204/com.example.app D/i=﹕ 14 05-02 07:09:00.396
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.396
> 21204-21204/com.example.app D/ID:﹕ 15 05-02 07:09:00.396
> 21204-21204/com.example.app D/Linija br:﹕ 157 05-02 07:09:00.396
> 21204-21204/com.example.app D/i=﹕ 15 05-02 07:09:00.406
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.406
> 21204-21204/com.example.app D/ID:﹕ 16 05-02 07:09:00.406
> 21204-21204/com.example.app D/Linija br:﹕ 158 05-02 07:09:00.406
> 21204-21204/com.example.app D/i=﹕ 16 05-02 07:09:00.416
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.416
> 21204-21204/com.example.app D/ID:﹕ 17 05-02 07:09:00.416
> 21204-21204/com.example.app D/Linija br:﹕ 159 05-02 07:09:00.416
> 21204-21204/com.example.app D/i=﹕ 17 05-02 07:09:00.426
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.426
> 21204-21204/com.example.app D/ID:﹕ 18 05-02 07:09:00.436
> 21204-21204/com.example.app D/Linija br:﹕ 160 05-02 07:09:00.436
> 21204-21204/com.example.app D/i=﹕ 18 05-02 07:09:00.436
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.436
> 21204-21204/com.example.app D/ID:﹕ 19 05-02 07:09:00.436
> 21204-21204/com.example.app D/Linija br:﹕ 162 05-02 07:09:00.436
> 21204-21204/com.example.app D/i=﹕ 19 05-02 07:09:00.446
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.446
> 21204-21204/com.example.app D/ID:﹕ 20 05-02 07:09:00.446
> 21204-21204/com.example.app D/Linija br:﹕ 260 05-02 07:09:00.446
> 21204-21204/com.example.app D/i=﹕ 20 05-02 07:09:00.456
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.456
> 21204-21204/com.example.app D/ID:﹕ 21 05-02 07:09:00.456
> 21204-21204/com.example.app D/Linija br:﹕ 260A 05-02 07:09:00.456
> 21204-21204/com.example.app D/i=﹕ 21 05-02 07:09:00.476
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.476
> 21204-21204/com.example.app D/ID:﹕ 22 05-02 07:09:00.476
> 21204-21204/com.example.app D/Linija br:﹕ 261 05-02 07:09:00.476
> 21204-21204/com.example.app D/i=﹕ 22 05-02 07:09:00.486
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.486
> 21204-21204/com.example.app D/ID:﹕ 23 05-02 07:09:00.486
> 21204-21204/com.example.app D/Linija br:﹕ 262 05-02 07:09:00.486
> 21204-21204/com.example.app D/i=﹕ 23 05-02 07:09:00.496
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.496
> 21204-21204/com.example.app D/ID:﹕ 24 05-02 07:09:00.496
> 21204-21204/com.example.app D/Linija br:﹕ 263 05-02 07:09:00.496
> 21204-21204/com.example.app D/i=﹕ 24 05-02 07:09:00.506
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.506
> 21204-21204/com.example.app D/ID:﹕ 25 05-02 07:09:00.506
> 21204-21204/com.example.app D/Linija br:﹕ 264 05-02 07:09:00.506
> 21204-21204/com.example.app D/i=﹕ 25 05-02 07:09:00.516
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.516
> 21204-21204/com.example.app D/ID:﹕ 26 05-02 07:09:00.516
> 21204-21204/com.example.app D/Linija br:﹕ 265 05-02 07:09:00.516
> 21204-21204/com.example.app D/i=﹕ 26 05-02 07:09:00.526
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.526
> 21204-21204/com.example.app D/ID:﹕ 27 05-02 07:09:00.526
> 21204-21204/com.example.app D/Linija br:﹕ 266 05-02 07:09:00.526
> 21204-21204/com.example.app D/i=﹕ 27 05-02 07:09:00.536
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.536
> 21204-21204/com.example.app D/ID:﹕ 28 05-02 07:09:00.536
> 21204-21204/com.example.app D/Linija br:﹕ 267 05-02 07:09:00.536
> 21204-21204/com.example.app D/i=﹕ 28 05-02 07:09:00.546
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.546
> 21204-21204/com.example.app D/ID:﹕ 29 05-02 07:09:00.546
> 21204-21204/com.example.app D/Linija br:﹕ 000 05-02 07:09:00.546
> 21204-21204/com.example.app D/i=﹕ 29 05-02 07:09:00.556
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.556
> 21204-21204/com.example.app D/ID:﹕ 30 05-02 07:09:00.556
> 21204-21204/com.example.app D/Linija br:﹕ 000 05-02 07:09:00.556
> 21204-21204/com.example.app D/i=﹕ 30 05-02 07:09:00.566
> 21204-21204/com.example.app D/id length:﹕ 31 05-02 07:09:00.566
> 21204-21204/com.example.app D/ID:﹕ 31 05-02 07:09:00.566
> 21204-21204/com.example.app D/Linija br:﹕ 000 05-02 07:09:00.566
> 21204-21204/com.example.app D/i=﹕ 31

Could anyone help me out on what am I doing wrong here? I would greatly appreciate it, I lost hours on this one trying all sorts of stuff with no result.
EDIT:
I have added my layout XML file
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:background="#ffffff"
    android:id="@+id/item_container"
    android:clickable="false"
    android:focusable="false">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:padding="2dp"
        android:background="#e8e8e8"
        android:id="@+id/item_body"
        android:clickable="false"
        android:focusable="false">

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/background"
            android:id="@+id/item_button"
            android:clickable="true"
            android:longClickable="true"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:minHeight="55dp">

                <FrameLayout
                    android:layout_width="3dp"
                    android:layout_height="fill_parent"
                    android:background="@android:color/transparent"
                    android:id="@+id/item_indicator"></FrameLayout>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="141-SAMOBOR-RAKOV POTOK-JAGNJIĆ DOL"
                    android:id="@+id/item_text"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="30dp"
                    android:textAppearance="@android:style/TextAppearance.Small"
                    android:gravity="fill" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/item_icon"
                    android:layout_gravity="center_vertical|right"
                    android:background="@android:color/transparent"
                    android:src="@drawable/plus_t"
                    android:layout_marginRight="5dp"
                    android:contentDescription="Proširi" />

            </FrameLayout>
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/item_image_container"
            android:layout_below="@+id/item_body"
            android:layout_marginTop="5dp"
            android:background="#ffffff">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/item_image"
                android:background="@android:color/transparent"
                android:layout_centerHorizontal="true"
                android:scaleType="fitCenter" />
        </RelativeLayout>

</RelativeLayout>

A: try this way,hope this will help you...
XML code
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:src="@drawable/ic_launcher"
        android:adjustViewBounds="true"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <LinearLayout
            android:id="@+id/lnrDynamicItem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

        </LinearLayout>
    </ScrollView>

</LinearLayout>

ACTIVITY code
MainActivity
  public class MainActivity extends Activity {

    private LinearLayout lnrDynamicItem;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lnrDynamicItem = (LinearLayout) findViewById(R.id.lnrDynamicItem);

        for (int i = 0; i <= id_l; i++)
        {
            Integer l = id_l;
            Log.d("id length: ", l.toString());
            Log.d("ID: ", id[i].toString());
            Log.d("Linija br: ", broj_linije[i]);
            Integer i2 = i;
            Log.d("i= ", i2.toString());

            item_layout.setId(i);
            item_layout.setTag("View");

            TextView textView = new TextView(this);
            textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            textView.setId(i+1);

            if(broj_linije[i].equals("000"))
            {
                textView.setText(naziv_linije[i]);
            }
            else
            {
                textView.setText(broj_linije[i] + " - " + naziv_linije[i]);
            }

            textView.setTag(textView.getId());

            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view)
                {
                    Integer a =  (Integer) view.getTag();
                    Toast.makeText(getApplicationContext(), "Clicked me", Toast.LENGTH_SHORT).show();
                    Log.d("clicked", h.toString());
                }
            });

            lnrDynamicItem.addView(textView);
        }

    }

 }


text:
Q: The integral form of inner product . I want to know how scientists know that the inner product of f and g equal to integration from $$\int_a^b f(x)g(x)\ dx.$$

A: An inner product on a vector space $V$ over $\mathbb R$  is a function $\langle\cdot,\cdot\rangle : V \times V \to \mathbb R$ which satisfies certain axioms, e.g., $\langle v, v\rangle = 0$ iff $v = 0$, $\langle v, v\rangle \geq 0$ for all $v$.
The definition of an inner product on the vector space of let's say continuous functions on $[0,1]$ of
$$\langle f, g \rangle = \int_0^1 f(x)g(x) \ dx$$
works in that it satisfies those axioms.
Now, given that, it turns out we can use the inner product for a very wide range of useful things.
Historically, the definition was probably inspired by analogy with vectors in $\mathbb R^n$, namely
$$\langle (v_1,v_2,...,v_n),(w_1,w_2,...,w_n)\rangle = \sum_{i=1}^n v_iw_i$$


text:
Q: Applications starting but not showing UI I tried to start applications as usual from the Windows start menu. Over ~ 30 minutes, I got the following effects:

*

*applications with a GUI do not get shown any more.

*I can continue using GUI applications that are already opened

*I can open non-GUI / console applications (like cmd).

*From the command line prompt, I can see that the GUI applications are started using tasklist
Here's an example:
>tasklist | find "taskmgr"
taskmgr.exe                   4352 Console                    1      7.216 K
taskmgr.exe                   7824 Console                    1      7.216 K
taskmgr.exe                   7232 Console                    1      7.232 K

As you can imagine, I tried to start Task Manager to diagnose the problem 3 times. But none of the Task Manager windows became visible.
Under the assumption that tasklist displays the processes in the order they were started, I roughly identified the issue:
...
openAgent.exe                 7012 Console                    1    592.440 K Not Responding
...
WerFault.exe                  3592 Console                    1     10.112 K Unknown
...

openAgent is an application I closed (or at least tried to close, since it still seems to be running). Something must have crashed due to the presence of WerFault, but I could not see a Windows Error Reporting dialog.
Terminating the openAgent application forcefully using taskkill /pid 7012 /f, all applications I attempted to start suddenly appeared.
Looking at the Windows Error Reporting dialog now, it shows exception 80000003, which is a (debug) breakpoint.
What has happened here? I'd like to understand the situation from a Windows Internals standpoint. In theory I'd expect that the crash of a user mode application should not be able to influence other applications.
Unfortunately I neither have a kernel dump of the situation nor a user mode crash dump of openAgent, so this is all information I can give you.
My system is Windows 7 SP1 x64 Enterprise, no pending Windows updates, Intel Core i7 CPU. openAgent is an executable of SilkTest by MicroFocus, a test automation tool.

A: I could reproduce the issue once again and it turns out that openAgent installs a hook called OsHookDll_x86 from the same company.
This hook applies to DispatchHookW():
2:010> k
...
0049f2b0 75a86381 OsHookDll_x86!GetMessageHook+0x37
0049f2cc 75a780a9 USER32!DispatchHookW+0x38
...
0049f544 5eff5709 USER32!PeekMessageW+0x108

which affects the Windows Message loop. The windows message loop is needed by any GUI application to run.
The hook sends Windows Messages to openAgent via USER32!SendMessageW() but openAgent was suspended by Windows Error Reporting (WerFault) and therefore cannot process such messages, resulting in a timeout:
1:009> k
ChildEBP RetAddr
00138f90 75a79886 USER32!NtUserMessageCall+0x15
00138fcc 75a797f3 USER32!SendMessageTimeoutWorker+0xa6
00138ff4 59d6066c USER32!SendMessageTimeoutW+0x21
...

I could not fully analyze the rest since during my debug session, everything else started to freeze as well. I assume that the hook tries to resend the message instead of returning, thus resulting in an endless loop.
!analyze -v did not work due to Missing symbols for ntdll.


text:
Q: Cannot manage to click on a button using Xpath hi i'm trying to click on a button using Xpath on chrome browser but from some reason the software does not click on it.
i used the devtools inspect in order to copy the Xpath to the findElement function.
that's the website: https://mynames.co.il/
i'm sorry that's in hebrew...
this photo shows the button ,i marked the button in blue
that's the steps file:
package stepDefinitions;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

import cucumber.api.PendingException;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class purchaseDomainSteps {

WebDriver driver;

    @Before
    public void setup() throws IOException {
        System.setProperty("webdriver.chrome.driver", Paths.get(System.getProperty("user.dir")).toRealPath() +  "\\src\\test\\java\\drivers\\chromedriver.exe");
        this.driver = new ChromeDriver();
        this.driver.manage().window().maximize();
        this.driver.manage().timeouts().pageLoadTimeout(120, TimeUnit.SECONDS);
    }

    @After()
    public void tearDown() {
        this.driver.manage().deleteAllCookies();
        this.driver.quit();
    }

@Given("^I access https://mynames\\.co\\.il$")
public void i_access_https_mynames_co_il() throws Throwable {
    driver.get("https://mynames.co.il/");
    throw new PendingException();
}

@When("^I click on Login button\\.$")
public void i_click_on_Login_button() throws Throwable {

    String path = "/html/body/div[1]/div/div/section[2]/div/div/div[2]/div/div/section/div/div/div[2]/div/div/div/div/div/a/span/span";
    //WebDriverWait wait = new WebDriverWait(driver, 5);
    driver.findElement(By.xpath(path)).click();
    throw new PendingException();
}

that's the runner class:
package runners;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)

@CucumberOptions(features = { "src/test/java/featurefiles/" }, glue = {
        "stepDefinitions" }, monochrome = true, tags = {},
                plugin = { "pretty", "html:target/cucumber", "json:target/cucumber.json",
                "com.cucumber.listener.ExtentCucumberFormatter:output/report.html" })

public class MainRunner {

}

A: Hey pls use this Xpath to click that button which you marked in blue colour line
//span[contains(text(),'כניסה')]

A: After I've check the website (https://mynames.co.il/):

         כניסה

I recommend 2 options:

*

*Use the link itself to redirect on login page

String targetPage = driver.findElement(By.xpath("/html/body/div[1]/div/div/section[2]/div/div/div[2]/div/div/section/div/div/div[2]/div/div/div/div/div/a")).getAttribute("href");
driver.navigate().to(targetPage);

*(Maybe this is what you want) You click on href or force a href to act like button

driver.findElement(By.xpath("/html/body/div[1]/div/div/section[2]/div/div/div[2]/div/div/section/div/div/div[2]/div/div/div/div/div/a")).click();

The reason that your code is not working is because span that you assume as button, doesn't have any click action meanwhile the click action you hope for is on a href.
// this is just text with style inside span
כניסה

A: Are you getting any Exception ? If yes, what exception is that ? If no, selenium clicking is happening but the application is not acknowledging the click. So try using javascript executor to perform click as below
WebElement ele = driver.findelement(By.xpath("//span[text()='כניסה']"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("argument[0].click();",ele);

Even after using the above code, if it doesn't work, then check if you are referring to the right feature and class files in junit runner class cucumberOptions 'glue' and 'features'
One more important tip : I see absolute xpath in your script which will not work if there is a change in the DOM structure in future, So always go for relative xpath

A: As the element is a dynamic element so to click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

*

*cssSelector:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.elementor-button-link.elementor-button.elementor-size-xs span.elementor-button-text"))).click();

*xpath:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[@class='elementor-button-text' and text()='כניסה']"))).click();


text:
Q: What this phrase trying to say? Could anyone please help me with this, I dont get the meaning, why he said that is satisfying and also crushing? And also what is the meaning of I read a good deal?  Btw gradually he become a poet

*

*It was my last year. I'd wanted to be a football player very much,
and got my letter but didn't make the team. Well, that was satisfying
but crushing too. I read a good deal, but had never written. So this
was a recoil from that. Then I had some luck in that Richard Eberhart
was teaching there.

A: In US high schools it is common for to award "letters", a patch bearing the school monogram, to participants in school activities such as sports teams or the band or orchestra.
Every school and organization within the school has its own criteria for awarding letters. In this passage the writer probably earned his letter for commitment and effort—perhaps on the practice squad. So it was satisfying to earn the letter, even though it was crushing not to be selected for the team.
It's traditional to wear the letter on a sweater or jacket of the school colors, like these:


text:
Q: neo4j relationships between nodes using a common property (id) without creating more nodes I have been trying to match together two different nodes (process) and (process framework) that have the same id. I want to set a relationship between those (called:SAME).
The query works but it creates 3 times the amount of processes that I wanted and I can´t figure out why:
MATCH (p:Process)
MATCH (pcf:ProcessFramework)
WHERE HAS (p.id) AND HAS (pcf.pcf_id) AND p.id=pcf.pcf_id
MERGE (p)<-[:same]-(pf)
return p,pcf

I also tried it with CREATE UNIQUE instead of MERGE but its the same result. I am not a developer so maybe I am doing a very obvious mistake but I really can´t see it!
Thanks!

A: You have a typo in your query, you use pf where you should use pcf in the MERGE.
I'd also change it to this and make sure you have an index on :ProcessFramework(pcf_id)
MATCH (p:Process)
MATCH (pcf:ProcessFramework)
WHERE p.id=pcf.pcf_id
MERGE (p)<-[:same]-(pcf)
return p,pcf


text:
Q: How to redirect users to another domain .htaccess Server by default redirects users who type example.com/folder to example.com/folder/
Is there any way to change that (for example when they go to example.com/folder to redirect to  otherexample.com/folder/). But this has to affect all folders but exclude the root. Also the code should do nothing when they type example.com/folder/.
Edit
Also the code should not affect images and all other files (or better say, if the requested document has file extension), just folders.
example:
should affect : example.com/folder
              : example.com/folder/folder

but should not : example.com
               : example.com/forum (but only forum, only this folder)
               : example.com/folder/
               : example.com/folder/.
               : example.com/folder/folder/
               : example.com/image.png
               : example.com/something.something
               : example.com/something.
               : example.com/.something

Edit
And an other edit:
Let's say we found the .htaccess code (the 1st answer below). How do I make it work for all my domain and website expect my blog (example.com/blog) which I don't want to have redirections like whole my website?

A:
Server by default redirects users who type example.com/folder to
example.com/folder/

That's done by mod_dir for several good reasons, all of which are explained in the DirectorySlash documentation. You could use DirectorySlash Off to turn that behaviour off, but it is generally NOT a good idea to do that, unless you have VERY good and valid reasons to do so.
However, having said that, what you've described in your question can be handled by mod_rewrite alone. First, you need to check if the requested resource is a directory. It needs to be a physical directory inside your DocumentRoot.
RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_URI}  -d

It is vitally important to also apply %{DOCUMENT_ROOT}, otherwise the directory check won't work.

*

*'-d' (is directory)
Treats the TestString as a pathname and tests whether or not it exists, and is a directory.

Second, you need to ignore all requests to directories that actually do have a trailing slash.
RewriteCond   %{REQUEST_URI}                  !/$

Now you've filtered down to just the resources you want to redirect to another domain: directories without a trailing slash. Everything else (directories with trailing slashes, images, etc.) is not even in the game at this point. Time for the actual redirect.
RewriteRule   ^   http://other.com%{REQUEST_URI}/ [redirect=temp,last]

You might want to change your mind later on about the redirection, so you should use temporary redirects (a.k.a. 302 Found) instead of permanent ones (a.k.a. 301 Moved Permanently). The last tells mod_rewrite to stop all further processing.
And here's the final product:
RewriteEngine On

RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_URI}  -d
RewriteCond   %{REQUEST_URI}                  !/$

RewriteRule   ^   http://other.com%{REQUEST_URI}/ [redirect=temp,last]

A: What about
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://otherexample.com/$1/ [L,R=301]

A: # This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/

# This allows you to redirect your entire website to any other domain
Redirect 302 / http://mt-example.com/

# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html

# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

Read more here for RewriteEngine method

A: Hope this is what you need
Redirect 301 /directory http://www.newdomain.com

just change directory with your folder name

A: For  :  www.newdomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

For  : olddomain.com to newdomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]


text:
Q: Android OnPreferenceClickListener I have an Activity that displays a settings menu using a PreferenceFragment. There is a method that passes a list of Beans to the fragment so it can dynamically generate a list of Preferences that I want to act essentially like buttons. I'm trying to use the OnPreferenceClickListener to react to one of the Preferences being clicked, but I need to let the outermost Activity know about this. My code looks like this:
public class PairActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fragment = new SettingsFragment();
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, fragment)
                .commit();
        ...
    }

    public static class SettingsFragment extends PreferenceFragment {
        public void displayBeans(Collection<Bean> beans) {
            ...
            for(Bean bean : beans) {
                Preference pref = new Preference(getActivity());
                pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                    @Override
                    public boolean onPreferenceClick(Preference preference) {
                        // want to let the Activity know something happened
                    }
                });
            }
        }
    }

    ...
}

The comment shows where I want to reach the Activity from, but it's inside of an anonymous class inside a static class... What can I do to solve my issue?

A: Edit:

Make your SettingsFragment an inner class of PairActivity:
public class PairActivity extends Activity {

    public class SettingsFragment extends PreferenceFragment {

    }

}

Then you can safely reference the activity with PairActivity.this.

Edit:
That's a nice answer you linked and it's indeed the proper way to use it like that. I didn't think about it.
Nevertheless when the fragment is attached to an activity you can reference it using getActivity. A fragment will definitely be attached to an activity if you call this method from inside of a clickListener so it's fine to do this:
public class PairActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fragment = new SettingsFragment();
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, fragment)
                .commit();
        ...
    }

    public static class SettingsFragment extends PreferenceFragment {
        public void displayBeans(Collection<Bean> beans) {
            ...
            for(Bean bean : beans) {
                Preference pref = new Preference(getActivity());
                pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                    @Override
                    public boolean onPreferenceClick(Preference preference) {
                        PairActivity pairActivity = (PairActivity) getActivity();
                        // Do something with pairActivity instance
                    }
                });
            }
        }
    }

    ...
}

You just need to make sure that you don't attach your fragment to another activity as the cast (PairActivity) will throw an exception then.


text:
Q: search for text in javascript and get all its start and end index I have a content like

The apple is the pomaceous fruit of the apple tree, species Malus
  domestica in the rose family (Rosaceae). It is one of the most widely
  cultivated tree fruits,  apple is the good for and the most widely
  known of the many members of genus Malus that are used by humans.
  Apples grow on small, deciduous trees.

I have an array like
["apple", " ", "is", " ", "the"];

With this array how to find the start index and end index of the word apple is the in javascript?
I tried looping the content and using indexOf but I couldn't get all the index of the word
this is what i tried
var matchs =[];
var content = "a b c defgh a b csdwda abcdfd";
var arrayWord =["a"," ", "b"];
var w =0;
var pos =0;
var firstIndex = content.indexOf(arrayWord[w],pos);
pos = firstIndex;
while (pos > -1) {
    pos+=arrayWord[w].length;
    w++;
    pos = content.indexOf(arrayWord[w], pos);
    matchs.push(firstIndex,pos);
}

A: After reading your comments I think this is what you are after. You can add further replace statements if necessary.
var text,
    pos,
    start,
    matches = [],
    charArr,
    charText,
    currentMatch;

text = $("h5").text( );

//white spaces must match length of string being replaced
text = text.replace("\r\n","    ");
charText = text.split("");

charArr = ["apple", " ", "is", " ", "the"].join("").split("");
currentMatch = 0;

// Loop through char array ignoring multiple white spaces
for( pos = 0; pos < text.length; pos += 1 ) {

    if( currentMatch === 0 ) start = pos;

    if( charText[pos] === charArr[currentMatch] ) {
        currentMatch += 1;
    } else if( charText[pos] !== " " ) {
        currentMatch = 0;
    }

    // matched entire array so push to matches
    if( currentMatch === charArr.length ) {
        matches.push( [ start, pos] );
        currentMatch = 0;
    }
}

Fiddle here

A: Assuming I've understood your question correctly, you can join the array and use the indexOf method of the string to get the start index (this example assumes your string is stored in str and your array is stored in arr):
var start = str.indexOf(arr.join(""));

You could also get rid of the spaces from your array and pass the space to join instead, for a smaller array.

A: var text = $("h5").text(); // Get the text from your h5.
var searchText = "apple is the";
var found = []
function findAll(string) {
  var startIdx = string.search(searchText);
  var endIdx = startIdx + searchText.length;
  if(startIdx == -1) {
    return;
  }
  else {
    found.append([startIdx, endIdx]);
    findAll(string.substring(endIdx, string.length));
  }
}
findAll(text);

This will recursively search the string until all instances of searchText is found.
Each occurrence is stored as a list of begin and end indexes [[start, end],[start,end],...] in found


text:
Q: Subdomain staging wordpress site error establishing a database connection I'm using subdomain to launch staging site i pushed all the files to subdomain file i edited wp-config to rename db name and db user to the exact names then i edited wp-optionin on mysql to redirect home link but when i run the website i get the error message.

*

*I'm using PHP Version 8.0.13

*I checked my db privileges and they're all checked

*I tried to add staging url in wp-config but i got blank white page.

define('WP_HOME','http://'subdomainname'.mywebisteurl.com/');
define('WP_SITEURL','http://'subdomainname'.mywebisteurl.com/'

I changed debug to true in wp-config and this line of error comes out when i run the staging site

Warning: mysqli_real_connect(): (HY000/1045): Access denied for user
'dbname'@'localhost' (using password: YES) in /wp-includes/wp-db.php
on line 1753

mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );

I figured out how to solve the database establishing error i just changed my db password without special letters and it worked
but when i run the site i got bigger errors now

Warning:
require_once(/wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors-loader.php):
Failed to open stream: No such file or directory in
/wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors.php
on line 33

require_once ASTRA_THEME_HEADING_COLORS_DIR . 'class-astra-heading-colors-loader.php';// phpcs:ignore: WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound

Fatal error: Uncaught Error: Failed opening required '/wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors-loader.php' (include_path='.:/opt/alt/php80/usr/share/pear:/opt/alt/php80/usr/share/php:/usr/share/pear:/usr/share/php') in /wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors.php:33 Stack trace: #0 /wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors.php(45): Astra_Heading_Colors->__construct() #1 /wp-content/themes/astra/functions.php(156): require_once('/home/dbname...') #2 /wp-settings.php(555): include('/home/dbname...') #3 /wp-config.php(177): require_once('/home/dbname...') #4 /wp-load.php(50): require_once('/home/dbname...') #5 /wp-blog-header.php(13): require_once('/home/dbname...') #6 /index.php(17): require('/home/dbname...') #7 {main} thrown in /wp-content/themes/astra/inc/addons/heading-colors/class-astra-heading-colors.php on line 33


text:
Q: Is StartDateTime on an Event set to UTC or GMT? Documentation leads me to say these times are set to UTC always;

If the Event IsAllDayEvent flag is set to false (indicating that it is not an all-day event), then the event start date information is contained in the StartDateTime field. The time portion is always transferred in the Coordinated Universal Time (UTC) time zone. You need to translate the time portion to or from a local time zone for the user or the application, as appropriate.

but when I try adding a recurring event which crosses a time when clocks move forward/backward the hours changes when running a SOQL in the developer console. See below;

select id, subject, startdatetime from Event order by startdatetime

You can see the hour goes back from 8am to 7am during the weekend of 6th October, but UTC time never changes, so this is GMT surely no?!

A: Edited
Cordinated Universal Time or UTC is a time standard that is used to keep time synchronized across the world while Greenwich Mean Time - GMT (UTC-0) is the same time zone as the UTC base time zone standard but predates it by 300 years.
Time zones around the world are expressed using positive or negative offsets from UTC, as in the list of time zones by UTC offset. The westernmost time zone uses UTC−12, being twelve hours behind UTC; the easternmost time zone, uses UTC+14, being fourteen hours ahead of UTC. In 1995, the island nation of Kiribati moved those of its atolls in the Line Islands from UTC−10 to UTC+14 so that Kiribati would all be on the same day.
From Wikepedia:

UTC does not change with a change of seasons, but
  local time or civil time may change if a time zone jurisdiction
  observes daylight saving time (summer time). For example, local time
  on the east coast of the United States is five hours behind UTC during
  winter, but four hours behind while daylight saving is observed
  there.[26]

To answer your question more specifically, Salesforce stores all records in UTC which does not change. Records are then opened in the user's local time. If the local time jurisdiction observes daylight saving time, the time will be adjusted accordingly.


text:
Q: I need to define the cubic equation $f(x)= ax^3 + bx^2 + cx + d$ It is given that if cubic function $f(x)$ is divided by $(x^2+4)$ and $(x+3)$, the remainders will be $7x-20$ and $-2$ respectively. Also it is said show that $f(x)$ is $x^3 + 6x^2 + 11x +4$. I tried but can i find the $a,b,c$, and $d$ without knowing them in from the start?

A: $f(x) = (x^2 + 4)(ax +b) +7x - 20$
$f(-3)=-2 = 13(-3a+b)-41 $
therefore $b= 3a+3$
so, $f(x)= (x^2+4)(ax +3a+3)+ 7x-20 $  (non-zero $a$)

A: A simple method (based on the chinese remainder theorem) goes as follows:
To solve $f \operatorname{mod} p = u$ and $f \operatorname{mod} q =  v$ (where p and q are coprime polynomials):
put $\ \bar{p} = p^{-1}\operatorname{mod} q$ and $\ \bar{q} = q^{-1}\operatorname{mod} p$
then $f = vp\bar{p}+uq\bar{q}$. Indeed we have $ f = upp^{-1}\operatorname{mod} q = u$ and $ f = vqq^{-1}\operatorname{mod} p = v$.
In this case we have for $p = x^2+4$, $q = x+3$, $u = 7x-20$ and $v=-2$ that $\bar{p} = -\frac{x}{39}$ and $\bar{q} = -\frac{x}{13}+\frac{3}{13}$ so that $f = -\frac{19}{39}x^3+\frac{20}{13}x^2+\frac{197}{39}x-\frac{180}{13}$. But this only one of the many solutions, the all differ by a multiple of $pq$. In this case $f + \frac{58}{39}\ pq\ $ yields the given polynomial.

A: Solving in pari/gp:
? chinese(Mod(7*x-20,x^2+4),Mod(-2,x+3))
%1 = Mod(3*x^2 + 7*x - 8, x^3 + 3*x^2 + 4*x + 12)
?
? Mod(a*x^3+b*x^2+c*x+d,(x^2+4)*(x+3))
%2 = Mod((-3*a + b)*x^2 + (-4*a + c)*x + (-12*a + d), x^3 + 3*x^2 + 4*x + 12)

I.e. $3=-3a+b$, $7=-4a+c$, $-8=-12a+d$.
And $\quad a=1\quad\Longrightarrow\quad b=6,c=11,d=4$.


text:
Q: How do mount tools, helpers, and calls relate? man 8 mount says mount uses helpers in /sbin/ (such as mount.exfat, mount.fuse, and mount.ntfs). man 2 mount doesn't mention helpers. The corresponding umount pages showed the same thing.
My ls /sbin | grep mount shows:
mount.cifs
mount.ecryptfs
mount.ecryptfs_private
mount.exfat
mount.exfat-fuse
mount.fuse
mount.lowntfs-3g
mount.ntfs
mount.ntfs-3g
umount.ecryptfs
umount.ecryptfs_private
umount.udisks2

*

*Why doesn't man 2 mount mention the helpers?

*What does mount/umount do with filesystems that don't have a helper?

*Why do filesystems have a helper for mount, umount, both, or neither?

A: System manuals were "sectioned" some time ago. The sections are listed here for various OS. Section 2 is for "System Calls"; i.e. documentation on how a program requests a service provided by the kernel in this case.
Also note that in man 2 mount, it does provide for a full range of filesystem types as defined in /proc/filesystems - filesystemtype is an argument in the mount function call. If you compare the list in /proc/filesystems to the output of ls /sbin | grep mount, you will see some commonality.
And so one way to look at this is that the mount syscall does have "helpers" - the "helpers" are the value of the filesystemtype argument. Another way to look at it is that Section 2 of man mount is for system programmers, whereas man 8 mount (or just man mount) is for system users and administrators. The user's interface to the kernel service is through a command named mount; system programmers interface to the same kernel service is via the mount function.
Something for everyone...


text:
Q: How to get the column of the beginning of a line in vim script In vim script, col("$") will return the column # of the end of the line. I want something similar to get the column # for the beginning of the line, something like col("^"). But that doesn't work, nor can I find anything that does that.
I want this so that I know the amount of white-space at the beginning of a line.

A: Do you mean something like this?
indent(line("."))

A: The best I can come up with right now to do this is
normal! ^
col(".")

That's not an ideal solution, though, because I'm essentially just moving the cursor where I want and then checking the column.


text:
Q: External Stylessheets with puppeteer I am trying to get all the external stylesheets in puppeteer Js and i am not getting only one.
here is my code:
try {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    page.on('response', async response => { // don't await anything on this line
        if(response.request().resourceType() === 'stylesheet') {
            resolve(response.text()); // await and resolve here
        }
    });

    await page.goto(url);
    await browser.close();
    // don't resolve here
} catch (e) {
    return reject(e);
}

The problem here is when i have more than 1 external stylesheets i am not able ot get them. How would i achieve that

NOTE: I am using resolve because i need the stylesheets for further
  processing. and ineed them returned.

A: You can add all stylesheets (or their Promises) to an array and then resolve it, after the page is loaded and the Promises are resolved.
Code
try {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    const stylesheetPromises = [];

    page.on('response', async response => {
        if(response.request().resourceType() === 'stylesheet') {
            stylesheet.push(response.text());
        }
    });

    await page.goto(url);
    await browser.close();
    const stylesheets = await Promise.all(stylesheetPromises);
    resolve(stylesheets);
} catch (e) {
    return reject(e);
}

The Promise (which I assume this code is inside) is then resolved with an array of strings containing all the stylesheets. This is done by adding all the Promises of response.text() to an array, which we finally await via Promise.all. After that the results are returned.


text:
Q: Which ASP.NET technology would be best for a URL trigger filter? I'd like to write a URL trigger filter in ASP.NET that would accept a trigger request (in this case from a Kiln web hook), analyze the contents of the request, and based on the contents either throw the request away (filter it) or pass it on to another URL (Jenkins).
There's really no UI to this filter so what's the best type of ASP.NET project to use: an ASP.NET Handler, ASP.NET Module, Generic Handler, or something else?

A: Looks like a typical HTTP Module.
You can register to a event at the init function and add your logic.
MSDN
CodeProject
MSDN - Example

A: This is a relatively simple requirement, so an HTTP Module would quite possibly work for you, and it'd be the most light-weight approach.
However, if it were me, I'd probably use WebApi, which is built for handling RESTful requests. This will make the "analyze the contents of the request" requirement much simpler, and probably give you additional flexibility if you want to transform the request before passing it on to Jenkins in the future.


text:
Q: how to fix scale 1:4000 to export map in PDF ol3 This is my code to export map in pdf but i want to fix this map in 1:4000 scale the n export or print it to pdf.
var dims = {
  a0: [1189, 841],
  a1: [841, 594],
  a2: [594, 420],
  a3: [420, 297],
  a4: [297, 210],
  a5: [210, 148]
  };

  var exportElement =  document.getElementById("export-pdf");
  exportElement.addEventListener('click', function(e) {
        console.log("hi");
  if (exportElement.className.indexOf('disabled') > -1) {
    return;
  }
  exportElement.className += ' disabled';

  var format = document.getElementById('format').value;
  var resolution = document.getElementById('resolution').value;
  var buttonLabelElement = document.getElementById('button-label');
  var label = buttonLabelElement.innerText;
  var dim = dims[format];
  var width = Math.round(dim[0] * resolution / 25.4);
  var height = Math.round(dim[1] * resolution / 25.4);
  var size = /** @type {ol.Size} */ (map.getSize());
  var extent = map.getView().calculateExtent(size);

  map.once('postcompose', function(event) {
    //var tileQueue = map.getTileQueue();

    // To prevent potential unexpected division-by-zero
    // behaviour, tileTotalCount must be larger than 0.

    //var tileTotalCount = tileQueue.getCount() || 1;
    var interval;
    interval = setInterval(function() {
      //var tileCount = tileQueue.getCount();
      //var ratio = 1 - tileCount / tileTotalCount;
      //buttonLabelElement.innerText = ' ' + (100 * ratio).toFixed(1) + '%';
      //if (ratio == 1 && !tileQueue.getTilesLoading()) {
        clearInterval(interval);
        buttonLabelElement.innerText = label;
        var canvas = event.context.canvas;
        var data = canvas.toDataURL('image/jpeg');
        var pdf = new jsPDF('landscape', undefined, format);
        pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
        pdf.save('map.pdf');
        map.setSize(size);
        map.getView().fit(extent, size);
        map.renderSync();
        exportElement.className =
            exportElement.className.replace(' disabled', '');
     // }
    }, 100);
  });

  map.setSize([width, height]);
  map.getView().fit(extent, /** @type {ol.Size} */ (map.getSize()));
  map.renderSync();

}, false);

any help would be highly appriciated.
I updated the code us per your suggestion still map is not exported to pdf.
//print map
    var dims = {
  a0: [1189, 841],
  a1: [841, 594],
  a2: [594, 420],
  a3: [420, 297],
  a4: [297, 210],
  a5: [210, 148]
  };

  var exportElement =  document.getElementById("export-pdf");
  exportElement.addEventListener('click', function(e) {
        console.log("hi");
  if (exportElement.className.indexOf('disabled') > -1) {
    return;
  }
  exportElement.className += ' disabled';

  var format = document.getElementById('format').value;
  var resolution = document.getElementById('resolution').value;
  var buttonLabelElement = document.getElementById('button-label');
  var label = buttonLabelElement.innerText;
 var scale = 4000;

var mapView = map.getView();
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);

var dim = dims[format];
var width = Math.round(dim[0] * resolution / 25.4);
var height = Math.round(dim[1] * resolution / 25.4);
var size = map.getSize();
var extent = map.getView().calculateExtent(size);

var mapView = map.getView();
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapResolutionAtEquator = mapView.getResolution();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);
var mapResolutionFactor = mapResolutionAtEquator / mapPointResolution;

map.once('rendercomplete', function(event) {
    console.log('hiiii');
     buttonLabelElement.innerText = label;
  var canvas = event.context.canvas;
  var data = canvas.toDataURL('image/jpeg');
  var pdf = new jsPDF('landscape', undefined, format);
  pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
  pdf.save('map.pdf');
  map.setSize(size);
  map.getView().fit(extent, size);
   exportElement.className =
            exportElement.className.replace(' disabled', '');
});

var printPointResolution = (scale * dim[0]) / (width * 1000);
var printResolutionAtEquator = mapResolutionFactor * printPointResolution
var printZoom = mapView.getZoomForResolution(printResolutionAtEquator);

map.setSize([width, height]);
mapView.fit(extent, (map.getSize()));
mapView.setZoom(printZoom);

}, false);

A: Since I'm not familiar with ol3, this will be for ol5.
To print in desired scale we neeed to calculate the zoom at which printed map will have that scale. First we need formula to calculate scale of printed map:
var scale =  (width * mapPointResolution * 1000) / dim[0];

where mapPointResolution is map resolution at the center of displayed map:
var mapView = map.getView();
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);

We will also need mapResolutionFactor:
var mapResolutionFactor = mapResolutionAtEquator / mapPointResolution;

EDIT1: Original calculation of printPointResolution was wrong because it didn't take into account print DPI resolution. To get the correct value two different formulas for print width in pixels have to be combined:
width = (scale * printDim[0]) / (mapPointResolution * 1000);
width = printDim[0] * resolution / 25.4;

From this we get map point resolution for print at desired scale:
mapPointResolution = (scale * 25.4) / (resolution * 1000);

And finally from this we can get required zoom for print:
printResolutionAtEquator = mapResolutionFactor * printPointResolution;
printZoom = mapView.getZoomForResolution(printResolutionAtEquator);

To put all this togeter (just the print part):
var scale = 4000;

var mapView = map.getView();
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);

var dim = dims[format];
var width = Math.round(dim[0] * resolution / 25.4);
var height = Math.round(dim[1] * resolution / 25.4);
var size = map.getSize();
var extent = map.getView().calculateExtent(size);

var mapView = map.getView();
var currZoom = mapView.getZoom();  //edit2
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapResolutionAtEquator = mapView.getResolution();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);
var mapResolutionFactor = mapResolutionAtEquator / mapPointResolution;

map.once('rendercomplete', function(event) {
  var canvas = event.context.canvas;
  var data = canvas.toDataURL('image/jpeg');
  var pdf = new jsPDF('landscape', undefined, format);
  pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
  pdf.save('map.pdf');
  map.setSize(size);
  // map.getView().fit(extent, size);  //edit2: not needed
  mapView.setZoom(currZoom);  // edit2: set original zoom
});

var printPointResolution = (scale * 25.4) /(resolution * 1000);  // edit1: corrected
var printResolutionAtEquator = mapResolutionFactor * printPointResolution;
var printZoom = mapView.getZoomForResolution(printResolutionAtEquator);

map.setSize([width, height]);
// mapView.fit(extent, (map.getSize())); - edit1: removed, not neccessary
mapView.setZoom(printZoom);

EDIT2: Corrected code to return to original zoom after print.

A: Here is solution for ol3. Base code is taken from ol3 export to PDF example https://openlayers.org/en/v3.20.1/examples/export-pdf.html.
ol3 does not have getZoomForResolution view method, so I took simplifed formula just for this example from getZoom method:
desiredZoom = Math.log(mapView.getMaxResolution() / reqiredResolution) / Math.log(2);

The code for export to PDF at desired scale then looks like this:
var printScale = 4000;

var dim = dims[format];
var width = Math.round(dim[0] * resolution / 25.4);
var height = Math.round(dim[1] * resolution / 25.4);
var size = map.getSize();
var extent = map.getView().calculateExtent(size);

var mapView = map.getView();
var currZoom = mapView.getZoom();  // edit1
var mapProjection = mapView.getProjection();
var mapResolutionAtEquator = mapView.getResolution();
var viewCenter = mapView.getCenter();
var mapResolutionAtEquator = mapView.getResolution();
var mapPointResolution = ol.proj.getPointResolution(mapProjection, mapResolutionAtEquator, viewCenter);
var mapResolutionFactor = mapResolutionAtEquator / mapPointResolution;

var source = raster.getSource();

var tileLoadStart = function() {
  ++loading;
};

var tileLoadEnd = function() {
  ++loaded;
  if (loading === loaded) {
    var canvas = this;
    window.setTimeout(function() {
      loading = 0;
      loaded = 0;
      var data = canvas.toDataURL('image/png');
      var pdf = new jsPDF('landscape', undefined, format);
      pdf.addImage(data, 'JPEG', 0, 0, dim[0], dim[1]);
      pdf.save('map.pdf');
      source.un('tileloadstart', tileLoadStart);
      source.un('tileloadend', tileLoadEnd, canvas);
      source.un('tileloaderror', tileLoadEnd, canvas);
      map.setSize(size);
      // map.getView().fit(extent, size);  edit1: not needed
      mapView.setZoom(currZoom);  // edit1: return to original zoom
      map.renderSync();
      exportButton.disabled = false;
      document.body.style.cursor = 'auto';
    }, 100);
  }
};

map.once('postcompose', function(event) {
  source.on('tileloadstart', tileLoadStart);
  source.on('tileloadend', tileLoadEnd, event.context.canvas);
  source.on('tileloaderror', tileLoadEnd, event.context.canvas);
});

var mapView = map.getView();
var printPointResolution = (printScale * 25.4) / (resolution * 1000)
var printResolutionAtEquator = mapResolutionFactor * printPointResolution;
var printZoom = Math.log(mapView.getMaxResolution() / printResolutionAtEquator) / Math.log(2);

map.setSize([width, height]);
mapView.setZoom(printZoom);

map.renderSync();

EDIT1: Corrected code to return to original zoom after print.


text:
Q: Html video in webView I have a wkWebView where through a scriptAPI I upload a video and play it. There are two questions.

1) When a video is only loaded it is very small, and then when it
  plays it becomes full screen. How to make it full screen at once?
2)How can I automatically switch to another at the end of the video
  view controller?

@IBOutlet weak var backgroundView: UIView!

    var webView: WKWebView!
    var videoURL:URL!
    var didLoadVideo = false

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        if !didLoadVideo {
            webView.loadHTMLString(embedVideoHtml, baseURL: nil)
            didLoadVideo = true
        }

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setupWebView()

       videoURL = URL(string: "https://www.youtube.com/embed/kBVxMvATaFU")

    }

    func setupWebView() {
        let webConfiguration = WKWebViewConfiguration()
        if #available(iOS 10.0, *) {
            webConfiguration.mediaTypesRequiringUserActionForPlayback = []
        } else {
            // Fallback on earlier versions
            webConfiguration.mediaPlaybackRequiresUserAction = false
        }
        webConfiguration.allowsInlineMediaPlayback = true

        webView = WKWebView(frame: CGRect(x: 0, y: 0, width: backgroundView.frame.width, height:  backgroundView.frame.height), configuration: webConfiguration)
        webView.uiDelegate = self

        self.backgroundView.addSubview(webView)

    }

    var embedVideoHtml:String {
        return """
        <!DOCTYPE html>

        """
    }


text:
Q: How to retrieve random elements from a Python 3 generator? Someone suggested this for generating combinations: this will give me combinations, but, will not have the desired propoerties (for which post processing is needed) as mentioned in the end of my question.
Please understand, len(myList) = 10e6 and desired combinations even larger.
I am working with graphs.

Lets say I have a very large list. I am generating combinations for this list using itertools. What I want to achieve is to select the elements at random, without materializing the generator (it is too big even for 16 GB of RAM, I learnt that the hard way).
Here, is what I have done so far:
import itertools
import random

myList = [('abc',1), ('bcd',2), ('cdef',3), ('adcv',4), ('zofd',5), ('qmkdf',6), ('qmk',7), ('oswd',8)]
# actual list is much larger than above in my case

myCombi_gen = itertools.combinations(myList, r=2)
# Above should generate: [(('abc',1), ('bcd',2)), (('abc',1), ('cdef',3)), .....]

N = 15
counter = 0

for elem in myCombi_gen:
    if random.random() > 0.5:       # selecting based on probability
        print(elem, end=' ')
        counter+=1
        # doing something useful here
        if counter == N:
            break

My problem is, the elements in the combinations that end up being selected are concentrated at a locality. I want them to be more uniformly spread out (may be some distribution?). Some heads up will be helpful.

Notes:
Even without the probabilistic selection I need only a fraction of the combinations. That simply picks up the first N elements if randomised selection is not used. Code updated accordingly.
For clarity, for my specific case, I can't do the following:
# Cannot do the following, memory (RAM) usage blows up

all_combi = list(itertools.combinations(myList, r=2))
random.shuffle(all_combi)
selected_combi = random.sample(all_combi, N)

A common approach suggested by many seems to be, why not sample myList and then generate combinations? No. I have updated the structure of myList for better understanding. It is sorted and has to remain so. itertools.combinations generates sorted combinations which suits my purpose, that is why I used it (I am open to any other combination generator). I want the sampling to be performed on the combinations, not on the original elements of myList.
# This approach is unacceptably slow (though I didn't time it):

# making random combinations of size 2
selected = set()
while True:
    left = random.choice(myList)
    right = random.choice(myList)

    if left[1] < right[1] and left[0] != right[0] and (left, right) not in selected and (right, left) not in selected:
        selected.add((left, right))
    if len(selected) == N:
        break

A: Use more_itertools. With 1M permutations, it takes less than 1 minute.
random_combination:

Return a random r length subsequence of the elements in iterable.
This equivalent to taking a random selection from
itertools.combinations(iterable, r).

from more_itertools import random_combination, random_permutation
import string

s = string.ascii_letters
g = {tuple(random_permutation(s)) for i in range(1000000)}

result = set()

while len(result) != 15:
    if (c := random_combination(g, r=2)) not in result: result.add(c)

A: This should help with solving the localization problem.
import random

N = 15
counter = 0

# List of data
myList = [['abc', 'bcd', 'cdef', 'adcv', 'zofd', 'qmkdf', 'qmk', 'oswd'],
          ['zbc', 'zcd', 'zdef', 'zdcv', 'zofd', 'zmkdf', 'zmk', 'zswd'],
          ['ahhc', 'gcd', 'fdef', 'fdcv', 'gofd', 'gmkdf', 'gmk', 'gswd']]

num_lists = 2

while counter < 15:

    # Randomly select n lists
    sampled_lists_index = random.sample(list(range(len(myList))), num_lists)

    for i in sampled_lists_index:
        # print(i)
        print(random.sample(myList[i], 1)[0], end=" ")

    # Taking care of the formatting
    print("\n")

    counter += 1

A: Specifically for the question:
from more_itertools import random_combinations as rc

N = 15

myList = [('abc',1), ('bcd',2), ('cdef',3), ('adcv',4), ('zofd',5), ('qmkdf',6), ('qmk',7), ('oswd',8)]

result = set()

while len(result) != N:
    c = rc(myList, r=2)
    if c not in result:
        result.add(c)

this will produce the following:
{(('qmkdf', 6), ('qmk', 7)), (('cdef', 3), ('zofd', 5)), (('adcv', 4), ('zofd', 5)), (('bcd', 2), ('cdef', 3)), (('bcd', 2), ('qmk', 7)), (('adcv', 4), ('qmk', 7)), (('bcd', 2), ('adcv', 4)), (('abc', 1), ('zofd', 5)), (('abc', 1), ('oswd', 8)), (('cdef', 3), ('oswd', 8)), (('adcv', 4), ('qmkdf', 6)), (('cdef', 3), ('qmkdf', 6)), (('bcd', 2), ('oswd', 8)), (('abc', 1), ('qmkdf', 6)), (('bcd', 2), ('qmkdf', 6))}

Please note that the combinations are random yet follow the sort order.


text:
Q: Getting alert dialog properties I want to check if dialog is showing and if it is then save its title, message, button titles in onSaveInstanceState() method and display an alert with saved properties next time activity is restored from saved bundle.

A: One solution is to switch to a dialog fragment http://developer.android.com/guide/topics/ui/dialogs.html. That fragment can retain its instance automatically.

A: I think you should have your custom dialog,which will store the info you need.

A: I suggest you to use alert.isShowing() [alert is object of AlertDialog] to know alertdialog is showing or not. And then you can save data into onSaveInstanceState() method.


text:
Q: Conditional compiling/linking with gcc I have scientific simulation code written in C that runs from the command line. The user provides an input model as a set of C subroutines in a model.c file that are then compiled into code at runtime.
Certain model properties are not always relevant for a specific problem but currently the user still needs to provide an empty dummy function for that property in order for the code to compile.
Is it possible to have dummy subroutines for the model properties embedded in the source code that are linked only if the user-provided model.c does not contain a subroutine for that property?
As an example, if model.c contains a subroutine called temperature(), the code should link to that one, rather than the subroutine called temperature() found in src/dummy_function.c. If model.c does not have temperature() the compiler should use the dummy function in src/dummy_function.c.
If possible, I would prefer a solution that does not require preprocessor directives in the model.c file.

A: Yes you can. Suppose you have simple code in file, say undesym.c:
int
main(void)
{
  user_routine();
  return 0;
}

Create weak stub in say file fakeone.c
#include "assert.h"

int  __attribute__((weak))
user_routine(void)
{
  assert(0 == "stub user_routine is not for call");
  return 0;
}

Now create "user" function in, say goodone.c
#include "stdio.h"

int
user_routine(void)
{
  printf("user_routine Ok\n");
  return 0;
}

Now if you will link together gcc undesym.c fakeone.c then a.out will run to assert, but if you will add goodone.c to compilation, like gcc undesym.c fakeone.c goodone.c, then it will prefer strong definition to weak, and will run to message.
You may adopt the same mechanism, defining default functions weak.

A: Since you say that the user's subroutines are "compiled into the code at runtime", you could use dynamic linking to load a user-provided binary and look for their entry points at runtime. In linux (or any POSIX system), this would be based on dlopen()/dlsym() and look more or less like this:
#include <dlfcn.h>

/* ... */

/* Link the UserModule.so into the executable */
void *user_module = dlopen("UserModule.so", RTLD_NOW);

if (!user_module) {
    /* Module could not be loaded, handle error */
}

/* Locate the "temperature" function */
void *temperature_ptr = dlsym(user_module, "temperature"):

if (!temperature_ptr) {
    /* Module does not define the "temperature" function */
}

void (*user_temperature)() = (void(*)())temperature_ptr;

/* Call the user function */
user_temperature();

See the dlopen documentation for details. A similar facility is very likely available in whatever OS you're using.