text:
Q: Twitter-bootstrap: How to use row-fluid class properly? I have a problem understanding how row-fluid class works. According to the documentation it adjusts itself to fluid design such as responsive design. So if it has enough space it makes it fit on the same row otherwise it goes to the next line.
However looking at this example here : https://duelify.com/
Strangely enough the first three article headers fit on first row.
Second row and rest are slightly pushed to the right. But looking at the html (below) no additional classes are involved to cause this 'side effect'.

Why aren't the article headers fitting in the one row. Why is there this random gap in between? Is there a way to make them appear ordered without any gaps in between?

A: There are a couple of things going on here. Remember, by default, the total size of the spans in a fluid-row should add up to 12. There is quite a bit more here, so when the css defines the width of a span4 as approximately 33% they are actually exceeding 100%, so they are going to a new line. But they are not clearing, so you end up with them looping around and making columns like on the page.
The reason you have the space to the left of what would be the second row is that bootstrap defines 'gutters' to give the columns some margin. Because of the excess columns being used you see them. There is specific css to reduce the gutter on the first span of a row to 0, hence why there is no space on the first one.
The subsequent 'rows' have only two columns because the presence of the additional gutter throws off the math and makes the three span4s add up to more than 100% width, causing them to wrap.

A: In your case, proper code will be like

etc...

In every row-fluid class maximum sum of span classes must be up to 12. Span classes have left margin. Only last child in one row-fluid don't have left margin.
Look again now at examples on Twitter Bootstrap documentation. "For a simple two column layout, create a .row and add the appropriate number of .span columns. As this is a 12-column grid, each .span spans a number of those 12 columns, and should always add up to 12 for each row (or the number of columns in the parent)."

A: The following code will work after container (for Responsive layout):


text:
Q: ¿Hay alguna alternativa sintáctica en esta query?

Se que esto es una solución:

Pero me gustaría saber si hay alguna otra alternativa, más en concreto, a la hora de formular la sintaxis para la fecha en que era director el empleado.

Me pregunto si hay alguna forma de formular lo mismo utilizando otra sintaxis.

A: Con el operador BETWEEN puedes hacerlo
Nota: OJO con los rangos siempre debes comprobar si los rangos son inclusivos o no, el BETWEEN toma ambos rangos inclusivamente, debes comprobar si lo datos en tu base de datos son así, asumo por tu consulta inicial que lo son, ya que agregaste <= y >=
select emp_no from dept_manager where '1990-01-01' BETWEEN from_date and to_date

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is it possible to "hide" a sub directory after rewriting root to that directory? What I'm trying to accomplish is basically hide the fact that the page is served from a subdirectory.
I currently have the following .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/blog
RewriteRule (.*) /blog/$1

This does what I want. It serves pages from /blog while giving the user the impression of being in the root directory.
However if the user visits http://www.example.com/blog they get the same page. If possible I would actually like them to get /blog/blog.
The main reason this worries me is not because of real users but because of robots that might index the page with the wrong URL.

A: This is possible but you have to cheat a little. Essentially THE_REQUEST never changes during rewriting so you can test for that.
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /blog
RewriteRule . - [F]
RewriteCond %{REQUEST_URI} !^/blog
RewriteRule (.*) /blog/$1

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond


text: Q: Using C# I want to create a bar chart that shows the count of each value in an excel column I have an excel sheet of raw data.  Using C# I would like to create a bar chart in excel of each value in one specific column (column c) and the number of times the value shows up.  I think I need to programmatically need to create a pivot chart in order to do this properly, but am unsure if this is the best way, and finding a good learning resource on how to properly implement it.  Any help would be greatly appreciated.


text:
Q: How to build static library for iOS on linux I have c++ static library written on linux.
Is it possible to build this library for iOS?
I have installed g++-arm-linux-gnueabi, but when i try to do this:
arm-linux-gnueabi-g++-4.7 main.cpp -o mn -march=armv7

output is:
target CPU does not support ARM mode

Thanks and sorry for my english

A: 0: If you don't have source code, then it's impossible. Else read below:
1: Create a new C/C++ library in XCode(Below OS X->Framework & Library).
2: Put ALL your header files into a dictionary(It's not a must but it will help a lot to organize your project later, and also your header import path).
3: Import your source code into library project.
4: Drag library project dictionary into project window you want to import. Remember ONLY keep header files outside library project, remove anything else to prevent some unexpected issue caused by XCode when compiling. It's hard to explain with words, just let me show you a screenshot:

5: Set dependencies & header search path, then you are good to go.
Sounds quite easy, right? Don't be fooled.
You will meet many detailed problems such as XCode can't find your header paths, link error(symbol not found), compiler error or using wrong C++ standards, CPU architecture..... etc.
But these can be solved, just give it a try, and it's worth trying :)

A: There is no supported way to build iOS applications or libraries on any platform other than Mac OS X.
Take the source code to the library to a Mac, import it into an Xcode project, and try there.


text:
Q: Nested UpdatePanel Triggers My child UpdatePanel updates both its contents and those of its parent UpdatePanel.
<asp:UpdatePanel ID="UpdatePanel1"
                 runat="server">
    ...
    <asp:UpdatePanel ID="UpdatePanel2"
                     runat="server">
        ...
    </asp:UpdatePanel>
    ...
</asp:UpdatePanel>

I don't want my parent UpdatePanel to be updated every time its child updates.

A: <asp:UpdatePanel ID="UpdatePanel1" ChildrenAsTriggers="False"
                 UpdateMode="Conditional"
                 runat="server">

</asp:UpdatePanel>

A: Set the UpdatePanel.UpdateMode Property to Conditional.
<asp:UpdatePanel ID="UpdatePanel1"
                 UpdateMode="Conditional"
                 runat="server">
    ...
</asp:UpdatePanel>

Project Cool:

Child Update Panel refreshes only its
contents and doesnt refresh that of
the Parent Update Panel unless, the
update mode for the parent update
panel is not set to Conditional

CodeClimber:

When set to Conditional, the
UpdatePanel will be updated only on
postback originated by controls inside
the panel or from the triggers
specified. So, if you have multiple
update panels and you don't want to
update all of them to be updated every
time, you have to set the UpdateMode
to Conditional.

A: This is what I do
<asp:UpdatePanel ID="UpdatePanel1" ChildrenAsTriggers="False"
                 UpdateMode="Conditional" runat="server">
    ...
    <asp:UpdatePanel ID="UpdatePanel2" ChildrenAsTriggers="False"
                 UpdateMode="Conditional" runat="server">
        ...
    </asp:UpdatePanel>
    ...
</asp:UpdatePanel>

In the code behind after binding UpdatePanel2 Controls with data, call UpdatePanel2.Update();
Ajax updates only HTML markup in "UpdatePanel2".


text:
Q: A field initializer cannot reference the non-static field, method, or property when i try to access a list I try to make 2d Minecraft but when i try to access the list, This Error Happen:
"A field initializer cannot reference the non-static field, method, or property"
The Script:
    [SerializeField] Generator Generator;
    GameObject[] terrain = Generator.terrain;
    public void show()
    {
        foreach (GameObject g in terrain)
        {
            Vector3 pos = new Vector3(transform.position.x,transform.position.y,0);
            Instantiate(grass, pos, Quaternion.identity);
        }
    }

I want to access the list and use the Game Object Inside it.


text:
Q: Using custom C# class library in another project I built a class library as a NuGet package to be used in another C# project.  When I built the class library, I followed a tutorial that suggested targeting .NET Standard 2.0.
I installed the package into the other project and it builds fine.  However, I've noticed that the output folder contains several other 'System.' dlls (ie. System.AppContext.dll).
In the past, when I've built a class library for C++, I did not get the dependent dlls copied to the output folder.  I had assumed that building a C# class library would act the same way.  For C++, those dependent dlls are resolved at runtime by the C++ redistributable dlls.  I thought the same would be true in that C# would resolve them through the installed framework.
So, I'm a bit confused as to why the extra dlls are present in the output folder.  Is it because I targeted .NET Standard 2.0?  Do I need to ship the extra dlls with my application?


text:
Q: Custom contour labels in ContourPlot Suppose I wanted to draw the zero contour for the function
$$d^2-g.$$
I could use the following code:
ContourPlot[d^2-g,{g,0,1},{d,0,1},Contours->{0},
              ContourStyle->Black,ContourShading->None,FrameLabel->{"g","d"}]

Which produces this:

Taking this one step further, I might want to plot the zero contour for
$$td^2-g.$$
at various values of $t$, which I could achieve functionally with
Show[Table[ContourPlot[t*d^2-g,{g,0,1},{d,0,1},Contours->{0},
         ContourStyle->Black,ContourShading->None,FrameLabel->{"g","d"}],{t,0.1,1,0.1}]]

producing this:

Now, to make this easier to understand, I want to label each contour with its corresponding value of $t$, but this is where I run into trouble. I had thought that this could be achieved with the option
ContourLabels->t

but that yields this:

(it seems to have moved the labels rather than changing them). Does anyone know how to get Mathematica to draw a label equal to the relevant value of t on each of these contours?
Secondly, assuming I can get that working, how can I reposition the labels towards the top of the contours so that they appear where the contours are furthest apart.

A: One quick way, not very general, is to use custom ticks :
ContourPlot[#*d^2 - g & /@ Range[0.1, 1, 0.1], {g, 0, 1}, {d, 0, 1}, Contours -> {0},
 ContourStyle -> Black, ContourShading -> None, FrameLabel -> {"g", "d"},
 FrameTicks -> {{Automatic, None}, {Automatic, Range[0.1, 1, 0.1]}},
 FrameTicksStyle -> {{Automatic, Automatic}, {Automatic, Red}}]

A: I'm revisiting this topic because I have a new solution at the bottom of the post. The outline of this answer is:
Interactively labeling contours

*

*Using the graphics editor

*Using Tooltip

*Converting Tooltip displays to static labels at custom positions

Section 1 was my original answer, the other two are new.
1. Using the graphics editor
What I usually do is label the contours by hand with the help of the drawing tools. For that you first have to know what labels belong to which contour. In your example, the label you want is the parameter t, so to get myself oriented I first defined a ContourLabels function that can display that number:
labelFunction[t_][x_, y_, z_] := Text[t, {x, y}]

Show[Table[
  ContourPlot[t*d^2 - g, {g, 0, 1}, {d, 0, 1}, Contours -> {0},
   ContourStyle -> Black, ContourShading -> None,
   FrameLabel -> {"g", "d"}, ContourLabels -> labelFunction[t]], {t,
   0.1, 1, 0.1}]]

I left all the other things unchanged in your example.
Then I re-did the plot without ContourLabels (just delete that option), and highlighted the resulting plot by clicking on it. Next, press t and click where you want to add the first manually placed contour label. Type the number for the contour, and click outside the text to accept the label. press t  again to start adding the next contour label at your desired position, etc.

After entering the labels like this, you can also double-click each label and edit it further, e.g. by moving it around if you don't like your original choice of placement.
How permanent are these annotations?
One problem that always makes me feel uneasy about using the editing tools is that manual annotations appear less permanent because they don't get reproduced when you re-run the notebook. However, it's worth pointing out that manual annotations aren't all that bad in practice:
Assume you want to re-do the last plot above, keeping the labels but coloring the contours differently. The colors could be added like this:
coloredPlot =
 Show[Table[
   ContourPlot[t*d^2 - g, {g, 0, 1}, {d, 0, 1.5}, Contours -> {0},
    ContourStyle -> Hue[t], ContourShading -> None,
    FrameLabel -> {"g", "d"}], {t, 0.1, 1, 0.1}]]

Note that I added ContourStyle -> Hue[t] and also changed the plot range in the vertical direction. But now of course the labels are gone again. Fortunately, you can copy the contour labels from the previous plot as follows:

Here I double clicked one label, then shift-clicked the others to select them  all. Now I pressed the copy keyboard shortcut and go back to the colored plot coloredPlot I just produced.
Next, type the following:

Here, I pasted the previously copied labels into the Show command. Executing this line, I get the labels at the correct absolute plot coordinates in the new plot.
The conclusion from this is that the manual labor involved in making the labels as I showed above is not completely wasted when you re-draw the contour plot, because copying your work preserves the coordinates of the insets.
2. Using Tooltip
Normally, Tooltip is the easiest way to label contours because that's the default behavior of ContourPlot when no ContourLabels option is specified.
However, we want to label contours by a Tooltip showing a custom quantity,  not the default which is contour height. In the documentation for ContourLabels (under Details), you find that custom tool tips should be available by specifying
ContourLabels -> {f, g}

where the second function, g, is used "as a tooltip for each complete contour line." This is very ambiguously worded, and it seems to have had people stumped (see the MathGroup archive). It turns out that g isn't the function that specifies the argument for the Tooltip, it actually has to be of Head Tooltip.
So in the example of the question, for a Table of several contour plots where each contour is custom labeled by the Table index t, we can get a tooltip-labeled plot like this:
toolPlot = Show[
 Table[
  ContourPlot[t*d^2 - g, {g, 0, 1}, {d, 0, 1}, Contours -> {0},
   ContourStyle -> Black, ContourShading -> None,
   FrameLabel -> {"g", "d"},
   ContourLabels -> {
     None,
     Tooltip[#, t] &}
   ],
  {t, 0.1, 1, 0.1}
  ]
 ]

The first function in ContourLabels is simply set to None so we don't get any static labels at all. The second argument shows how you get the Tooltip labeling "each complete contour line," as the documentation put it.
Now we're done debugging the mysterious documentation, and it's time for the fun part:
3. Converting Tooltip displays to static labels at custom positions
Here we ask the question:
Given a graphics object such as toolPlot from above, can we convert the information contained in the Tooltips into static labels and position these labels interactively?
This is different from adding labels completely manually, because we're going to rely on the auto-generated information in the Tooltip and only leave the choice of position as a manual task.
For this, I'll use the same idea as in my answer to this question, but modified to get a dynamically updated graphic that includes labels wherever I click on a Tooltip-decorated line:
Options[burnTooltips] = {ImageSize -> 360,
   "LabelFunction" -> (Framed[#, FrameStyle -> None,
       RoundingRadius -> 8, Background -> RGBColor[1, .8, .4]] &)};

burnTooltips[plot_, opt : OptionsPattern[]] := DynamicModule[
  {
   ins = {},
   wrapper = OptionValue["LabelFunction"],
   toolRule = Function[{arg},
     Tooltip[t__] :> Button[
       Tooltip[t],
       AppendTo[
        arg,
        Inset[wrapper[Last[{t}]], MousePosition["Graphics"]]
        ]
       ],
     HoldAll]
   },
  EventHandler[
   Dynamic@Show[
     plot /. toolRule[ins],
     Graphics@ins,
     ImageSize -> OptionValue[ImageSize]
     ],
   {"MouseUp", 2} :> (toolRule = {} &)
   ]
  ]

The function burnTooltips can be applied to the contour plots of our example as follows:
burnTooltips[toolPlot]

This will display the graphic in the argument again, but now whenever you click on an object displaying a Tooltip, the displayed value appears as a static label in the graphic. When you're done adding the labels at locations where they look good to you, you may want to prevent this dynamic display from receiving any further clicks. To do that, right-click the mouse over the completed picture.
Here is what the result might look like:

To continue working with this graphic, copy it and paste it into the next Input cell. For example, to get an image to upload above, I typed
Export["picture.png",   ]

and pasted the image in the space.
There are two options you may want to play with for burnTooltips: ImageSize and "LabelFunction". The first one doesn't need explanation, and the second one should be something of the type Framed[#]& or Pane[#]& (my default setting is shown in the image). By adding the label formatting as a function (note the &), it's possible to customize the labels almost arbitrarily. For example, one could also try this:
"LabelFunction" -> (Pane[Style[#, Red, Background -> White],
    ImageSize -> {20, 20}, ImageSizeAction -> "ResizeToFit"] &)

This method is pretty amenable to how I normally work with plots: use default labeling (i.e., Tooltip in this case) while exploring the problem, and start worrying about the exact placement of labels only at the end.
Here I showed how one can get to the finalized labeled plot from the Tooltip stage. In the function burnTooltips, the Tooltip is used as a kind of vehicle with which a new "payload" can be injected into an existing plot, turning it into a dynamic object that accumulates information about where you click to place labels containing the exact same information that the Tooltip displayed.
Generalizations
You should be able to apply burnTooltips to virtually any Graphics object, not just ContourPlots. But I think ContourPlot is one of the most important applications for this technique because even in single plots (not tables as we considered here), the automatically generated labels are often placed in awkward locations so that manual adjustment is required.

A: Another quick way is to write your own ContourLabels function which places the labels where you want them. Note that I added some PlotRangePadding to make the labels fully visible in the frame
Show[Table[
  ContourPlot[t*d^2 - g, {g, 0, 1}, {d, 0.1, 1}, Contours -> {0},
   ContourStyle -> Black, ContourShading -> None,
   FrameLabel -> {"g", "d"},
   ContourLabels ->
    Function[{x, y, z},
     Text[Framed[t], {t, 1}, Background -> White]]], {t, 0.1, 1,
   0.1}], PlotRangePadding -> .05]

Additionally a short side-note: When your function is not that simple, the placement of the labels may require that you solve for the root (contour-value) of your expression. This should hopefully work with a simple FindRoot in most cases.


text:
Q: How do I remove/modify a javascript function before it executes? I just came across https://www.hotslogs.com, who uses javascript to redirect to the adblock page if the ad does not work properly.
Its source code looks like this

function FillMonkeyBrokerHorizontal01() {}

function nb6fda3f1(src) { //function name is randomly generated
  if (true) {
    var jqueryWindow = $(window);
    jqueryWindow.attr("location", "/Info/AdBloc" + "k?Sour" + "ce=" + src);
  } else
    ga("send", "event", "AdFillMonkeyBroker", "Ad Blocked Acceptably", {
      nonInteraction: true
    });
}

//other if-conditions calls this function

My first thought is to modify this function to a function that does nothing. I tried the solution in Stop execution of Javascript function (client side) or tweak it and the example on jsbin.com/ogudon/1 worked for me.
However when I tried my solution

// ==UserScript==
// @name        hotslogs.com adblock killer killer
// @description hotslogs.com adblock killer killer
// @include     https://www.hotslogs.com/*
// @run-at      document-start
// @version     1
// @grant       none
// ==/UserScript==

checkForBadJavascripts([
  [TRUE,
    /mb105.gz.js/, alert("intercepted mb105.gz.js");
  ]
  [FALSE,
    /AdBloc/, alert("intercepted adbloc function");
  ]
]);

//checkForBadJavascripts definitions,etc.

It did not work well, the page redirects to adblock page and no alert was triggered. I am not sure if it is due to the before/afterscriptexecute not supported in HTML5 standard or if I missed anything. Any suggestions or alternative solutions?


text:
Q: Accessing Dictionary and Multi-Dimension Array is Slow I found that accessing Dictionary and Multi-Dimension array can be slow-- quite a puzzle since access time for dictionary and array is O(1).
This is my code
public struct StateSpace
{
public double q;
public double v;
public double a;
}

public class AccessTest
{
   public Dictionary<int, Dictionary<double,StateSpace>> ModeStateSpace;
   public double[,] eigenVectors;
   public void AccessJob(int n, double times)
  {
     var sumDisplacement = new double[6];
     for(int i=0; i< n; i++)
     {
       var modeDisplacement = ModeStateSpace[i][times].q;  //takes 5.81 sec
       for(int j=0; j<6; j++)
       {
                var eigenVector = eigenVectors[i, j];  //takes 5.69 sec
                sumDisplacement[i] += eigenVector*modeDisplacement ; //takes 1.06 sec
       }
     }
  }

}

Notice the interesting part? The manipulation takes ~ 1 sec, but the accessing of dictionary and multi dimensional array takes ~5 sec!! Any idea why this is the case?
The n is not important here, and so is the absolute magnitude of the time needed for each operation. What is important is the ratio between the arithmetic operation and the dictionary lookup time.
Edit: I'm using Ants Profiler to do the profiling.
Note: I just simplified my actual code into something like this; the above code snippet has not been tested yet, but I'm fairly confident that I capture the gist of the problem with the above code snippet.

A: It is a known fact that jagged arrays are faster than multidimensional arrays in .NET (at least on windows):

*

*Why are multi-dimensional arrays in .NET slower than normal arrays?

*What are the differences between a multidimensional array and an array of arrays in C#?
so maybe try a jagged array instead


text:
Q: childwindow focus function does not work in IE I am trying to open a url of my application in a new tab and when user clicks on same link, it will focus on the open tab. This works fine in chrome. IE its does not work. Does IE require any other piece of code?

    opne tab


text:
Q: Can somebody explain parameters in run.conf of JBoss AS In run.conf of JBoss AS there are few parameters which I am unable to figure out how they are used MAX_FD, PROFILER, JAVA_HOME, JAVA. Can somebody explain the use of these parameters. I agree I am new to JBoss and these are preliminary questions.

A: From this wiki entry

*

*JAVA_HOME : The location of the JDK (java development kit)

*JAVA_OPTS : Options passed the java command, e.g. -Xmx512M

*JAVA : The name of the java binary (default java)

*JBOSS_CLASSPATH : additional classpath entries, if this is set, its value will be prepended to the classpath at startup

*MAX_FD : The maximum number of file descriptors used by JBoss (Unix only)

A: Actually Xms is for defining minimum memory size that is to be allocated for the deployed jboss Appplication  and Xmx is maximum memory size.If any exception like "Out of Memory" we should increase this memory size for the application from this run.conf file.
That is increase the range of Xms - Xmx value


text:
Q: Webrequest and stream, does not read between [ ] c# I am trying to read a json string from a webrequest.
I use the HttpWebRequest because the server need authentication.
I can read the answer string, except the data between the [ ].
the answer should look like this:
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "playerid": 0,
        "type": "video"
    }]
}

but only looks like this:
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": []
}

The json is generated by Kodi/xbmc
What am I doing wrong?
static void Main(string[] args) {
    string Url = @" http://192.168.1.118:8080/jsonrpc?request={""jsonrpc"": ""2.0"", ""method"": ""Player.GetActivePlayers"", ""id"": 1} ";

    string credentials = "user:passwd";
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Url);

    request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials)));
    request.PreAuthenticate = true;
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream resStream = response.GetResponseStream();

    StreamReader reader = new StreamReader(resStream);
    string text = reader.ReadToEnd();

    Console.WriteLine(text);
    Console.ReadLine();
}


text:
Q: Android app perform action after period of inactivity (no user interaction) How can I add a timer to my Android app that is based on user interaction (or lack thereof)? In other words, if there is no user interaction for 2 minutes, I want to have the app do something, in this case navigate to the initial Page(Like Login Page). If at 1:55 someone touches the screen, the timer resets. I would think this would need to be a global timer so no matter which view you are on, the lack of interaction starts the timer. Although, I could create a unique timer on each view. Does anyone have any suggestions, links or sample code where this has been done before?

A: you can do it with Handler and a postDelayed runnable
something like
handler.postDelayed(yourRunnable, 120000);

and cancel it by removing if user interact with screen.
Regards,


text:
Q: Difference between a random variable and its expected value In this paper by Rohe et al.,
Rohe, Karl; Chatterjee, Sourav; Yu, Bin, Spectral clustering and the high-dimensional stochastic blockmodel, Ann. Stat. 39, No. 4, 1878-1915 (2011). ZBL1227.62042.
they show that a certain random matrix has the same eigenvectors as its expected value with high probability. They propose the following illustrative example.
Consider a matrix $W \in \mathbb R^{n\times n}$ with i.i.d. Bernoulli$(1/2)$ entries. We thus have, for $i\neq j$,
$$
(WW)_{ij}\sim \mbox{Binomial($n,1/4$)}.
$$
Next, they state that

...for any $i,j$, $(WW)_{ij}-\mathbb E[(WW)_{ij}]=o(n^{1/2}\log(n))$. Thus, the Frobenius distance from the squared matrix to its expectation is
  $$
\|WW/n^2-\mathbb E[WW]/n^2\|_F=\frac{1}{n^2}\sqrt{\sum_{i,j}((WW)_{ij}-\mathbb E[WW_{ij}])^2}=o\left(\frac{\log(n)}{n^{1/2}}\right).
$$

However, $WW$ being a random variable, this does not make sense to me. The result of that difference should be yet another random variable. Even if this result is supposed to be a value attained with high probability, I'm not sure I can see how the got that particular asymptotic bound.
What exactly do the authors mean with this notation? How did they get to that asymptotic equality?

A: If $WW_{ij} - \mathbb{E}[WW_{ij}] = o(n^{1/2}\log n)$ then $$(WW_{ij} - \mathbb{E}[WW_{ij}])^2 = o(n\log^2 n).$$
Summing this over all $i,j$, we get
$$\sum_{ij} (WW_{ij} - \mathbb{E}[WW_{ij}])^2 = o(n^3\log^2 n).$$
Taking the square root, we get
$$\sqrt{\sum_{ij} (WW_{ij} - \mathbb{E}[WW_{ij}])^2} = o(n^{3/2}\log n).$$
Dividing by $n^2$, we get
$$\frac{1}{n^2}\sqrt{\sum_{ij} (WW_{ij} - \mathbb{E}[WW_{ij}])^2} = o\left(\frac{\log n}{\sqrt{n}}\right).$$
Here, $WW$ is not a random variable, but a particular realization of the random variable. Confusingly perhaps, both are denoted in exactly the same way. Let me give a simpler example. Suppose that $X \sim \mathrm{Bin}(n,1/2)$. Then with high probability, $n/3 \leq X \leq 2n/3$. Therefore with high probability, $|X - \mathbb{E}[X]| \leq n/6$.

Since $WW_{ij} \sim \mathrm{Bin}(n,1/4)$, a Chernoff bound shows that with high probability, $WW_{ij} - \mathbb{E}[WW_{ij}] = o(n^{1/2} \log n)$ for all $i,j$. (In fact, we can replace $\log n$ with any function which is $\omega(\sqrt{\log n})$.) Therefore, the bound in your quote holds whp.


text:
Q: How to call a method from a class in qt? I made a class in qt the the following code is the header:
#ifndef TEST_H
#define TEST_H

class Test {
public:
    Test();
    void coppy(int zahl);
};

#endif // TEST_H

The methods are initialized in the .cpp file:
#include "test.h"

int tata;
Test::Test()
{
}

void coppy(int zahl)
{
    tata = zahl;
}

And I want to call the coppy method in a second class when I press a button like this:
void MainWindow::on_pushButton_2_clicked()
{
    Test *t = new Test();
    t->coppy(5);
}

But I always get the following error: undefined reference to `Test::coppy(int)'
What am I doing wrong?

A: void coppy(int zahl) defines a new function in your .cpp file. The compiler doesn't see any relation between this function and Test's coppy function. To define a class member function you need to use the full member name, including the class name. Try the following instead :
void Test::coppy(int zahl)
//   ^^^^ Add the class name here
{
    tata = zahl;
}

A: void Test::coppy(int zahl)
{
    tata = zahl;
}

It must be in your cpp file.
And I suggest you to make int tata a class member


text: Q: Android  resource - make auto mirrored I need  XML resource auto mirrored. Unfortunately autoMirrored parameter is available for  only. Any idea how to overcome this without providing a separate drawable file in drawable-ldrtl folder?


text:
Q: Struggling to Use an Array of Objects in a Method Let me preface this by saying that my knowledge when it comes to coding in general is very lackluster.
I've begun working on a code that creates a high score table, as of right now only random numbers show up but that's besides the point.  I decided to use a class to practice, and I'm having trouble with using an array of objects in a function.
Class contains 2 variables, first one stores the score as an int, second stores the names as a string but the string isn't exactly relevant to my question.
class Table
{
public:
    int m_score = 0;
    string m_name = { " " };
    void randomizeScores(Table position[], int amount);
};

int main()
{
    const int size = 5;
    Table position[size];

    /* Here seems to be the problem
       Replacing position.randomizeScores with Replacing position->randomizeScores makes it work
       and I have no idea why.  Which is what i'd like to find out*/

    position.randomizeScores(position, size);
}

void Table::randomizeScores(Table position[], int amount)
{
    for (int i = 0; i < amount; i++)
    {
        position[i].m_score = (rand() % 100) + 1;
    }
}

Thank you very much folks!


text:
Q: zeroes are recognized as NaN from pandas' isnull() I have the following code:
import pandas as pd
df = pd.DataFrame([0.0]*5, index=pd.date_range('2020-10-02 10:00:00','2020-10-02 10:04:00', freq='60s'), columns=['col1'])
print(df)

out:
                     col1
2020-10-02 10:00:00   0.0
2020-10-02 10:01:00   0.0
2020-10-02 10:02:00   0.0
2020-10-02 10:03:00   0.0
2020-10-02 10:04:00   0.0

And then I use the following line of code:
print(df[df.isnull()])

Which results in the following:
                     col1
2020-10-02 10:00:00   NaN
2020-10-02 10:01:00   NaN
2020-10-02 10:02:00   NaN
2020-10-02 10:03:00   NaN
2020-10-02 10:04:00   NaN

I am confused since I expected to get an empty dataframe back, since none of the values is NaN. Is this expected behaviour?

A: You need compare column for boolean indexing:
print(df[df.col1.isnull()])

If need compare all columns need DataFrame.all or DataFrame.any for test if all values per columns are True or at least one. If one column DataFrame like here output is same.
print(df[df.isnull().any(axis=1)])


text:
Q: Code blocks work separately but not together I'm making a function for my chrome extension. It's supposed to move all tabGroups to the left most position in alphabetical order and then sort the rest of the tabs in alphabetical order aswell.
The problem is when I remove this code block everything works fine, meaning the tabGroups gets moved to the left most position. But when I add it back it stops working. The thing is that the code block works on it's own if I manually move the tabGroups myself. Any help is appreciated!

for (let i = 0; i < titles.length; i++) {
        for (let j = 0; j < titles.length; j++) {
          if (tabs[i + moveIndex].title == titles[j]) {
            chrome.tabs.move(tabs[i + moveIndex].id, { index: (j + moveIndex) });
          }
        }
      }

This is the full function, with tabs being: let tabs = await chrome.tabs.query({ currentWindow: true });

async function titleSort(tabs) {
  // Puts groups in current window into an array
  let groups = await chrome.tabGroups.query({ windowId: -1 });
  console.log(groups);

  // Separates titles into a different array
  let groupTitles = [];
  for (let i = 0; i < groups.length; i++) {
    groupTitles.push(groups[i].title);
  }
  // Sorts the array alphabetically
  groupTitles.sort((a, b) => a.localeCompare(b));
  console.log(groupTitles);

  // Put groups into an array in alphabetical order
  let groupsAlph = [];
  for (let i = 0; i < groups.length; i++) {
    for (let j = 0; j < groupTitles.length; j++) {
      if (groupTitles[i] == groups[j].title) {
        groupsAlph.push(groups[j]);
      }
    }
  }
  console.log(groupsAlph);

  chrome.storage.sync.get(["preserveGroupOrder"], (data) => {
    if (data.preserveGroupOrder == false) {
      // Separates titles into a different array
      let titles = [];
      for (let i = 0; i < tabs.length; i++) {
        titles.push(tabs[i].title);
      }

      // Sorts the array alphabetically
      titles.sort((a, b) => a.localeCompare(b));

      // Checks if the titles match and rearranges the tabs accordingly
      for (let i = 0; i < tabs.length; i++) {
        for (let j = 0; j < titles.length; j++) {
          if (tabs[i].title == titles[j]) {
            chrome.tabs.move(tabs[i].id, { index: j });
          }
        }
      }
    } else if (data.preserveGroupOrder == true) {
      let tabsInGroup = [];
      // Resets values to 0 in tabsInGroup
      for (let i = 0; i < groups.length; i++) {
        tabsInGroup[i] = 0;
      }

      // Gets the amount of tabs in each group
      for (let i = 0; i < tabs.length; i++) {
        for (let j = 0; j < groups.length; j++) {
          if (tabs[i].groupId == groupsAlph[j].id) {
            tabsInGroup[j]++;
          }
        }
      }
      console.log(tabsInGroup);

      // Moves groups to the left most positions
      let moveIndex = 0;
      for (let i = 0; i < groupsAlph.length; i++) {
        chrome.tabGroups.move(groupsAlph[i].id, { index: moveIndex });
        moveIndex += tabsInGroup[i];
      }
      console.log(moveIndex);

      // Separates titles into a different array
      let titles = [];
      let tabsLength = tabs.length - moveIndex;
      for (let i = 0; i < tabsLength; i++) {
        titles.push(tabs[i + moveIndex].title);
      }

      // Sorts the array alphabetically
      titles.sort((a, b) => a.localeCompare(b));
      console.log(titles);

      // TODO: Sort the rest of the tabs (works separately)
      // Checks if the titles match and rearranges the tabs accordingly
      for (let i = 0; i < titles.length; i++) {
        for (let j = 0; j < titles.length; j++) {
          if (tabs[i + moveIndex].title == titles[j]) {
            chrome.tabs.move(tabs[i + moveIndex].id, { index: (j + moveIndex) });
          }
        }
      }
    }
  });
}

A: I'm fairly confident that the issue is that you're not requerying tabs after you move tab groups:
chrome.tabGroups.move(groupsAlph[i].id, { index: moveIndex });

If you're only creating the tabs index once, then if tabs 6 - 8 are part of a group, and the group gets moved to index spots 0-2 by that line, your tabs variable does not know that unless you requery. So when you start resorting tabs 3 through 8, you're including tabs you don't want to and excluding tabs that you do. If for some reason you don't want to requery, you could keep track of the index numbers where you find tabs and have your title builder start at zero and skip the tabs. I.e., instead of ->
for (let i = 0; i < tabsLength; i++) {
  titles.push(tabs[i + moveIndex].title); ...

Something like ->
for (let i = 0; i < tabs.length; i++) {
  if (isNotGroupMember[i]) {
    titles.push(tabs[i].title); ...

You would need to readjust some other pieces, but there's a good chance that will be the case regardless.
If that's not the issue, it's not clear from your code and I have a second hypothesis, but I'd try that first.
Also, it's not your question, but you may be interested in sorting arrays of objects by a key, rather than separating out the titles, sorting those, and then match sorting them back into place. See an example at w3schools. Although maybe there's a good reason to build your own sort.


text:
Q: Force android bluetooth discovery on Is there a way to force the bluetooth adapter to be discoverable? Like the BluetoothAdapter.Enable() method?
I know about the BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE but it show a dialog to the user.
I want to do this to make it easier for the user to use the application - so they can set a Auto connect setting to true... and then it wan't ask these questions again. But I don't know how to get around the dialog?
BR

A: You can't do that without user interaction.  You can autoconnect to a previously paired bluetooth device but you can't make the device discoverable without user interaction I believe for security reasons.


text:
Q: Bootable ISO from working hard drive I am looking for a way to create a bootable ISO image of an existing, working hard drive containing a master boot record.
Is there a known solution to this problem?
Background:
I have some critical scientific equipment that is running Windows XP. It is increasingly difficult to support compatible hardware. I would like to see if it can run in a virtual machine (e.g.: VirtualBox) on a more modern computer. To try this I need an iso of the existing drive.
Attempts so far

*

*Clonezilla lets me make images, and supposedly even make a 'recovery iso' but this does not appear to be a bootable iso of the actual drive.

*Acronis's software lets me make the bootable media and back up the drive from it, but only to some proprietary format. I don't know how I could get it working with VirtualBox.

A: Use instead the Virtual Box Physical to Virtual converter using Disk2VHD.
VBOX P to V
To convert a physical disk to virtual disk with Disk2vhd:
1. Download and extract the Disk2vhd.zip file on the computer that you want to convert to a VirtualBox machine, or on another computer where you have attached the disk of the physical machine that you want to convert to virtual.

2. From the extracted folder, right-click on disk2vhd64.exe and select Run as administrator. Then ask yes at UAC warning.

*At Disk2vhd window:
Uncheck the Use Vhdx checkbox. *
Select the physical disk that you want to convert to virtual disk. (In this example I have connected the disk I want to convert to virtual to another pc).
Select a destination folder and type a name for the created virtual disk file (e.g. "WindowsXP.vhd"). **
Finally, click Create to create the virtual disk image from the physical disk.


text:
Q: scalling image with getScaledInstance() in java Can anyone explain this, there are 3 ways by which I have created Image object but only the last object(k) can be successfully scaled using getscalledinstance().
public class scalingTest extends JPanel {

    public static Image i;
    public static Image j;
    public static Image k;
    scalingTest() throws IOException
    {
        i = Toolkit.getDefaultToolkit().getImage("C:/Users/Prashant/Desktop/2.png");
        j = new ImageIcon("C:/Users/Prashant/Desktop/2.png").getImage();
        k = ImageIO.read(new File("C:/Users/Prashant/Desktop/2.png"));
    }
    public static void main(String s[]) throws IOException
    {
        JFrame jf = new JFrame("Scaling TEST");
        jf.add(new scalingTest());
        jf.setSize(500, 500);
        jf.setVisible(true);
    }
    @Override
    public void paintComponent(Graphics g)
    {
        g.drawImage(i.getScaledInstance(100, 100, Image.SCALE_DEFAULT), 0, 0, this);
        g.drawImage(j.getScaledInstance(100, 100, Image.SCALE_DEFAULT), 100, 100, this);
        g.drawImage(k.getScaledInstance(100, 100, Image.SCALE_DEFAULT), 200, 200, this);
    }
}

A: Read the Javadoc of Image.getScaledInstance:

A new Image object is returned which will render
       the image at the specified width and
       height by default.  The new Image object
       may be loaded asynchronously even if the original source image
       has already been loaded completely.

Ensure the scaled image is really there when you try to draw it (look for "ensure image is fully loaded" if you need advice how to do that). The reason it works with the image obtained through ImageIO is that ImageIO gives you a BufferedImage, and that is always loaded.
Also note: For the purpose of simply drawing an image to a size other than the images size, you do not need to create a scaled instance - Graphics has methods to draw images in a different size on the fly. You might be better off using that, depending on use case.


text:
Q: big step semantics for loop, I keep getting an infinite loop Although this is only part of the code, can some decipher why i am getting an infinite loop
This is how the big step semantic is suppost to look like

eval (For iexp c, s)
    |(bEval (Compare Leq iexp (IConst 0), s)) = s
    |otherwise = eval (For n' c, s')
    where
        s' = eval(c,s)
        n' = (IBin Minus iexp (IConst 1))

A: The infinite loop most probably comes from a different part of your code. The snippet you gave  looks correct and--with the necessary types and functions suitably mocked out--terminates.
Perhaps you do not evaluate subtraction correctly? Another possibility is that bEval does not work correctly.
This is a good use-case for Data.Trace, which provides a trace function for debugging. This is just like using print statements to debug in any other language. (Internally, it uses unsafePerformIO.)
The trace function takes a string and an expression; it prints the string and returns the expression. There is also a traceShow function which uses show on its argument before printing.
You can use it to print out the intermediate values as the loop gets executed. I suggest something like this:
eval (For iexp c, s)
  | condition `traceShow` condition = s
  | otherwise = n' `traceShow` eval (For n' c, s')
  where condition = bEval (Compare Leq iexp (IConst 0), s)
        s' = eval(c,s)
        n' = (IBin Minus iexp (IConst 1))

This will print out the condition and value of the counter at each step. This should help you figure out where the loop is coming from. If it doesn't, you can move the trace statements around, using them the same way as I have here.


text:
Q: How to pass a tensor type value to the shape argument of Variable? I met a problem that can be summarised below:
foo = tf.constant(3)
foo_variable = tf.get_variable("foo", shape=[foo], dtype=tf.int32)

That the shape of the variable has to depend on the value of a tensor(foo here is only an abstraction of calculated result from other operations)
The error here is The shape of a variable can not be a Tensor object
How to resolve this?

A: Create a tensor-initializer that has shape specified by your foo tensor and then instantiate a new variable using this initializer with validate_shape=False:
import tensorflow as tf

x = tf.placeholder(tf.int32, shape=())
shape = tf.constant([2, 3]) + x
init = tf.zeros(shape, dtype=tf.int32)
v = tf.get_variable('foo', initializer=init, validate_shape=False)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer(), {x: 1})
    print(v.eval())
    # [[0 0 0 0]
    #  [0 0 0 0]
    #  [0 0 0 0]]

A: A tensorflow variable cannot have a dynamic shape but if you know the shape out of the session you could use:
foo_variable = tf.get_variable("foo", shape=[], validate_shape=False)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(foo_variable, feed_dict={foo_variable: ones((2,2))}))


text:
Q: Roblox 2009 Lua: Get Loadstring's error I've been making a 2009 script builder for a few hours now, and I can't figure out how to make it print errors. If I do print(loadstring("a")) it prints into the roblox output nil [string "s"]:1: '=' expected near '<eof>', which == nil. What I want to get is the error it reports at the end : '=' expected near '<eof>', type type is nil, so I have no idea how to get it. If anyone could help that would be greatly appreciated!

A: Refer to the Lua 5.1 manual, which will point you to the documentation for load:

If there [are] errors, ... returns nil plus the error message.

It's typical for Lua to return error messages as a second return value:
local f, err = loadstring(mycode)
if not f then
    print("There was an error: `" .. err .. "`")
end

This err begins with where the error happened, which unhelpfully quotes the input to loadstring.
For example, for the input code "hello there", the error is
[string "hello there"]:1: '=' expected near 'there'

Lua appears to cut the quote off at the first newline or 63 character, whichever is less:
For "hello\there" the error is
[string "hello..."]:2: '=' expected near 'there'

For "helloooooooooooooooooooooooooooooooooooooooooooooooooooooo there" the error is
[string "helloooooooooooooooooooooooooooooooooooooooooooooooooooooo ther..."]:1: '=' expected near 'there'

If you're sure there's no "]: in the first 63 characters/first line of your script, you can just search for that sequence to find where it stops:
local location, message = err:match('^(%[string ".*"%]:%d+:%s+)(.*)$')

This won't be right if your code is, for example, "hello\"]:1: there", which you may want to address.
The simplest way to address it would be to take user control away from the first line that is quoted: prepend the code with your own first line that is nice (and make sure to adjust the line number of the error if you display it to the user:)
local f, err = loadstring("--code\n" .. mycode)
print(err)

Now the error message should always begin
[string "--code..."]:


text:
Q: html5 web font security Are there any security risks associated with loading web fonts?
Our corporate IE policy prohibits downloading web fonts. I'd like to change that policy but I can't find any solid information about what the security risks are.
Are web fonts actually installed on the PC or are they just handled and rendered by the browser? If the latter, I don't see why it would be any riskier than processing any other web resource (images, js files, etc).
Thanks

A: There was a vulnerability rendering TTF in 2011 and another in 2015, which could allow remote code execution.
The Windows Kernel would appear to have issues with font rendering. Non-TTF fonts don't have any known vulerabilities that I have been able to find, but they may exist.


text:
Q: Magento - Custom options do not update price of configurable product In Magento 1.9 I've created configurable product with 2 associated products. In Super product attributes configuration I set-up fixed price difference like for any other configurable product. Later on I created a Custom Option called Gift Wrap (checkbox, fixed price, sku: gift-wrap) for the main configurable product.
When selecting the checkbox in front-end and adding item to the shopping cart the  checkout page /checkout/cart/ shows price without custom option! Why Gift Wrap price was not summed with Configurable product price?

A: We managed to find the root of the problem. Magento's Configurable product works just fine with Custom Option. We had installed FME_Pricecalcultor there are bugs in FME_Pricecalcultor_Model_Observer observer model.


text:
Q: wxMaxima transform trigonometric expression I got a equation in the following form
f(t) = 2*cos(t) + 3*sin(t)

and I want to reduce it to something like
f(t) = (9 + 4)^(1/2) * cos(t - atan(3/2))

None of the trigonometric simplify functions seems to work. Is there a way to do so?


text:
Q: Chrome taking 90% CPU in the background Whenever I boot up my PC and open task manager Chrome is shown to be taking 90% cpu with no active windows open, this is just something in the background. I have tried:

*

*reinstalling Chrome

*disabling all extensions

*checked chrome's task manager, the process is not listed

Please help, also for some reason when I click the 3 dots then at the bottom it says "managed by your organization" even though this is a personal PC for personal use only.


text:
Q: How do I pass user profile pic in nav through AppServiceProvider? laravel-5 This is a very common task. I'm trying to display user profile pic on the nav throughout the site.
The profile pictures are urls from google,facebook,or from s3 if user uploads them.  I have this function to access the pictures
public static function get_profile_pic($user){
    $pic=array_flatten($user->media->where('category','profile'))[0]->path;
    if(empty($pic)){
        $pic = '/images/user-icon.jpg';
        return $pic;
    }else
        return $pic;
}

In my nav view I have :
@if(Auth::check())

<img class='nav-pic' src='<?php link_to_action('HomeController@index',$pic)?>'/>

my homecontroller:
class HomeController extends Controller {
public function index(Request $request) {
    if ($request->user()) {
        $user = $request->user();
        $pic = User::get_profile_pic($user);
 }
    view()->share('scripts', array('home.js'));
    return view('home.index', compact('user'));
}

and this is what I have in the AppServiceProvider
public function boot()
{
    if (Auth::check()){
        $user = Auth::user();
        $pic = User::get_profile_pic($user);
        view()->composer('includes.new_nav1',function($view){
            $view->with('pic', User::get_profile_pic($user));
        });
    }
}

A: Any time you see something like User::method($user) it's probably better to refactor that so that the method is on the user object itself, i.e. $user->method()
Laravel has something even better called an "appended" attribute. That means it behaves exactly like a normal attribute (database column), you just have to define an accessor method for it:

1 - Take your function:
public static function get_profile_pic($user)

and change it to
public function getProfilePicAttribute()

2 - Replace $user with $this inside of that method.
3 - Finally, add this array to your User model:
protected $appends = ['profile_pic'];

This tells Laravel that "profile_pic" behaves like a database attribute but should not be saved into the database table.
Now for any User object, you can simply use $user->profile_pic, e.g.
profile_pic }}">

And change your view composer to just view->with($user, Auth::user())


text:
Q: Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)' after updating java version to 11 I am not able make build after changing jdk to jdk11.0.15.1.
It gives following error:

Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.

When I check in cmd with command "java -version" it says java 11 is current version and when I command "javac -version" it gives javac 11 as current version.


text:
Q: Avoiding repeating state names Let's say i have a rootreducer like below.
const rootR = combineReducers({
  topics,
  ...
});

the topics reducer
function topics(state = { topics=[], error: null}, action){
  switch (action.type){
    case types.FETCH_TOPICS_SUCCESSFULLY:
      const { topics } = action;
      return {
        ...state,
        topics,
      };
    default:
      return state;
  }
};

And when i fire the related action i get my state with repeatable properties state.topics.topics instead of state.topics
Is there any way to avoid this repeating (topics.topics)?
Thanks in advance

A: You're double-nesting things.  The topics reducer will only see the "topics" slice of state.  So, instead of returning {...state, topics}, just do return topics.
update
Your edit to the question changes the situation considerably.
Originally, you had:
function topics(state = {}, action){

Now, you have:
function topics(state = { topics=[], error: null}, action){

I'll admit I'm a bit confused at this point as to what your desired state structure actually should be.
Looking at your original definition, it seemed like you were misunderstanding how combineReducers works, and redundantly trying to return a new object that contained a field/slice named "topics".  Now, it looks like the root-level "topics" slice itself has a field named "topics" as well.
Are topics and error supposed to be at the root of your state tree?  Or, are they both really supposed to be part of the top-level "topics" slice?  If that's really what you want, then you've defined the state tree as needing to be topics.topics.
Also, to answer @free-soul: no, in the original example, return topics would not mutate state, because it's just returning whatever was in the action.  Even if the action.topic field was literally the same array that used to be in the state, the result would just be a no-op.

A: @markerikson is right, the state variable passed in the function is actually topics once FETCH_TOPICS_SUCCESSFULLY is called, so it's better to do return topics there.
But given your condition,  instead of return {...state, topics} or return topics, you can also do return Object.assign({}, state, topics). This will create a new object with all properties from previous state and topics merged together.

A: Looking at the initialState of your topics reducer, the state object accessible to topics reducer has this structure:
{
    topics: [],
    error: null
}

So when you combineReducers like this:
const rootR = combineReducers({
  topics,
  anotherReducer,
  someOtherReducer.
  // ...
});

resulting global app state is going to look like this:
{
    topics: {
        topics: [],
        error: null
    },
    anotherReducer: {
        // ...
    },
    someOtherReducer: {
        // ...
    },

    // ...
}

So if you want to access topics array from global state, you need to do state.topics.topics.
You have two things under state.topics, an array of topics and error.
Hence let's rename second topics key to items to avoid confusion.
(it is unavoidable to have a second key to store the array because you also want error)
thus we have:
state.topics = {
    items: [],
    error: null,
}

Instead of state.topics.topics, now we access state.topics.items
To achieve this, initialstate passed to topics reducer has to be:
function topics(state = { items = [], error: null }, action){
    //...
}

Now inside the reducer FETCH_TOPICS_SUCCESSFULLY, we want to append an array action.topics to items, like this (without mutating our current state):
case types.FETCH_TOPICS_SUCCESSFULLY:
    const { topics } = action;
    return {
        ...state,
        items: [
            ...state.items,
            ...topics
        ],
    };


text:
Q: Use Branch Name in TFS 2015 Automated Build My TFS repo has the following structure:
Project
 - Dev
    - 1.0.0_Branch1
    - 1.1.0_Branch2
    - N.0.0_BranchN

The branches are actual branches in TFS.
I have an automated CI build set up for this project on a TFS server. The issue I am having is that I need the build name in TFS to use the name of the branch.
I have tried a number of the build definition variables listed here , for examle $(SourceBranchName) and and $(Build.SourceBranchName) but all of these are instead using the name of the Project (Project in this example).
I would like the build to be named along the lines of 1.0.0_Branch1.1 with the last number being the revision.
The reason I would like to do this is so that when I generate Nuget packages at the end of the build, they can be versioned using the version of the branch that is being built. Currently they are being versioned using the date which means that the highest version is only ever the most recently built, which may not be the case in practice. I don't want to have to manually set the versions each time.
All assemblies that are being built are correctly versioned to match the branch that they are within.
Is there a way to achieve this?

A: For build definitions, $(SourceBranchName) can be used in the build number format:

example build:

The environment variable is BUILD_SOURCEBRANCHNAME so it will be available as $(BUILD_SOURCEBRANCHNAME) in msbuild.
The list of available variables is found at: https://www.visualstudio.com/en-us/docs/build/define/variables#predefined-variables

A: This could be caused by the "Mappings" setting you configured under "Repository" tab in your build definition. When you build with TFVC repository, the BUILD_SOURCEBRANCHNAME variable is filled with the last path segment in the root server path of the workspace. So I'm wondering that the mapped server path in your build definition is "$/Project" rather than "$/Project/Dev/1.0.0_Branch1".

TFVC repo branch: The last path segment in the root server path for
  the workspace. For example in $/teamproject/main this value is main.

Refer to this link for details: Predefined Variables.


text:
Q: Missing space between "Results found" or "Results for " and "Search options" When conducting a search where the results page has "Results found" and "Search options" next to each other (that is, searches that don't contain tags but use a search operator, example), a space is missing:

Results foundSearch options <options>

If a keyword is added, the lack of space appears after the keyword:

Results for <keyword>Search options <options>

I don't remember this happening before but lack any pictures to prove so.


text:
Q: Running Heroku using webpack and node.js Firstly for context, here is my file structure:
bundle.js
package.json
package-lock.json
.gitignore
/.git
/node_modules
/src
    form.js
    form.css
    index.html
    json.js

Here is my package.json:
{
  "name": "transcriber-form-helper",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/webpack/bin/webpack.js ./src/form.js bundle.js"
},
  "author": "",
  "license": "ISC",
  "dependencies": {
    "jquery": "^3.2.1"
  },
  "devDependencies": {
    "css-loader": "^0.28.7",
    "style-loader": "^0.19.0",
    "webpack": "^3.8.1"
  },
  "engines": {
          "node": "6.12.0"
  }
}

I have a working app (meaning if I run index.html, it runs correctly) which I have built with dependencies from node.js. I am also trying to use webpack but I don't fully understand it so I heavily suspect it is the source of my problems. From what I understand, node.js runs the start script on npm start and the start script runs webpack to compile /src/form.js and all its dependencies into an output bundle.js.
It is this bundle.js that is linked in my index.html as a script.
I am attempting to run this on a Heroku deploy. I created a brand new folder and git init. I committed all the files and ran a heroku create and subsequently pushed all with git push heroku master. Here is the result:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=false
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  6.12.0
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 6.12.0...
remote:        Downloading and installing node 6.12.0...
remote:        Detected package-lock.json: defaulting npm to version 5.x.x
remote:        Bootstrapping npm 5.x.x (replacing 3.10.10)...
remote:        npm 5.5.1 installed
remote:
remote: -----> Restoring cache
remote:        Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > uglifyjs-webpack-plugin@0.4.6 postinstall /tmp/build_5f7197c56e4eae8677e4d73562940ae8/node_modules/uglifyjs-webpack-plugin
remote:        > node lib/post_install.js
remote:
remote:        added 392 packages in 9.621s
remote:
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Saving 2 cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (nothing to cache)
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote:        Done: 24.9M
remote: -----> Launching...
remote:        Released v9
remote:        https://calm-beyond-56449.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.

As far as I can understand it, nothing is clearly wrong, right?
The following is the Heroku logs --tail immediately after deploying.
2017-11-23T16:39:06.000000+00:00 app[api]: Build started by user <my email here>
2017-11-23T16:39:48.456625+00:00 app[api]: Release v9 created by user <my email here>
2017-11-23T16:39:48.456625+00:00 app[api]: Deploy b38385b7 by user <my email here>
2017-11-23T16:39:06.000000+00:00 app[api]: Build succeeded
2017-11-23T16:39:49.649609+00:00 heroku[web.1]: State changed from crashed to starting
2017-11-23T16:39:52.613766+00:00 heroku[web.1]: Starting process with command `npm start`
2017-11-23T16:39:55.858825+00:00 app[web.1]:
2017-11-23T16:39:55.858824+00:00 app[web.1]: > node node_modules/webpack/bin/webpack.js ./src/form.js bundle.js
2017-11-23T16:39:55.858823+00:00 app[web.1]: > transcriber-form-helper@1.0.0 start /app
2017-11-23T16:39:55.858811+00:00 app[web.1]:
2017-11-23T16:39:58.414268+00:00 app[web.1]: Hash: e0226ff21cf9f346ae14
2017-11-23T16:39:58.414289+00:00 app[web.1]: Time: 1450ms
2017-11-23T16:39:58.414286+00:00 app[web.1]: Version: webpack 3.8.1
2017-11-23T16:39:58.414292+00:00 app[web.1]: bundle.js  299 kB       0  [emitted]  [big]  main
2017-11-23T16:39:58.414291+00:00 app[web.1]:     Asset    Size  Chunks                    Chunk Names
2017-11-23T16:39:58.414294+00:00 app[web.1]:    [1] ./src/json.js 9.42 kB {0} [built]
2017-11-23T16:39:58.414296+00:00 app[web.1]:    [3] ./node_modules/style-loader!./node_modules/css-loader!./src/form.css 1.01 kB {0} [built]
2017-11-23T16:39:58.414294+00:00 app[web.1]:    [0] ./src/form.js 2.68 kB {0} [built]
2017-11-23T16:39:58.414298+00:00 app[web.1]:    [4] ./node_modules/css-loader!./src/form.css 474 bytes {0} [built]
2017-11-23T16:39:58.414299+00:00 app[web.1]:     + 4 hidden modules
2017-11-23T16:39:58.558119+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-23T16:39:58.542644+00:00 heroku[web.1]: Process exited with status 0

It appears to have crashed. Running Heroku ps: scale web=1 and subsequently Heroku open results in an error:
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
Additionally I have run heroku config:set NPM_CONFIG_PRODUCTION=false to include devDependencies.
Not sure if any other files are relevant to the problem but I'll include small excerpts of what I think is the connection stuff in each file:
form.js:
var templates = require('./json.js');
var $ = require('jquery');
require('style-loader!css-loader!./form.css');

index.html:
<!DOCTYPE html>
<meta charset="utf-8"/>

                <title>Pejman's TranscribersOfReddit form helper</title>

/r/TranscribersOfReddit form helper

                <input type="submit" id="btn_generate" value="Generate" />
                <input type="submit" id="btn_reset" value="Reset" />

                <textarea rows=10 cols=80 id="output"></textarea>

                <input type="submit" id="btn_copy" value="Copy to Clipboard" />


text:
Q: SetCapture does not work and returns nullptr I'm trying to capture the mouse for a windowed game to handle mouse input and everytime I try, it returns nullptr. What I am seeing on the window is a waiting cursor (blue circle).
Here is the code for Win32 window wrapper:
XWindow::XWindow(WCHAR* title, int width, int height)
{
     memcpy(m_szTitle, title, sizeof(title));
     m_width = width;
     m_height = height;
}

ATOM XWindow::MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEXW wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIcon(hInstance,
    MAKEINTRESOURCE(IDI_WIN32PROJECT1));
    wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName = nullptr;
    wcex.lpszClassName  = m_szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance,
    MAKEINTRESOURCE(IDI_SMALL));

    return RegisterClassExW(&wcex);
}

BOOL XWindow::InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    m_hInst = hInstance;
    m_hWnd = CreateWindowW(m_szWindowClass, m_szTitle, WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, 0, m_width, m_height, nullptr, nullptr, hInstance, nullptr);

    if (!m_hWnd)
        return FALSE;

    ShowWindow(m_hWnd, nCmdShow);
    UpdateWindow(m_hWnd);

    return TRUE;
}

LRESULT CALLBACK XWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            switch (wmId)
            {
                case IDM_EXIT:
                DestroyWindow(hWnd);
                break;
                default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);

            EndPaint(hWnd, &ps);
        }
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        return 0;
}

And this is the WinMain function:
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE
hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
{
    XIllumin* pMainGameWindow = new XIllumin(L"X3DEngine", 800, 600);

    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    if (LoadStringW(hInstance, IDS_APP_TITLE, pMainGameWindow-
    >GetWindowTitle(), MAX_LOADSTRING) == 0)
    return FALSE;

    if (LoadStringW(hInstance, IDC_WIN32PROJECT1, pMainGameWindow-
    >GetWindowClass(), MAX_LOADSTRING) == 0)
    return FALSE;

    pMainGameWindow->MyRegisterClass(hInstance);

    if (!pMainGameWindow->InitInstance(hInstance, nCmdShow))
        return FALSE;

    if (SetCapture(pMainGameWindow->GetWindowHandle()) == nullptr)
    //  return FALSE;

    if (!pMainGameWindow->ParseInitFile("Config/GameInit.txt"))
    {
        pMainGameWindow->FAIL_MSG_BOX(L"Error loading init file.");
        return FALSE;
    }

    pMainGameWindow->InitGameObjects(" ");

    HACCEL hAccelTable = LoadAccelerators(hInstance,
    MAKEINTRESOURCE(IDC_WIN32PROJECT1));

    MSG msg;

    while (1)
    {
        if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
            {
                 pMainGameWindow->CleanUp();
                 break;
            }

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        if (!pMainGameWindow->GameMain(" "))
            break;
    }

    return (int)msg.wParam;
}

I am not sure what exactly is wrong. I think it might be the window creation parameters for CreateWindowW(), but don't really know which to use.
EDIT: The input is supposed to be handled by the game window when I hover the mouse cursor on it, but I see a waiting cursor as soon as the window pops up and the cursor is over it. Not really sure what else to say on top of that.

A: Note that SetCapture returns a handle to the window previously captured the mouse. So it is OK for SetCapture to return NULL when mouse was not captured by some other window previously. "Wait" cursor has nothing to do with it.
Note that by commenting //  return FALSE; you change if scope to the following, potentially skipping config loading:
if (SetCapture(pMainGameWindow->GetWindowHandle()) == nullptr)
{
    //  return FALSE;

    if (!pMainGameWindow->ParseInitFile("Config/GameInit.txt"))
    {
        pMainGameWindow->FAIL_MSG_BOX(L"Error loading init file.");
        return FALSE;
    }
}

This is a good example of why {} should never be omitted.
You should pump messages prior to calling SetCapture so window would be initialized and get to foreground propertly:
// at InitInstance
UpdateWindow(m_hWnd);
MSG msg;
while(PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE))
{
       TranslateMessage(&msg);
       DispatchMessageW(&msg);
}


text:
Q: How to override web view text selection menu in android The basic android's web text selection menu is as shown in image attached below. It has options like copy, share, select all, web search.

I want to over ride this menus and want them as my own menu list like "mark colour", "mark as imp" etc. I look around most of the questions available about context menu on stack overflow. The most of the question relate with context menu but not giving result as expected. I want menu like below image

When I perform selection android monitor shows some view creation form viewRoot like
D/ViewRootImpl: #1 mView = android.widget.PopupWindow$PopupDecorView{648898f V.E...... ......I. 0,0-0,0}
D/ViewRootImpl: #1 mView = android.widget.PopupWindow$PopupDecorView{a66541c V.E...... ......I. 0,0-0,0}
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1

How to achieve such implementation?
I also gone through https://github.com/naoak/WebViewMarker but not getting proper result.
What I have done yet?
I extend WebView of android and I want to make support for minimum SDK 19. When I perform long press I got long press event but I can't get such menus creation api calls.

A: You need to overwrite action menus of activity
more info you can read :https://developer.android.com/guide/topics/ui/menus.html
HOW TO OVERWRITE:
@Override
public void onActionModeStarted(android.view.ActionMode mode) {
    mode.getMenu().clear();
    Menu menus = mode.getMenu();
    mode.getMenuInflater().inflate(R.menu.highlight,menus);
    super.onActionModeStarted(mode);
}

highlight
    <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/impclick"
        android:title="Mark As Important"
      />
    <item android:id="@+id/colorclick"
        android:title="Mark with color" />
</menu>

A: This solution is not depend on Action mode of Activity and work for all android platform

I tried to give answer but it exceeds the character limits so I am putting some code part

Reference Link 1 For Selection On Web View

https://github.com/btate/BTAndroidWebViewSelection

Reference Link 2 For Making Web View Marker

https://github.com/liufsd/WebViewMarker

Both above links really plays important role and developed by some awesome developers. First Of All Need Some Research On TextSelectionSupport Class From Reference Link 1. I customised two lines of code in TextSelectionSupport class to get rectangle of selection in Selection Listener here.

Clone the Sample Project from here
  https://github.com/ab-cse-2014/WebViewSelection.git
See The implementation of CustomWebView and Use Of TextSelectionSupport class.
This is my web view class in project

 import android.content.Context;
 import android.graphics.Rect;
 import android.os.Build;
 import android.support.annotation.RequiresApi;
 import android.support.v7.app.AppCompatActivity;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.webkit.WebView;
 import android.widget.PopupWindow;
 import android.widget.Toast;

 import com.cse.webviewtextselection.R;
 import com.cse.webviewtextselection.webviewmaker.TextSelectionSupport;

 public class CustomWebView extends WebView {

private final String TAG = this.getClass().getSimpleName();

private Context mContext;

private TextSelectionSupport mTextSelectionSupport;

private PopupWindow mPopupWindow;

private int currentTop;

public CustomWebView(Context context) {
    super(context);
    mContext = context;
    initSetUp();
    preparePopupWindow();
}

public CustomWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    initSetUp();
    preparePopupWindow();
}

public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;
    initSetUp();
    preparePopupWindow();
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    initSetUp();
    preparePopupWindow();
}

private void initSetUp() {

    mTextSelectionSupport = TextSelectionSupport.support((AppCompatActivity) mContext, this);
    mTextSelectionSupport.setSelectionListener(new TextSelectionSupport.SelectionListener() {
        @Override
        public void startSelection() {

        }

        @Override
        public void selectionChanged(String text, Rect rect) {
            Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
            showPopAtLocation(mPopupWindow, rect.left, rect.top);
        }

        @Override
        public void endSelection() {
            if (mPopupWindow != null) {
                mPopupWindow.dismiss();
            }
        }
    });
}

private void preparePopupWindow() {

    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View customPopupView =  layoutInflater.inflate(R.layout.custom_popup_layout, null);
    mPopupWindow = new PopupWindow(customPopupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
    mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog);

}

private void showPopAtLocation(PopupWindow mPopupWindow, int x, int y) {

    if (mPopupWindow != null) {

        if (currentTop != 0 || currentTop > ((AppCompatActivity)mContext).getWindow().getDecorView().getHeight()) {

                if (y > currentTop) {

                    y -= currentTop;

                }

        }

        Log.d("Current Top : ", String.valueOf(currentTop));
        Log.d("Y : ", String.valueOf(y));

        //mPopupWindow.showAtLocation(((AppCompatActivity)mContext).findViewById(R.id.parentRelativeLayout), Gravity.NO_GRAVITY, x, y);
        mPopupWindow.showAtLocation(((AppCompatActivity)mContext).getWindow().getDecorView(), Gravity.NO_GRAVITY, x, y);

    }

}

@Override
protected void onScrollChanged(int newLeft, int newTop, int oldLeft, int oldTop) {

    currentTop = newTop;

    super.onScrollChanged(newLeft, newTop, oldLeft, oldTop);
}
 }

Custom Popup Menu XML like androids smart text selection(custom_popup_layout.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myCustomMenuLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/transparent">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@android:color/white"
    android:elevation="5dp"
    android:layout_margin="12dp">

    <TextView
        android:id="@+id/menuOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Mark With Color"
        android:textColor="@android:color/black"
        android:padding="10dp"
        android:maxLines="1"/>

    <TextView
        android:id="@+id/menuTwo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Mark As Important"
        android:textColor="@android:color/black"
        android:padding="10dp"
        android:maxLines="1"/>

    <TextView
        android:id="@+id/menuThree"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Show More"
        android:textColor="@android:color/black"
        android:padding="10dp"
        android:maxLines="1"/>

</LinearLayout>

</LinearLayout>

Output Screen Shots

A: what you need is action mode, in activity:
    @Override
    public void onActionModeStarted(ActionMode mode) {
        Menu menu = mode.getMenu();

        // you can remove original menu: copy, cut, select all, share ... or not
        menu.clear();

        // here i will get text selection by user
        menu.add(R.string.action_menu_preview_card)
                .setEnabled(true)
                .setVisible(true)
                .setOnMenuItemClickListener(item -> {
                    if (mWebview != null) {
                        mWebview.evaluateJavascript("window.getSelection().toString()", value -> {
                            value = StringUtil.trimToNull(value);
                            if (value != null) {
                                // do something about user select
                            }
                        });
                    }
                    // Post a delayed runnable to avoid a race condition
                    // between evaluateScript() result and mode.finish()
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mode.finish();
                        }
                    }, 200);
                    return true;
                });
        super.onActionModeStarted(mode);
    }

i has test it above android 21, this can handle action mode menu click, and mode.getMenuInflater().inflate(...) can't do it.

A: i think here can help you .
For the sake of completeness, here is how I fixed the problem:
I followed the suggestion according to this answer, with a little more tweaking to more closely match the overridden code:
public class MyWebView extends WebView {
private ActionMode mActionMode;
private mActionMode.Callback mActionModeCallback;

@Override
public ActionMode startActionMode(Callback callback) {
    ViewParent parent = getParent();
    if (parent == null) {
        return null;
    }
    mActionModeCallback = new CustomActionModeCallback();
    return parent.startActionModeForChild(this, mActionModeCallback);
}

}
Essentially, this forces your customized CAB to appear instead of the Android CAB. Now you have to modify your callback so that the text highlight will go away along with the CAB:
public class MyWebView extends WebView {
    ...
    private class CustomActionModeCallback implements ActionMode.Callback {
        ...
        // Everything up to this point is the same as in the question
    // Called when the user exits the action mode
    @Override
    public void onDestroyActionMode(ActionMode mode) {
        clearFocus(); // This is the new code to remove the text highlight
         mActionMode = null;
    }
}

}
That's all there is to it. Be aware that as long as you are using MyWebView with the overridden startActionMode there is NO WAY to get the native CAB (the copy/paste menu, in the case of a WebView). It may be possible to implement that sort of behavior, but that is not the way this code works.
UPDATE: There is a much easier way to do this! The above solution works well, but here is an alternative, easier way.
This solution provides less control over the ActionMode, but it requires far less code than the above solution.
public class MyActivity extends Activity {
private ActionMode mActionMode = null;

@Override
public void onActionModeStarted(ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu();
        // Remove the default menu items (select all, copy, paste, search)
        menu.clear();

        // If you want to keep any of the defaults,
        // remove the items you don't want individually:
        // menu.removeItem(android.R.id.[id_of_item_to_remove])

        // Inflate your own menu items
        mode.getMenuInflater().inflate(R.menu.my_custom_menu, menu);
    }

    super.onActionModeStarted(mode);
}

// This method is what you should set as your item's onClick
// <item android:onClick="onContextualMenuItemClicked" />
public void onContextualMenuItemClicked(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.example_item_1:
            // do some stuff
            break;
        case R.id.example_item_2:
            // do some different stuff
            break;
        default:
            // ...
            break;
    }

    // This will likely always be true, but check it anyway, just in case
    if (mActionMode != null) {
        mActionMode.finish();
    }
}

@Override
public void onActionModeFinished(ActionMode mode) {
    mActionMode = null;
    super.onActionModeFinished(mode);
}

}
Here is an example Menu to get you started:

<item
    android:id="@+id/example_item_1"
    android:icon="@drawable/ic_menu_example_1"
    android:showAsAction="always"
    android:onClick="onContextualMenuItemClicked"
    android:title="@string/example_1">
</item>

<item
    android:id="@+id/example_item_2"
    android:icon="@drawable/ic_menu_example_2"
    android:showAsAction="ifRoom"
    android:onClick="onContextualMenuItemClicked"
    android:title="@string/example_2">
</item>

That's it! You're done! Now your custom menu will show up, you don't have to worry about the selection, and you barely have to concern yourself with the ActionMode lifecycle.
This works nearly flawlessly with a WebView that occupies its entire parent Activity. I am not sure how well it will work if there are multiple Views within your Activity at one time. It will likely require some tweaking in that case.


text:
Q: Bootstrap 4 equal height list-groups inside card-deck I like to make a card-desk with Bootstrap 4 that contains internal list-groups or card-block's (whatever sections) and this sections should have the  same horizontal height.
I tried with d-flex flex-column and list-groups. nothing worked as expected. set a fixed height to each section is not an option.
Example:
https://jsfiddle.net/7kvktrh5/
Code:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

Product 1

Some description

Price

Product 2

Some Text

Some description: This card has supporting text belosupporting textporting text belosuppal content.

Price

Product 3

This is a wider card little bit longer.

Some description: This card textporting text belosuppal content.

Price

A: I hope here is your solution

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

Product 1

Product 2

Some Text

Product 3

This is a wider card little bit longer.

Product 1

Some description: This card has supporting text belosupporting textporting text belosuppal content.

Product 2

Some Text

Product 3

This is a wider card little bit longer.

Product 1

Product 2

Some Text

Product 3

This is a wider card little bit longer.


text:
Q: MATLAB Freqz in Python I am trying to convert a simple plot code from Matlab to Python. The original code can be seen as:
   figure()
testlist = [
        0.03046874845
        -0.05527424795
        0.01682650241
        0.006369163085
        0.00203891158
        0.0161380391
        -0.04452231783
        0.05169710771
        -0.03534597353
        0.0162988922
        -0.007158760388
        0.009835218937
        0.00781369055
        -0.03391821702
        0.03218318175
        -0.02270531812
        -0.00313687103
        -0.003567927366
        0.02211840897
        -0.00289949565
        0.003331161139
        -0.00084616717
        0.03405780102
        -0.0155820586
        -0.03855276047
        0.01964289036
        -0.03500874771
        -0.03498725681
        -0.03611383299
        0.04926392503
        0.0641901016
        0.04232309722
        0.1535235824
        0.0563995637
        0.04254218955
        -0.4660826409
        -0.1076933526
        -0.6828857313
        0.6867590539
        1.262460447 ]; % #eqs = 28922979, pred_res_rms = 0.02156535305
[h,f] =freqz(0.0215654,[1 -flipud(testlist)'],2048,2);

In order to convert this code into Python, I defined a List with the same name as in Matlab (testlist) with the same values in the Matlab array.
import matplotlib
import scipy
from scipy.signal import freqz
import numpy as np

testlist = list(reversed(testlist))

for i in range(len(testlist)):

    testlist[i] = 1 - testlist[i]

w, h =freqz(0.0215654,testlist,2048)
f = 2 * w /(2*np.pi)

With this code, I get the same f value as the matlab code. However, when I compare the h values between two codes, I get completely different values. Both the Matlab array h and the Python list h contain complex values but they aren't the same even though they should be. How can I bring the Python version so that the output list h is identical to the one from Matlab?
The first 15 values of the Matlab output of h:
-95002000
-1.2697e+01 - 6.6976e+02i
-1.2737e+01 - 3.3507e+02i
-1.2811e+01 - 2.2359e+02i
-1.2914e+01 - 1.6790e+02i
-1.3047e+01 - 1.3453e+02i
-1.3208e+01 - 1.1230e+02i
-13.3990 -96.4322i
-13.6180 -84.5337i
-13.8644 -75.2708i
-14.1373 -67.8428i
-14.4352 -61.7387i
-14.7561 -56.6166i
-15.0977 -52.2382i
-15.4568 -48.4324i

The first 15 values of the Python output of h:
 0.00055296+0.00000000e+00j 0.00055278+1.69856946e-05j
 0.00055224+3.39703866e-05j 0.00055135+5.09530728e-05j
 0.00055009+6.79327484e-05j 0.00054847+8.49084066e-05j
 0.0005465 +1.01879038e-04j 0.00054416+1.18843629e-04j
 0.00054146+1.35801163e-04j 0.00053839+1.52750617e-04j
 0.00053495+1.69690963e-04j 0.00053114+1.86621167e-04j
 0.00052697+2.03540186e-04j 0.00052241+2.20446971e-04j
 0.00051748+2.37340461e-04j

A: The error is not in the implementation of freqz, they are the same.  The error is instead in the way you are passing the data into freqz.
MATLAB interprets
1 -testlist

as a 1 followed by the negative of testlist.  If you remove the space:
1-testlist

will be interpreted as 1 minus the testlist, which is what you need to have the two implementations match.


text:
Q: How do you work with a C++ function that returns a shared_ptr when calling it from Rust over FFI? C++
shared_ptr<Foo> create_foo();

Rust
extern "C" {
    pub fn create_foo() -> ???;
}

Bindgen turns a shared_ptr into an opaque blob.
I can't just take the raw pointer because then the C++ code is unaware that I have a reference to Foo and might call its deconstructor.

A: std::shared_ptr is a C++ class and a non-trivial type that can not be exported as is from a library — you need its definition in your target language to conform to the one in C++. To use FFI you need to provide your library functions with a simple C ABI (the C++ ABI is not stable and may change between compiler versions (as might Rust's ABI)) and I doubt that all of functions related to std::shared_ptr are such, so there is one more obstacle for that.
I'd suggest to return a raw C-pointer from your library instead and own it in Rust.
Even in C++, to load a C++ library you provide C-ABI functions (via extern C) to gain access to a pointer of your type and then you use it in C++ as how as you want.
So, a few points:

*

*Return a raw C pointer from a function without name mangling so that we know its name and can link to it:
extern "C" Foo* create_foo();

*Add a deleter which knows how to properly deallocate the object:
extern "C" void delete_foo(Foo *);

*Let the library user (Rust) decide how to own it, for example, by boxing the value and using it with atomic reference counter via std::sync::Arc (as std::shared_ptr does):
extern "C" {
    fn create_foo() -> *mut Foo;
    fn delete_foo(p: *mut Foo);
}

struct MyFoo {
    raw: *mut Foo,
}

impl MyFoo {
    fn new() -> MyFoo {
        unsafe { MyFoo { raw: create_foo() } }
    }
}

impl Drop for MyFoo {
    fn drop(&mut self) {
        unsafe {
            delete_foo(self.raw);
        }
    }
}

fn main() {
    use std::sync::Arc;

    let value = Arc::new(MyFoo::new());
    let another_value = value.clone();
    println!("Shared counter: {}", Arc::strong_count(&value));
}

*Let the C++ side forget about owning this pointer - you can't rely on it if it is used from outside the library and you give a raw pointer to it.
If you don't have any access to the library sources, can't do anything with it: the std::shared_ptr object will not release the pointer ever and we can't make it not to delete the pointer.

A:
I can't just take the raw pointer because then the C++ code is unaware that I have a reference to Foo and might calls it's deconstructor.

Yes and no. With your actual example. C++ will give ownership of the shared_ptr to the one who called create_foo, so C++ knows that there is still something that owns the pointer.
You need to add a get function that will get the value for you without losing ownership of the pointer, something like this:
extern "C" {
    std::shared_ptr<Foo> create_foo() {
        // do the thing
    }
    /* or maybe this
    std::shared_ptr<Foo> &&create_foo() {
        // do the thing
    }
    */

    Foo *get_foo(std::shared_ptr<Foo> &foo) {
        foo.get();
    }

    void destroy_foo(std::shared_ptr<Foo> foo) {
    }
    /* or maybe this
    void destroy_foo(std::shared_ptr<Foo> &&foo) {
    }
    */
}

Also shared_ptr<Foo> is not valid C, so I don't know if bindgen and C++ with accept this (probably a warning) but that is already present in your code.
On the Rust side, you could do this:
// must be generated by bindgen and this might create a lot of problems
// this need to be the same struct as the shared_ptr on the C++ side.
// if even one octet is not correct you will run into bugs
// BE SURE that bindgen don't implement Copy for this
struct shared_ptr<T>;

struct Foo(i32);

extern "C" {
    fn create_foo() -> shared_ptr<Foo>;

    fn get_foo(foo: &shared_ptr<Foo>) -> *mut Foo;

    fn destroy_foo(foo: shared_ptr<Foo>);
}

fn main() {
    unsafe {
        let my_shared_foo = create_foo();
        let foo = get_foo(&my_shared_foo);
        (*foo).0;
        destroy_foo(my_shared_foo);
    }
}

Of course this is just an example, and nothing is really safe in any of this. And as I can't test, please let me know if I wrote something that doesn't work. bindgen should do the job.

A: You can return a pointer to a dynamically allocated std::shared_ptr
In the C++ side:
shared_ptr<Foo> create_foo();
extern "C" void *rust_create_foo()
{
    shared_ptr<Foo> foo = create_foo();
    return static_cast<void*>(new shared_ptr<Foo>(foo));
}
extern "C" void rust_delete_foo(void *ptr)
{
    shared_ptr<Foo> *foo = static_cast<shared_ptr<Foo>*>(ptr);
    delete foo;
}

And in the Rust side:
extern "C" {
    pub fn rust_create_foo() -> *const c_void;
    pub fn rust_delete_foo(foo: *const c_void);
}

If you fail to call rust_delete_foo then the dynamically allocated pointer will leak and so the object will never be deallocated.
Then, when you want to use the object, you will have to write wrapper functions that take that void*, do the cast and call the appropriate function.


text:
Q: iOs simulator frame rate drop I'm doing my first steps in spriteKit, i only have two scenes, in the second one i have a method which spawns little pixels (rocks) and they fall down with the physic. The other thing I have is a parallax effect with a image.png which size is 323x90. The image move in the background from left to right and when it disappear in the right it spawns again (i don't destroy the node, only change it's position) in the left and begin again the animation.
When the rocks are falling, the node max count is 20 - 21 but my FPS drop to 20-21. This is beginning to slow down and i don't understand why, i wonder what will happen when my scene grows up. I've tried with iphone 5 simulator and is the same. Does any one know why?


text:
Q: Reading *.mhd/*.raw format in python Can anyone please tell me the way I can read a dataset containing .mhd/.raw files in python?

A: Adding on the above posts, you can start with a CT-Scan .mhd file downloaded from the here and display / save 29 images with the following code (assuming that you have both the header and the raw files downloaded in the current directory):
import SimpleITK as sitk
import matplotlib.pylab as plt
ct_scans = sitk.GetArrayFromImage(sitk.ReadImage("training_001_ct.mhd", sitk.sitkFloat32))
plt.figure(figsize=(20,16))
plt.gray()
plt.subplots_adjust(0,0,1,1,0.01,0.01)
for i in range(ct_scans.shape[0]):
    plt.subplot(5,6,i+1), plt.imshow(ct_scans[i]), plt.axis('off')
    # use plt.savefig(...) here if you want to save the images as .jpg, e.g.,
plt.show()

Here is the same CT-scan .mhd file that is read with SimpleITK and animated:

A: The easiest way is to use SimpleITK (MedPy uses ITK for .mhd/.raw files too). Command
pip install SimpleITK

works for many python versions. For reading .mhd/.raw you can use this code from kaggle

import SimpleITK as sitk
import numpy as np
'''
This funciton reads a '.mhd' file using SimpleITK and return the image array, origin and spacing of the image.
'''

def load_itk(filename):
    # Reads the image using SimpleITK
    itkimage = sitk.ReadImage(filename)

    # Convert the image to a  numpy array first and then shuffle the dimensions to get axis in the order z,y,x
    ct_scan = sitk.GetArrayFromImage(itkimage)

    # Read the origin of the ct_scan, will be used to convert the coordinates from world to voxel and vice versa.
    origin = np.array(list(reversed(itkimage.GetOrigin())))

    # Read the spacing along each dimension
    spacing = np.array(list(reversed(itkimage.GetSpacing())))

    return ct_scan, origin, spacing

A: Using skimage may be even easier after you installed SimpleITK
import skimage.io as io
img = io.imread('file.mhd', plugin='simpleitk')

This will give you a numpy array with z,y,x sorting.

A: You can try to use MedPy or this mhd_utils script


text:
Q: Cutting off polygons that exceed world boundaries in QGIS? I have some polygons that exceed the boundaries of the world map on the latitude. Basically, they stick out of the world map overlay at the left and right side of the screen. This is causing them to overlap when I load them in the software I use the view the exported shapefile.
I got much more polygons than in this mockup but I cannot share the original data. I use diffuse to create a single outline.

The problem is that the green and red polygons create an overlap in my shapefile viewer because they exceed the world map.
In the case of the green polygon, the problem can be solved if there is a way to cut off the data beyond the world map because the shape is the same.
In case of the red polygon, the part that is outside the world map doesn't exist at the right side of the screen so somehow that part can't be cut.
The part that overflow needs to be copied to the left side of the world map or the overflowing data should not create overlaps.
Basically, I want to create outlines only polygon. This is working, except for those couple of polygons that create overlap because they exceed the world map.


text:
Q: Highcharts yAxis title click I want to set the yAxis extremes on the yAxis title click.
yAxes[i].setExtremes(min, max);

I am able to capture the onclick event on the yAxis labels*.
Here is the JSFiddle demo
but I want to enable click on yAxis title and get the values from the user and set extremes.

A: To capture onclick for the axis title you can use your existing approach of iterating over the axis and adding a similar onclick function to the axis.axisTitle.element (JSFiddle):
var yAxes = pChart.yAxis;
yAxes.forEach(function(axis) {
    axis.labelGroup.element.childNodes.forEach(function(label){
        label.style.cursor = "pointer";
        label.onclick = function(){console.log('You clicked on '+this.textContent);};
    });
    axis.axisTitle.element.style.cursor = "pointer";
    axis.axisTitle.element.onclick = function(){console.log('You clicked on '+this.textContent);};
});