text:
Q: Cant use the Boolean operator 'or' in a if statement to initiate if either string contains the following characters. Only works if separate statements Part of the project I`m working on requires me to automate arcGIS functions using python. While trying to locate files I noticed that when I included the 'or' operator in my if statement that the loop would stop collecting files after currentDirList no longer contained the first string. The other half of the data is named differently and I thought I could use the 'or' operator to search for either possible naming convention. However I can only get it to work as two separate statements. This is does what I need it to do. However, I have no experience in python aside from this and I am learning as I go. Despite my attempts to search for an answer I don't understand why it doesn't work. Could someone help me understand why this is happening?
Using the 'or' operator
while listCount < listSize:
    if currentDirList[listCount].__contains__('Ashland Wheat HessianFly' or 'HF_Ashland'):
        tifPath = str(Path(dataSource + "\\" + currentDirList[listCount]))
        currentSource.append(glob.glob(tifPath + '/*.tif'))
    listCount += 1

As separate statements
while listCount < listSize:
    if currentDirList[listCount].__contains__('Ashland Wheat HessianFly'):
        tifPath = str(Path(dataSource + "\\" + currentDirList[listCount]))
        currentSource.append(glob.glob(tifPath + '/*.tif'))
    listCount += 1

listCount = 0
while listCount < listSize:
    if currentDirList[listCount].__contains__('HF_Ashland'):
        tifPath = str(Path(dataSource + "\\" + currentDirList[listCount]))
        currentSource.append(glob.glob(tifPath + '/*.tif'))
    listCount += 1

A: Don't call __contains__ directly, use the in operator.
You need to write two separate comparisons and combine them with or.
if 'Ashland Wheat HessianFly' in currentDirList[listCount] or 'HF_Ashland' in currentDirList[listCount]:


text:
Q: Correlation between Tensor products over a Ring and it's subring I'm intrested in finding out what the correlation between the two tensor products
$$ M \otimes_R  N \quad and \quad M \otimes_S N \quad $$
is.(R,S are Rings and S is a subring of R)
I know that we can construct a surjective Homomorphism $\phi : M\otimes_R N \to M\otimes_S N$
Now i just used the isomorphism theorem to derive $M\otimes _{ R }N\quad \cong \quad M\otimes _{ S }N/ker\quad \phi) $
Is this really all there is or can we say more things about their correlation

redpajama_set_name: RedPajamaStackExchange


text:
Q: Plot and an error I have set of matrices(multiplied to give U123[q, p, r]) and would like to diagonalize U123[q, p, r] and plot the eigenvalues. Fortunately, after some try I was able to get out of the Root. For this, I used dynamic calculation (dynamically giving values to the variables and calculating the eigenvalues inside the Module).
Element[k, Reals];
H31[q_] := {{0, 0, q Exp[I k]}, {0, 0, 0}, {q  Exp[-I k], 0, 0}};
H12[p_] := {{0, p, 0}, {p, 0, 0}, {0, 0, 0}};
H23[r_] := {{0, 0, 0}, {0, 0, r}, {0, r, 0}};

(*FullSimplify[PowerExpand@MatrixExp[-I  H31].MatrixExp[-I  H12].\
MatrixExp[-I  H23].MatrixExp[-I  H12]];*)

U123[q_, p_, r_] :=
  MatrixExp[-I  H31[q]].MatrixExp[-I  H23[r]].MatrixExp[-I  H12[p]];

quit[q_, p_, r_] :=
 Module[{$ph}, $ph = -I Log[Eigenvalues[U123[q, p, r]]];
  Plot[Evaluate@Flatten[Through[{Re}[$ph]]], {k, -Pi, Pi},
   Frame -> True,
   PlotLegends -> {"Re $ph1", "Re $ph2", "Re $ph3"}]]
Manipulate[
 quit[q, p, r], {{q, Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{p, 3 Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{r, Pi/4}, 0, 2 Pi,
  Appearance -> "Labeled"}]

The problem I am facing now is, I can freely change p and r but not q (which supposed to work like them p and r).
This what I getting after changing q, even by a very small value. Only thing I am able to do is that I am able to change the values for q here {{q, Pi/2}, 0, 2 Pi, Appearance -> "Labeled"}. Then it works but not through sliding.

Can this graph be resolved, as I am getting this also:

I have no idea how to solve this. To get even this much working, I am very thankful to the solutions I received at this and this from @Bob Hanlon and @yohbs.

A: Adapted from the code in Reordering numerically calculated eigenvalues assuming smooth dependence on a parameter
Clear["Global`*"]
Element[k, Reals];
H31[k_, q_] := {{0, 0, q (Cos[k] + I Sin[k])}, {0, 0,
    0}, {q (Cos[k] + I Sin[k]), 0, 0}};
H12[p_] := {{0, p, 0}, {p, 0, 0}, {0, 0, 0}};
H23[r_] := {{0, 0, 0}, {0, 0, r}, {0, r, 0}};

(*FullSimplify[PowerExpand@MatrixExp[-I H31].MatrixExp[-I \
H12].MatrixExp[-I H23].MatrixExp[-I H12]];*)

U123[k_?NumericQ, q_?NumericQ, p_?NumericQ, r_?NumericQ] :=
  MatrixExp[-I H31[k, q]].MatrixExp[-I H23[r]].MatrixExp[-I H12[
       p]] // N;

q = \[Pi]/2;
p = 3 \[Pi]/2;
r = \[Pi]/4;
c = {};
frames = {};
xvals = Pi Range[-1, 1, 1/100];
alle = Table[({k, #} & /@ (-I Log[Eigenvalues[U123[k, q, p, r]]] //
   Re)), {k, xvals}];
colors = {RGBColor[0.368417, 0.506779, 0.709798], RGBColor[
   0.880722, 0.611041, 0.142051], RGBColor[
   0.560181, 0.691569, 0.194885]};
Clear[g];
Monitor[Do[
  line = First@Position[alle, First@SortBy[#, #[[2]] &]] & /@
    alle[[;; 2]];
  MapIndexed[(nextx = #;
     proj = {nextx,
       Quiet[Interpolation[alle[[Sequence @@ #]] & /@ line]@nextx]};
     AppendTo[line,
      Position[alle,
        First@Nearest[alle[[First@#2 + 2]], proj]][[1]]]) &,
   xvals[[3 ;;]]];
  AppendTo[c, alle[[Sequence @@ #]] & /@ line];
  alle = Delete[alle, line];
  AppendTo[frames,
   g = Show[{If[Length@First@alle > 0, ListPlot[Flatten[alle, 1]],
       Graphics[]],
      Graphics[
       MapIndexed[{Thick, colors[[First@#2]], Line[#]} &, c]]},
     PlotRange -> All, AxesOrigin -> {0, 0}]], {nrem, 3, 1, -1}], g]
Graphics[MapIndexed[{Thick, colors[[First@#2]], Line[#]} &, c],
 Axes -> True]

before:

after:

edit:
to put the above inside Manipulate, just wrap it inside a function e.g. plotevs[...] that returns the figure, like this:
Element[k, Reals];
H31[k_, q_] := {{0, 0, q (Cos[k] + I Sin[k])}, {0, 0,
    0}, {q (Cos[k] + I Sin[k]), 0, 0}};
H12[p_] := {{0, p, 0}, {p, 0, 0}, {0, 0, 0}};
H23[r_] := {{0, 0, 0}, {0, 0, r}, {0, r, 0}};

(*FullSimplify[PowerExpand@MatrixExp[-I H31].MatrixExp[-I \
H12].MatrixExp[-I H23].MatrixExp[-I H12]];*)

U123[k_?NumericQ, q_?NumericQ, p_?NumericQ, r_?NumericQ] :=
  MatrixExp[-I H31[k, q]].MatrixExp[-I H23[r]].MatrixExp[-I H12[
       p]] // N;

plotevs[q_, p_, r_] := Module[{},
  c = {};
  frames = {};
  xvals = Pi Range[-1, 1, 1/100];
  (*alle=Table[{{xvals[[k]],xvals[[k]],xvals[[k]]},-I Log[Eigenvalues[
  U123[xvals[[k]],q,p,r]]]//Re}\[Transpose],{k,1,Length[xvals]}];*)

  alle = Table[({k, #} & /@ (-I Log[Eigenvalues[U123[k, q, p, r]]] //
        Re)), {k, xvals}];
  colors = {RGBColor[0.368417, 0.506779, 0.709798], RGBColor[
    0.880722, 0.611041, 0.142051], RGBColor[
    0.560181, 0.691569, 0.194885]};
  Clear[g];
  Do[line =
    First@Position[alle, First@SortBy[#, #[[2]] &]] & /@
     alle[[;; 2]];
   MapIndexed[(nextx = #;
      proj = {nextx,
        Quiet[Interpolation[alle[[Sequence @@ #]] & /@ line]@nextx]};
      AppendTo[line,
       Position[alle, First@Nearest[alle[[First@#2 + 2]], proj]][[
        1]]]) &, xvals[[3 ;;]]];
   AppendTo[c, alle[[Sequence @@ #]] & /@ line];
   alle = Delete[alle, line];
   (*AppendTo[frames,g=Show[{If[Length@First@alle>0,ListPlot[Flatten[
   alle,1]],Graphics[]],Graphics[MapIndexed[{Thick,colors[[First@#2]],
   Line[#]}&,c]]},PlotRange\[Rule]All,AxesOrigin\[Rule]{0,
   0}]]*), {nrem, 3, 1, -1}];
  Return[Graphics[
    MapIndexed[{Thick, colors[[First@#2]], Line[#]} &, c],
    Axes -> True]]
  ]

then use Manipulate[] as before:
Manipulate[
 plotevs[q, p, r], {{q, Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{p, 3 Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{r, Pi/4}, 0, 2 Pi,
  Appearance -> "Labeled"}]

A: Thanks to you all again.
I was able to get answer partly (still great help, after working on the problem). I was able to resolve the first problem of the that blue color error plot but not second one.
Here is the answer:
Element[k, Reals];
H31[q_] := {{0, 0, q  (Cos[k] + I Sin[k])}, {0, 0, 0}, {q  (Cos[k] + I Sin[k]), 0, 0}};
H12[p_] := {{0, p, 0}, {p, 0, 0}, {0, 0, 0}};
H23[r_] := {{0, 0, 0}, {0, 0, r}, {0, r, 0}};

(*FullSimplify[PowerExpand@MatrixExp[-I  H31].MatrixExp[-I  H12].\
MatrixExp[-I  H23].MatrixExp[-I  H12]];*)

U123[q_, p_, r_] :=
  MatrixExp[-I  H31[q]].MatrixExp[-I  H23[r]].MatrixExp[-I  H12[p]];

quit[q_, p_, r_] :=
 Module[{$ph}, $ph = -I Log[Eigenvalues[U123[q, p, r]]];
  Plot[Evaluate@Flatten[Through[{Re}[$ph]]], {k, -Pi, Pi},
   Frame -> True,
   PlotLegends -> {"Re $ph1", "Re $ph2", "Re $ph3"}]]
Manipulate[
 quit[q, p, r], {{q, Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{p, 3 Pi/2}, 0, 2 Pi,
  Appearance -> "Labeled"}, {{r, Pi/4}, 0, 2 Pi,
  Appearance -> "Labeled"}]

I just redefined Exp[I k] = (Cos[k] + I Sin[k]). However, I don't have a single idea of the fact that why it worked, also of the second problem.


text:
Q: Does Meta Tag "Viewport" Property Behave in Emails the Same As the Standard Web Page? Context: I am trying to maintain some old code (an email template specifically) and I need to make it mobile readable (not necessarily good-looking). The old code I am talking about was basically created specifically for the desktop view as a priority. Due to time constraints, I thought about utilizing the meta "viewport" property.
My knowledge: I am very well aware that emails behave very differently from the ordinary web page and most of the layouts are usually done using table elements due to minimal support of various CSS properties.
My markup:
<html>
    <head>
        <meta name="viewport" content="width=670">
    </head>

    <body>
        <div>
            <!-- email content -->
        </div>
    </body>
</html>

Notice the code <meta name="viewport" content="width=670">. This is what I am trying to make work in the email. My testing environment currently is the Gmail app on Android & using Chrome while using dev tools mobile view.
What I noticed is, despite adding this meta tag, the content does not adjust to treat any device to "become" width=670 like it would normally function if done on a normal web page (i.e., not on email).
Am I doing something wrong or missing something? Or perhaps it is being overridden by the email client? Does meta tag "Viewport" property behave in emails the same as the standard web page?
N.B., I realize that this might come off as an XY problem for some of the viewers. It is not. I really want to know, for knowledge's sake, on how to make this work. Thanks in advance!

A: Typically, mobile clients will try and do their own scaling, and as such I believe the <meta name=viewport...> is overridden or ignored.
If the email is simple, i.e. one column, a <div> approach might suffice, but otherwise as you say, everything is done in tables for the sake of Outlook desktop rendering.
Readability in mobiles typically comes down to whether the content in the email is an appropriate size for viewing. If you have images that are set to widths greater than about 300px wide, and they do not have mobile overrides, the mobile client will scale the entire email down, to potentially unreadable size.
For something simple, you could add this:
@media screen and (max-width:620px) {
 img {
    width:100%!important;
    height:auto!important;
}

There can be other such content that gets in the way, like other fixed width block elements, or long unbreakable words (much less often), that will also force resizing.


text:
Q: Finding PID and Base Address in C++ I'm trying to write a code in C++ which would display a process ID and base address of some application, PID seems to look correct but base address is 0, which is incorrect. My question is - what's wrong here?
IDE: Code::Blocks
Also to make it even run i had to set up "-lpsapi" in
Settings -> Compiler -> Linker settings -> Other linker options
I was thinking about building this as admin but could't find such option in Code::Block (maybe build-in?)
Console output
Build messages
#define WINVER 0x0501
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <Psapi.h>
#include <tlhelp32.h>

using namespace std;

HANDLE GetHandle()
{
    string name = "PathOfExile_x64.exe";
    DWORD pid = 0;

    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    PROCESSENTRY32 process;
    ZeroMemory(&process, sizeof(process));
    process.dwSize = sizeof(process);

    if (Process32First(snapshot, &process))
    {
        do
        {
            if (string(process.szExeFile) == name)
            {
               pid = process.th32ProcessID;
               break;
            }
        } while (Process32Next(snapshot, &process));
    }

    CloseHandle(snapshot);

    if (pid != 0)
    {
        cout << "pid = " << pid << endl;
        return OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
    }

    return NULL;
}

HMODULE GetModule()
{
    HMODULE hMods[1024];
    HANDLE pHandle = GetHandle();
    DWORD cbNeeded;
    unsigned int i;

    if (EnumProcessModules(pHandle, hMods, sizeof(hMods), &cbNeeded))
        {
        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
        {
            TCHAR szModName[MAX_PATH];
            if (GetModuleFileNameEx(pHandle, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR)))
            {
                string wstrModName = szModName;

                string wstrModContain = "PathOfExile_x64.exe";
                if (wstrModName.find(wstrModContain) != string::npos)
                {
                    CloseHandle(pHandle);
                    return hMods[i];
                }
            }
        }
    }
    return nullptr;
}

int main()
{
    HWND WindowHandle = FindWindow(nullptr, "Path of Exile");
    DWORD PID;
    GetWindowThreadProcessId(WindowHandle, &PID);
    PVOID hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, 0, PID);

    HMODULE Module = GetModule();
    DWORD BaseAddress = (DWORD)Module;

    cout << BaseAddress << endl;

}

A: I would do it like this, tested working.  I'm not familiar with the Enum functions, I prefer to use the ToolHelp32Snapshot function
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <tlhelp32.h>

DWORD GetProcId(const char* procName)
{
    DWORD procId = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hSnap != INVALID_HANDLE_VALUE)
    {
        PROCESSENTRY32 procEntry;
        procEntry.dwSize = sizeof(procEntry);

        if (Process32First(hSnap, &procEntry))
        {
            do
            {
                if (!_stricmp(procEntry.szExeFile, procName))
                {
                    procId = procEntry.th32ProcessID;
                    break;
                }
            } while (Process32Next(hSnap, &procEntry));

        }
    }
    CloseHandle(hSnap);
    return procId;
}

uintptr_t GetModuleBaseAddress(DWORD procId, const char* modName)
{
    uintptr_t modBaseAddr = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
    if (hSnap != INVALID_HANDLE_VALUE)
    {
        MODULEENTRY32 modEntry;
        modEntry.dwSize = sizeof(modEntry);
        if (Module32First(hSnap, &modEntry))
        {
            do
            {
                if (!_stricmp(modEntry.szModule, modName))
                {
                    modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
                    break;
                }
            } while (Module32Next(hSnap, &modEntry));
        }
    }
    CloseHandle(hSnap);
    return modBaseAddr;
}

int main()
{
    DWORD procId = GetProcId("PathOfExile_x64.exe");

    uintptr_t modBase = GetModuleBaseAddress(procId, "PathOfExile_x64.exe");

    std::cout << "0x" << std::hex << modBase << std::endl;
    std::getchar();
    return 0;
}


text:
Q: vba Sort by multiple criteria and copy values to another sheet Hello again guys I have another tough problem for you, well may not be tough for you but it is for me. So I have one sheet with all of my data and I would like to sort by the first 3 conditions (Reject, Other, & year) Would be nice to be able to pick months too. Once the data is filtered I have it copied and sorted on another sheet so I can do some other functions and generate a table showing amount of times the vendor was rejected. There may be a simpler way to do this but currently this is the way I slapped together. If you have any other suggestions I would like to hear them.Code fails at the year sort. I keep getting all of the data from the other sheet
 ''Generates defect list
Sub Make_Defect_List_Yearly()
    Const REJECTED_COL = 8  'Column H (DISPOSITIO)
    Const DATE_COL = 13
    Dim shAD As Worksheet, shVP As Worksheet
    Dim adRng As Range, vpRng As Range, headers() As Variant
    Dim rng As Range, cel As Range, fCell As Range, lCell As Range
    Dim flg As Byte, LastRow As Long, flag As Boolean, i

    Set shAD = Worksheets("AllData")
    Set shVP = Worksheets("VendorProblems")
    lr = shAD.Cells(Rows.Count, 1).End(xlUp).Row
    Sheets("VendorProblems").UsedRange.ClearContents

'Copy VendorProblems to shVP --------------------------
  Application.ScreenUpdating = False
    shAD.AutoFilterMode = False

    With shAD.UsedRange
        Set adRng = FilterWS(.Columns(DATE_COL), "2017")
        If Not adRng Is Nothing Then
            If .Cells.CountLarge > 2 Then
                Set vpRng = shVP.Cells(shVP.UsedRange.Rows.Count + 1, 1)
                .Offset(1).Resize(.Rows.Count - 1, .Columns.Count).Copy vpRng
            End If
        End If
    End With

    With shAD.UsedRange
        Set adRng = FilterWS(.Columns(REJECTED_COL), "Reject")
        If Not adRng Is Nothing Then
            If .Cells.CountLarge > 2 Then
                Set vpRng = shVP.Cells(shVP.UsedRange.Rows.Count + 1, 1)
                .Offset(1).Resize(.Rows.Count - 1, .Columns.Count).Copy vpRng
            End If
        End If
    End With

    With shAD.UsedRange
        Set adRng = FilterWS(.Columns(REJECTED_COL), "Other")
        If Not adRng Is Nothing Then
            If .Cells.CountLarge > 2 Then
                Set vpRng = shVP.Cells(shVP.UsedRange.Rows.Count + 1, 1)
                .Offset(1).Resize(.Rows.Count - 1, .Columns.Count).Copy vpRng
            End If
        End If
    End With

    shAD.AutoFilterMode = False
'shVP.UsedRange.RemoveDuplicates Columns:=1, Header:=xlNo
'Sort shVP ----------------------------------------------------
    Set vpRng = shVP.UsedRange.Columns(11)
    With shVP.Sort
        .SortFields.Clear
        .SetRange shVP.UsedRange
        .SortFields.Add Key:=vpRng, SortOn:=xlSortOnValues, Order:=xlAscending
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .Apply
    End With
'Remove blanks from shVP --------------------------------------
    With shVP.UsedRange
        shVP.AutoFilterMode = False
        If Len(shVP.Cells(1)) = 0 Then shVP.Cells(1) = "Header": flg = 1
        Set vpRng = FilterWS(shVP.UsedRange.Columns(11), "=")
        If Not vpRng Is Nothing Then
            Set vpRng = shVP.UsedRange.Columns(2).SpecialCells(xlCellTypeVisible)
            If .Cells.Count > 1 Then .SpecialCells(xlCellTypeVisible).EntireRow.Delete
        End If
        If flg = 1 Then shVP.Cells(1).EntireRow.Delete
        shVP.AutoFilterMode = False
    End With
    Application.ScreenUpdating = True
'Copys qty recieved to amnt rejected if amt rejected is blank
    With shVP
        lr = .Cells(.Rows.Count, "A").End(xlUp).Row
        For Each cel In .Range("G2:G" & lr)             'loop through each cell in Column
            If (cel.Value) = "" Then                    'check Command Name
                Set fCell = cel.Offset(0, -3)           'set first cell to be copied in fCell
                Set lCell = cel.Offset(0, 0)
                lCell = fCell
            End If
        Next cel
    End With
'Sorts data alphabetically by vendor
Application.ScreenUpdating = True
    shVP.Activate
    Cells.Select
    Range("A:P").Activate 'old line a118
    With Selection
        .HorizontalAlignment = xlGeneral
        .WrapText = False
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    shVP.Range("A1").Select

    ' Array of header labels
    headers() = Array("Warehouse", "Inspection Type", "ItemID", "QtyReceived", "UOM", "Sample::Sample", "DefectFound", _
                      "Disposition", "PurchOrder", "DISTRIBUTOR", "Manufacturer", "Remarks", "Date", "Cost", "RejectCat", "Date")
    ' Row to insert
    shVP.Activate
    Range("A1").EntireRow.Insert
        With shVP
            For i = LBound(headers()) To UBound(headers())
                .Cells(1, 1 + i).Value = headers(i)
            Next i
    .Rows(1).Font.Bold = True
        End With
End Sub


text:
Q: prolog - multiple outputs, same variable How do I get the following program to produce the following output:
?- genN(3,R).
R=0;
R=1;
R=2;

My current output is just R=0;
code:
genN(1,0).
genN(N,R) :-
    N > 1,
    N1 is N-1,
    genN(N1,R1),
    R is R1.

newer code:
genN(1,R):-R is 0.
genN(N,R) :-
    N > 1,
    N1 is N-1,
    genN(N1,R),
    R is N1.

The above program is meant to output numbers from 0 to N-1.

A: If your Prolog implementation supports clpfd, you could write genN/2 like this:
:- use_module(library(clpfd)).

genN(Up,N) :-
    N #>= 0,
    N #<  Up,
    indomain(N).

Sample query:
?- genN(3,N).
N = 0 ;
N = 1 ;
N = 2.


text:
Q: How to get the features in the kind of vector layer which is created by using protocol? I am learning OpenLayers now. I found a strange thing about the vector layer when I using protocol to create it, for example:
 var scheldtoutflow = new OpenLayers.Layer.Vector("scheldtoutflow", {
     projection: new OpenLayers.Projection("EPSG:900913"),
     strategies: [new OpenLayers.Strategy.Fixed()],
     protocol: new OpenLayers.Protocol.HTTP({
               url: "data/scheldtoutflow",
               format: new OpenLayers.Format.GeoJSON()
            }),
               visibility: false
          });

when I debug this code I found that the features list for this layer is empty. Only if I register some events to the layer, e.g. select feature and so on, the feature list can become correct.
Does anyone know why it is like this? Thank you very much.
Cheers,
Xuan

A: It sounds like this issue could be very similar to this question.  I think you are trying to test the features list inline while the call to populate the features is going to call an HTTP request asynchronously.  The features will be empty as you will be interrogating them before the HTTP request has returned.  To do this correctly you need to add a handler to the layer loadend event to interogate the features


text:
Q: web kit scrollbar not chaging until i hover over it when changing themes In my webpage I am trying to get a custom scroll bar. It is working fine.
Now I have a theme button which allows user to choose either a black theme or a white theme. For this I wrote two css files, one carbon.css and another quartz.css
When a user clicks on one of the themes, I am updating the css file with the below function.
I am able to see all changes correctly except the scroll bar. Until I hover my mouse over the scroll bar, that css change is not happening.
To be more clear, suppose i am in black theme. I am seeing black scroll bar. Now when I click the white theme, I am seeing all my background, text changing properly to white theme. But the scroll bar still remains in black theme. Once I move my mouse on to scroll bar it is updating the scroll bar to white theme.
How can I solve this problem?
Thanks!
Hey Anubav: here is the code I am working after including your changes:
trail.html

  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

  <link href="./carbon.css" rel="stylesheet" type="text/css" id="extCSSFile"/>

carbon Theme

Quartz Theme

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

carbon.css
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size:8.5pt;
    width:inherit;
    min-width:100px;
    max-width:250px;
    margin:10px;
    background-color:#191919;
    color:white;
}

 ul{height:1000px;}

 #carbonTheme, #quartzTheme{
 text-decoration:underline;
 color:blue;
  }
  ::-webkit-scrollbar {
    width: 12px;
 }

::-webkit-scrollbar-track {
 background-color:#aaa;
}

::-webkit-scrollbar-thumb {

  background-color:black;
}

quartz.css
body {
    font-family: Arial, Helvetica, sans-serif;
    font-size:8.5pt;
    width:inherit;
    min-width:100px;
    max-width:250px;
    margin:10px;

 }
  ul{height:1000px;}

  #carbonTheme, #quartzTheme{
  text-decoration:underline;
  color:blue;
 }
 ::-webkit-scrollbar {
 width: 12px;
 }

 ::-webkit-scrollbar-track {
  background-color:#333;
 }

  ::-webkit-scrollbar-thumb {

   background-color:white;
 }

A: To force the browser to repaint the complete DOM just do $("#body").offset().Top; ( body is the ID given to body tag to speed up the selector )
A simple approach to your task can be  just add a attribute disabled="disabled" to your link element
Include LINK  in HEAD section as :
<link href="./carbon.css" rel="stylesheet" type="text/css" id="carbonCSS" />
<link href="./quartz.css" rel="stylesheet" type="text/css" id="quartzCSS" disabled="disabled" />

Include Script Below the link as :

Complete html page may look like :
<!DOCTYPE html>

  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

  <link href="./carbon.css" rel="stylesheet" type="text/css" id="carbonCSS" />
  <link href="./quartz.css" rel="stylesheet" type="text/css" id="quartzCSS" disabled="disabled" />

carbon Theme

Quartz Theme

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

There are no results

A: There are a few weird things about this solution.  As @Quentin pointed out, you shouldn't use the rel attribute simply for a variable storage area.  You may want to either use the css path in the href attribute (since you're returning false anyway) or set a class or id for each link at "black" or "white".
On top of that when you say just $('link') you're automatically just changing the href of your first link element on the page.  I would use an id attr for your theme link element, so you always know you're changing that one (whether you add other links in before that).
Your method also will then add an http request every time you click to change themes.
I think this would be your best solution: put all your styles in the same css sheet with a prefixed class for each theme-specific style and then toggleClass() (jQuery) on your html element to and from blackTheme/whiteTheme.  This will simplify a lot of your issues and perhaps automatically clear up the scrollbar color issues.
Here's a fiddle to hopefully illustrate the idea. (for simplicity's sake, I only made this work with a 2-way toggle.)

A: You need to remove and append the link element.
HTML file

<title></title>
<link href="css.css" rel="stylesheet" type="text/css" id="extCSSFile"/>

blackTheme

whiteTheme

css.css file
ul{height:1000px;}

#bt, #wt{
    text-decoration:underline;
    color:blue;
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
  background-color:#aaa;
}

::-webkit-scrollbar-thumb {

    background-color:black;
}

css2.css
body{
    background-color:black;
    color:white;
}

ul{height:1000px;}

#bt, #wt{
    text-decoration:underline;
    color:blue;
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
  background-color:#333;
}

::-webkit-scrollbar-thumb {

    background-color:white;
}

A: I believe we have a winner here.
This is HTML file code only; css files can what you want them to be.
I wish there was a CSS only method to it. I also didn't find deliberate repaint command for this purpose. One which I did find made use of chrome extensions, weird. But anyway, repainting was easy, all you have to do is shake the painted DOM a bit and you are good to go.
Oh, I am using latest canary build and jQuery; so factor them out in your code. Let me know if there is something amiss.
<link href="" rel="stylesheet" type="text/css" id="extCSSFile"/>


text:
Q: Irregular crash when creating NSManagedObject out of NSSet I have an irregular crash (1 in 5 times on devices, 4 in 5 times on Simulator). I have set an exception breakpoint and it occurs on the following line without any console information:
if let carColorSet = car.carToDisplay?.allObjects as? [Display] {

Note: car.carToDisplay is an NSSet
Before I set the exception breakpoint, I would get the following info in the console when it crashed:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableSet unionSet:]: set argument is not an NSSet'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102e79b0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001023d6141 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000102e00051 -[NSMutableSet unionSet:] + 1041
    3   CoreData                            0x0000000101b10df8 -[_NSFaultingMutableSet willReadWithContents:] + 936
    4   CoreData                            0x0000000101af131b -[_NSFaultingMutableSet allObjects] + 27
    5   Keyboard                            0x00000001018f838e

Any idea here? It seems like the crash occurs when I try to turn that carToDisplay?.allObjects into an array of Display objects.
This is a keyboard extension app btw.
Thank you for any input!

A: Problem (probably):
if let carColorSet = car.carToDisplay?.allObjects as? [Display]

carToDisplay is a NSet
However the function allObjects returns an array
I think you are trying to do a unionSet with an array.
Update the Question:
Please update your question, the qestion doesn't state the correct line of error.
The question needs to do the following

*

*state where the unionSet is invoked.

*what the argument type of unionSet is.


text:
Q: Failure to extract correct contents using re.findall() with python I am using Python 2 and I have a string
c = """
if ( is.data.frame(by) && ncol(by)>1 ) { by_by = sapply( by, paste.me, collapse, split) }
  ldat = sapply(xdat, by_by )
  out = data.table::rbindlist( lapply(ldat, FUN, ...) )
  return(out)
"""

I'd like to extract the second argument within either sapply() or lapply() and hence expect to get ['paste.me','by_by','FUN']. Unfortunately, I get ['split', 'by_by', '...'] using the following code.
re.findall(r"\b[sl]apply\(.+,\s*([\w._]+?)[,\s)]", c)

I already used the non-greedy qualifier ?. Why it is still going for the longest pattern without stopping at the second ,.

A: The trouble is that the .+ is slurping up the first comma, you should change it to .+?, or better yet, [^,]+


text:
Q: Duplicates in feature matrix I have several points which appear duplicates in the feature matrix (same values for the features). These points may have different values of the target variable. What is the appropriate way to handle this case during train test split? Should I just ignore the problem and go on with random split or remove duplicated points ?

A: It depends on what does a duplicate mean in your data.
If your features contain identification variables (for example, transaction number, student ID, etc), then duplicates are just copies of a same sample. In this case, if their target values ($y$) are the same, you should remove the duplicates. If they have different $y$'s, then this sample is problematic, and you should probably consider removing them altogether.
If your features does not contain identification variables, then it is totally possible that samples with the same feature values are different samples, and therefore possible to take different $y$'s. In this case, you don't need to do anything special.


text:
Q: PHP restructure array of data I have an array of data as follow:
array
  0 =>
    array (size=3)
      'name' => string 'credit_card'
      'revenue' => string '150'
      'date' => string 'Apr 2020'
  1 =>
    array (size=3)
      'name' => string 'cash'
      'revenue' => string '180'
      'date' => string 'Apr 2020'
  2 =>
    array (size=3)
      'name' => string 'cash'
      'revenue' => string '80'
      'date' => string 'May 2020'
  3 =>
    array (size=3)
      'name' => string 'credit_card'
      'revenue' => string '60'
      'date' => string 'May 2020'
  4 =>
    array (size=3)
      'name' => string 'cash'
      'revenue' => string '160'
      'date' => string 'Jun 2020'
  5 =>
    array (size=3)
      'name' => string 'credit_card'
      'revenue' => string '300'
      'date' => string 'Jul 2020'

I would like to restructure this array into the following one (to be used in a multiple Line Chart js):
array
  0 =>
    array (size=3)
      'cash' => string '180'
      'credit_card' => string '150'
      'date' => string 'Apr 2020'
  1 =>
    array (size=3)
      'credit_card' => string '60'
      'cash' => string '80'
      'date' => string 'May 2020'
  2 =>
    array (size=3)
      'credit_card' => string '0'
      'cash' => string '160'
      'date' => string 'Jun 2020'
  3 =>
    array (size=3)
      'cash' => string '0'
      'credit_card' => string '300'
      'date' => string 'Jul 2020'

In my case, since multiple line chartjs requires 2 arrays of number for credit_card and cash as inputs, javascript's map() method can easily do the trick with the above restructured data.
Could anyone kindly share any idea on how to restructure the array? Thx!

A: Try code below:
<?php
$data = array (
  0 => array (
      'name' => 'credit_card',
      'revenue' => '150',
      'date' => 'Apr 2020'
  ),
  1 => array (
      'name' => 'cash',
      'revenue' => '180',
      'date' => 'Apr 2020'
  ),
  2 => array (
      'name' => 'cash',
      'revenue' => '80',
      'date' => 'May 2020'
  ),
  3 => array (
      'name' => 'credit_card',
      'revenue' => '60',
      'date' => 'May 2020'
  ),
  4 => array (
      'name' => 'cash',
      'revenue' => '160',
      'date' => 'Jun 2020'
  ),
  5 => array (
      'name' => 'credit_card',
      'revenue' => '300',
      'date' => 'Jul 2020'
  )
);

$result = array_reduce(
    $data,
    function($res, $d) {
        if (!isset($res[$d['date']])) $res[$d['date']] = [
            'date' => $d['date'],
            'cash' => 0,
            'credit_card' => 0
        ];
        $res[$d['date']][$d['name']] = $d['revenue'];
        return $res;
    },
    []
);

var_export(array_values($result));

share PHP code


text:
Q: Issues with Copy-item script I have a script that needs to copy a list of files to ceraitn directories and locations on target servers.
I was able to understand that I need to creat an csv file as follows:

I need to understand from you how to make the files from source location to their adjacent file in target location. Any ideas?
My code looks like this:
 # customize log file
$date = (Get-Date -Format d).ToString() | foreach {$_ -replace "/", "_"}
$time = (Get-Date)

$scriptDir = "D:\Scripts\ServerBuildToolkitT1\SingleFileUpfate\"
$logDir = "D:\Scripts\ServerBuildToolkitT1\Logs\SingleFileUpfate\"

$logFileName = "SingleFileUpfate $date.log"

$sources = @()
$destinsyions = @()

function CSV {
    Import-Csv D:\Scripts_PS\SD.csv | ForEach-Object {
        $sources += $_."Source Location"
        $destinations += $_."Destination Location"
    }
}

# this file contains the list of destination server that you want copy
# file/folder to
$computers = Get-Content "D:\Scripts_PS\ServerList.txt"

function main
{
    foreach ($computer in $computers) {
        foreach ($destination in $destinations) {

        Write-Output "$([DateTime]::Now) Copying files update to $computer now" |
            Out-File -FilePath "$logDir\$logFileName" -Append
        Copy-Item $sources -Destination "\\$computer\$destination" -Force -Recurse -Verbose:$false
    }
}
}

csv
main

Write-Output "$([DateTime]::Now) the operation SingleFileUpdate completed successefully" |
    Out-File -FilePath "$logDir\$logFileName" -Append

i have updtaed the Script (as seen above) and now i am getting the following ERROR
"WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers."


text:
Q: GCP and AWS pricing - Are these important to know? I'm a newbie on cloud. I've been reading through AWS and GCP's billing/pricing documentation and I find the pricing on transfer, retrieval between and within regions, the requests....etc  extremely confusing for me to understand and remember.
Does knowing and remembering the pricing make a significant difference in cloud deployment? What is the best way to go about understanding and remembering the prices?

A: Cloud pricing is an ever changing operation so trying to remember the exact pricing of usage is not important as even if you can remember it, it might not be accurate. Cloud providers make announcements daily so these figures can always change.Instead trying to remember a banding for pricing i.e. low, medium, high as this is more likely to be the kind of knowledge you would draw upon in an initial plan.
Pricing can be be very confusing so you're not alone in this, you will never remember all of the pricing concepts for every service however having an understanding roughly of traffic to the internet, traffic within regions and traffic with availability zones generally will apply the same way across services (at least in AWS).
If you're trying to price a service in AWS there are specific pricing pages for each service with examples of all of the calculations. There is also a pricing estimator tool. If you're ever unsure overestimate rather than underestimate. Google Cloud also has a pricing calculator.


text:
Q: Fluid in spatially enclosed universe and some additional assumptions? Background
In general relativity I was wondering about the following Universe: Imagine a spatially closed universe containing only a perfect fluid:
$$x'_i =x_i + L_i $$
where $i =1,2,3$ one of the spatial components. Now, the perfect fluid in thermal equilibrium has the stress energy tensor:
$$ T^{\mu \nu} = (\rho + p)u^\mu u^\nu + p g^{\mu \nu} $$
Now assuming the pressure is a function of the $3$ volume and temperature $\theta$ of this universe:
$$ p \equiv p(\int \sqrt{|\det g_{ij}| }  dx_1 \wedge dx_2 \wedge dx_3, \theta)  $$
Questions
Is it a reasonable assumption to assume the pressure of the universe is a function it's volume? (It seemed intuitive to me but I wasn't sure how to justify it).
What is the corresponding Lagrangian of our stress energy tensor of a fluid which whose pressure depends on the volume of the universe?
$${\displaystyle T_{\mu \nu }=-2{\frac {\delta {\mathcal {L}}_{\mathrm {M} }}{\delta g^{\mu \nu }}}+g_{\mu \nu }{\mathcal {L}}_{\mathrm {M} }.}$$
(I can't seem to solve the maths)
Also does the line element change by assuming this dependency of pressure on the volume of the universe? If so, what is the new line element?


text:
Q: To determine whether stored procedure has cached plan or not I am testing on one stored procedure, to see whether SQL Server can make a "cache plan" for it.
In this stored procedure, it contains "dynamic sql" syntax(using "EXEC"), and supposes that sql server won't store a cache plan.
I used ADO.NET to call this stored procedure, and found the result in sql server.
The following pic shows the result from what I search in "sys.dm_exec_cached_plans" table after executing the stored procedure.

Does that mean this stored procedure is being cached for any similar search?
why there is no "query_plan" value in the result?
The sql server is SQL 2014 Enterprise Edition.
Thank you.

A: If you want your dynamic sql to reuse the cached execution plans use sp_executesql , If you read the MSDN documentation for sp_executesql it clearly states that sp_executesql can reuse the execution plan and Exec/Execute doesn't.
sp_executesql also allows you to parameterise your queries and protect you against sql-injection attacks.
From MSDN

To execute a string, we recommend that you use the sp_executesql
  stored procedure instead of the EXECUTE statement. Because this stored
  procedure supports parameter substitution, sp_executesql is more
  versatile than EXECUTE; and because sp_executesql generates execution
  plans that are more likely to be reused by SQL Server, sp_executesql
  is more efficient than EXECUTE.


text:
Q: pivoting and grouping columns at the same time This is a data transformation question involving both pivoting and grouping the data. I looked at a bunch of SE posts on this topic and am almost there, but not quite. So any help is appreciated.
I have data that looks like this.

So you can see the classic database format where there is a well with some WELL ID number, and then there are different CHEMICALS measurements taken on different dates. So a simple pivot would just create new columns with each date as its own column. HOWEVER, the observations are captured at different dates, so I would end up with like 100 columns. Instead I want to create those pivoted columns but then average the values for a year.
GOAL:
So I would like the result to look something as below. Each well should have a separate columns for each Chemical-Year combination, and the remaining columns like latitude and longitude should remain in the final data.
Well Id    TCPR123_2019    TCPC123_2018    TBR123_2019  Latitude  Longitude   ...
0103041-001    0.0         0.25            0.0        37.72...  -122.157...
0105003-001    0.0         0.5             0.3        37.66...  -121.84...

WHAT HAVE I DONE SO FAR:
So, I did a number of transformations and using the code:
df.groupby(['WELL ID','CHEMICAL',
    pd.Grouper(freq='Y', key='DATE', closed='left')])['RESULTS'].mean()

The results is this.
WELL ID      CHEMICAL  DATE      RESULTS
0103041-001  AS          2011-12-31      4.300000
                         2015-12-31      2.300000
                         2019-12-31      0.000000
0105003-001  AS          2011-12-31      0.000000
                         2014-12-31      0.000000

I just need to get this pivoted and get the remaining columns to show up. I had to use ['RESULTS'].mean() because otherwise it was averaging all of the columns. I tried to use df.unstack() but that did not include the other remaining columns. But I am not sure how to combine the pandas.DataFrame.pivot() with the df.groupby() operation? I am right at the last step, so any help is appreciated.

A: Just need to adding the unstack
df['year']=df.DATE.dt.year
s=df.groupby(['WELL ID','CHEMICAL', 'year'])['RESULTS'].mean().unstack([1,2])
s.columns=s.columns.map('{0[0]}_{0[1]}'.format)


text:
Q: How can I fix a geoTiff with an incorrect CRS? Trying to load and plot a raster (it's a DEM) in R, but having problems.
Using R I read in a raster file:
library(raster)

dem <- raster("DEM_Victoria.tif")  # >70 MB
print(dem)

class       : RasterLayer
band        : 1  (of  3  bands)
dimensions  : 5444, 6007, 32702108  (nrow, ncol, ncell)
resolution  : 100, 100  (x, y)
extent      : 176615.6, 777315.6, 5650397, 6194797  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +no_defs
data source : DEM_Victoria.tif
names       : DEM_Victoria
values      : 0, 255  (min, max)

My confusion here is the extent vs the CRS. The extent shows coordinates from a UTM Zone 55S system, while the CRS reports it as longlat.
Similarly, gdalinfo reports:
Driver: GTiff/GeoTIFF
Files:  DEM_Victoria.tif
Size is 6007, 5444
Coordinate System is:
GEOGCS["GDA94",
    DATUM["unknown",
        SPHEROID["unretrievable - using WGS84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (176615.587999997427687,6194797.138000000268221)
Pixel Size = (100.000000000000000,-100.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  176615.588, 6194797.138) (Invalid angle,Invalid angle)
Lower Left  (  176615.588, 5650397.138) (Invalid angle,Invalid angle)
Upper Right (  777315.588, 6194797.138) (Invalid angle,Invalid angle)
Lower Right (  777315.588, 5650397.138) (Invalid angle,Invalid angle)
Center      (  476965.588, 5922597.138) (Invalid angle,Invalid angle)
Band 1 Block=6007x1 Type=Byte, ColorInterp=Red
Band 2 Block=6007x1 Type=Byte, ColorInterp=Green
Band 3 Block=6007x1 Type=Byte, ColorInterp=Blue

Is this real? A problem? (well it is to me, but perhaps because I don't understand something) Fixable?
I tried 'Assign projection' in QGIS, which uses this command:
gdalwarp -t_srs EPSG:28355 -srcnodata -32768  DEM_Victoria.tif DEM_Victoria.tif.tmp

but it failed with:

ERROR 1: Too many points (12100 out of 12100) failed to transform,
  unable to compute output bounds.

A: If I understand this correctly, you're not translating the coordinates, you need to assign the correct CRS. gdal_translate can do this:
gdal_translate -a_srs EPSG:28355 DEM_Victoria.tif DEM_Victoria.tif.tmp

A: If you want a solution inside R, you can do:
library(raster)

dem <- raster("DEM_Victoria.tif")  # >70 MB
print(dem)
projection(dem) <- "+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
print(dem)

Check if the proj4 string is correct, that one its for EPSG:28355 http://spatialreference.org/ref/epsg/28355/


text:
Q: Issue when combining WHERE statements using AND in SQL I'm experiencing an odd error trying to combine multiple statements in my WHERE clause in SQL.
For example, this statement runs fine and does exactly what i would expect:
select
abr.[Email Address] as [SubscriberKey],
abr.[date_triggered],
abr.[ProductRatingRef1],
abr.[NumberOfReviewsRef1],
abr.[ProductNameRef1],
abr.[ProductCategoryRef1],
abr.[ProductTypeRef1],
abr.[GBP_RegularPriceRef1],
abr.[SkuIDRef1],
abr.[ProductCodeRef1],
abr.[ProductLinkRef1],
abr.[ImageLinkRef1]

from [Abandon Browse Log] abr

where (abr.[Email Address] not in (
  select bkt.CustomerID
  from [Abandoned Basket Source] bkt
))

Similarly, this statement runs how i would expect, when i run it on the data extension populated by the above query:
select * from [Abandon Browse Campaign v2]

where convert(date, ([date_triggered])) = convert(date, (getdate() -1))

Even running this query works fine:
select
abr.[Email Address] as [SubscriberKey],
abr.[date_triggered],
abr.[ProductRatingRef1],
abr.[NumberOfReviewsRef1],
abr.[ProductNameRef1],
abr.[ProductCategoryRef1],
abr.[ProductTypeRef1],
abr.[GBP_RegularPriceRef1],
abr.[SkuIDRef1],
abr.[ProductCodeRef1],
abr.[ProductLinkRef1],
abr.[ImageLinkRef1]

from [Abandon Browse Log] abr

where
(convert(date, ([date_triggered])) = convert(date, (getdate() -1)))

However, to get around the issue of using 2 queries and 2 (3?) Data Extensions, I am trying to combine both in to one as below:
select
abr.[Email Address] as [SubscriberKey],
abr.[date_triggered],
abr.[ProductRatingRef1],
abr.[NumberOfReviewsRef1],
abr.[ProductNameRef1],
abr.[ProductCategoryRef1],
abr.[ProductTypeRef1],
abr.[GBP_RegularPriceRef1],
abr.[SkuIDRef1],
abr.[ProductCodeRef1],
abr.[ProductLinkRef1],
abr.[ImageLinkRef1]

from [Abandon Browse Log] abr

where (abr.[Email Address] not in (
  select bkt.CustomerID
  from [Abandoned Basket Source] bkt
))
and
(convert(date, ([date_triggered])) = convert(date, (getdate() -1)))

I would expect this query to work, as both of the above work when separate, but not when combined. The only error i get out of salesforce is :

The query syntax is invalid Error while parsing query. Please check
  the syntax

A: If [Email Address] is the common field between [Abandoned Basket Source] and [Abandon Browse Log] then you could do something like this:
select
  abr.[Email Address] as [SubscriberKey]
, abr.[date_triggered]
, abr.[ProductRatingRef1]
, abr.[NumberOfReviewsRef1]
, abr.[ProductNameRef1]
, abr.[ProductCategoryRef1]
, abr.[ProductTypeRef1]
, abr.[GBP_RegularPriceRef1]
, abr.[SkuIDRef1]
, abr.[ProductCodeRef1]
, abr.[ProductLinkRef1]
, abr.[ImageLinkRef1]
from [Abandon Browse Log] abr
where convert(date, abr.date_triggered) = convert(date, getdate() -1)
and abr.[Email Address] not in (
  select bkt.[Email Address]
  from [Abandoned Basket Source] bkt
)

or
select
  abr.[Email Address] as [SubscriberKey]
, abr.[date_triggered]
, abr.[ProductRatingRef1]
, abr.[NumberOfReviewsRef1]
, abr.[ProductNameRef1]
, abr.[ProductCategoryRef1]
, abr.[ProductTypeRef1]
, abr.[GBP_RegularPriceRef1]
, abr.[SkuIDRef1]
, abr.[ProductCodeRef1]
, abr.[ProductLinkRef1]
, abr.[ImageLinkRef1]
from [Abandon Browse Log] abr
left join [Abandoned Basket Source] bkt on bkt.[Email Address] = abr.[Email Address]
where convert(date, abr.date_triggered) = convert(date, getdate() -1)
and bkt.[Email Address] is null

A: Try to switch the position of the conditions in the WHERE clause. I just tested and it worked for me.
select
abr.[Email Address] as [SubscriberKey],
abr.[date_triggered],
abr.[ProductRatingRef1],
abr.[NumberOfReviewsRef1],
abr.[ProductNameRef1],
abr.[ProductCategoryRef1],
abr.[ProductTypeRef1],
abr.[GBP_RegularPriceRef1],
abr.[SkuIDRef1],
abr.[ProductCodeRef1],
abr.[ProductLinkRef1],
abr.[ImageLinkRef1]

from [Abandon Browse Log] abr

where (convert(date, ([date_triggered])) = convert(date, (getdate() -1)))

and

(abr.[Email Address] not in (
  select bkt.CustomerID
  from [Abandoned Basket Source] bkt
))


text:
Q: How many coefficients do you have to change to lower the rank of a matrix? Let $1\leq r \leq n$ be integers. I'd like to find the smallest integer $m$ such that every matrix $A \in M_n(\mathbb R)$ of rank $r$ can be transformed into a matrix $A'$ of rank $r-1$ by changing at most $m$ coefficients.
The question is rather arbitrary, but here are some examples and remarks, partly to apologise:

*

*If $n =r$, you can transform any invertible matrix $A$ into a non-invertible one by modifying a single coefficient (just pick one whose corresponding cofactor doesn't vanish, and set it to the value that cancels the determinant), so $m = 1$.

*The matrix $(1)_{i,j}$ is of rank $1$, and you obviously have to change all of its coefficients to lower the rank, so $m=n^2$ when $r = 1$.

*In general, if $\mathop{\mathrm{rk}} A = r$, you can swap some rows and columns so that the $(r-1) \times (r-1)$ northeast submatrix of $A$ is invertible. Then, it's quite easy to show that you can modify the coefficients in the southwest block so that the rank becomes $r-1$. This proves that in general, $m \leq (n+1-r)^2$.

These arguments make me believe (perhaps rather naïvely) that the answer is in fact $m= (n+1-r)^2$, but I haven't got any concrete proof strategy to show it (and the contemplation of small examples quickly gets somehow messy).
Can you find the true value of $m$?

A: Your conjecture is true over any infinite field. More generally, in the set $M_{ab}$ of $a\times b$ matrices, at most $(a-r+1)(b-r+1)$ entries must be changed to reduce the rank of a rank $r$ matrix.

For completeness I first prove the direction you mentioned. As noted, we can reorder the rows and columns of a rank $r$ matrix $A\in M_{ab}$ until it has the form
$$
  A=\begin{bmatrix}X&Y\\Z&W\end{bmatrix}
$$
where $X\in M_{r-1,r-1}$ is nonsingular. By changing the $(a-r+1)(b-r+1)$ entries in $W$, we can change $A$ to
$$
  \begin{bmatrix}X&Y\\Z&ZX^{-1}Y\end{bmatrix}
    =\begin{bmatrix}X\\Z\end{bmatrix}
      \begin{bmatrix}I&X^{-1}Y\end{bmatrix}
$$
which has rank $r-1$, as required.

For the converse I will use some algebraic geometry. "Open" and "closed" will refer to the Zariski topology. With $m=(a-r+1)(b-r+1)-1$, we must show there exists a rank $r$ matrix whose rank cannot be reduced by changing $m$ entries. Let $R_r\subseteq M_{ab}$ denote the set of matrices of rank at most $r$. Note that $R_r$ is closed. The entries of a matrix in $M_{ab}$ are indexed by the set $I=\{1,\ldots,a\}\times\{1,\ldots,b\}$. For $J\subseteq I$, consider the subspace of matrices whose $J$-entries are zero:
$$
  Z_J=\{A\in M_{ab}\mid A_{ij}=0\text{ for all }(i,j)\in J\}.
$$
Changing up to $m$ entries is equivalent to adding an element of $Z_J$ for some $J$ with $|J|=ab-m$. Thus we must prove $R_r$ is not contained in
$$
  \bigcup_{J\subseteq I\atop|J|=ab-m}R_{r-1}+Z_J.
$$
In fact I will show the Zariski closure of this set does not contain $R_r$. We assumed the base field $k$ is infinite, so it suffices to prove this over the algebraic closure of $k$. Therefore suppose $k$ is algebraically closed.
Recall that there is a notion of dimension for algebraic varieties, namely Krull dimension, which coincides with linear dimension for a vector space. Moreover a dominant morphism can only reduce dimension. We need a couple of facts about $R_r$: namely it is irreducible and has dimension $r(a+b-r)$. To see this, let $U\subseteq M_{ab}$ be the open set of matrices with a nonsingular top left $r\times r$ submatrix. There is an isomorphism $GL(r)\times M_{a-r,r}\times M_{r,b-r}\to U\cap R_r$ given by
$$
  (X,Y,Z)\mapsto
    \begin{bmatrix}X\\Y\end{bmatrix}
      \begin{bmatrix}I&Z\end{bmatrix}.
$$
Thus $U\cap R_r$ is irreducible and has dimension $r^2+(a-r)r+r(b-r)=r(a+b-r)$. The image of the multiplication map $\mu:M_{ar}\times M_{rb}\to M_{ab}$ is $R_r$. Clearly $U'=\mu^{-1}(U)$ is nonempty. Since $M_{ar}\times M_{rb}$ is irreducible, we have
$$
  R_r=\mu(M_{ar}\times M_{rb})=\mu(\overline{U'})=\overline{\mu(U')}\subseteq\overline{U\cap R_r}.
$$
Hence $R_r$ is irreducible with dimension $r(a+b-r)$.
For each $J\subseteq I$, consider the projection $\phi_J:M_{ab}\to M_{ab}/Z_J$. Note that the codomain is a vector space of dimension $|J|$; intuitively $\phi_J$ picks out the $J$-entries of a matrix. Let
$$
  D_r=\{J\subseteq I\mid\phi_J|_{R_r}\text{ is dominant}\}.
$$
Intuitively, $J\in D_r$ means that if someone specifies the $J$ entries of a matrix, you can almost always choose the remaining entries to make a rank $r$ matrix. If $J$ belongs to $D_r$ then so does any subset of $J$. Suppose $J\in D_r\setminus D_{r-1}$ and $R_r\subseteq\overline{R_{r-1}+Z_J}$. Then
$$
  \phi_J(R_r)\subseteq\phi_J(\overline{R_{r-1}+Z_J})=\overline{\phi_J(R_{r-1}+Z_J)}=\overline{\phi_J(R_{r-1})}\subsetneq M_{ab}/Z_J,
$$
contradicting $J\in D_r$. Hence $J\in D_r\setminus D_{r-1}$ implies $\overline{R_{r-1}+Z_J}$ does not contain $R_r$.
Now suppose $|J|=ab-m$. First suppose $J\in D_r$. Recall that the dimension of $R_{r-1}$ is $(r-1)(a+b-r+1)=ab-m-1<|J|$. Thus $J\notin D_{r-1}$, so $R_r\not\subseteq\overline{R_{r-1}+Z_J}$.
On the other hand, suppose $J\notin D_r$. Pick a maximal subset $J'\subseteq J$ with $J'\in D_r$. Pick $j\in J\setminus J'$ and let $J''=J'\cup\{j\}$. Then $Z_{J'}=Z_{J''}+Z_{I\setminus\{j\}}$, so $\phi_{J'}$ factors as $\psi\phi_{J''}$ for some linear map $\psi$. Note that changing a single entry of a matrix cannot increase the rank by more than $1$, so
$$
  R_{r-1}+Z_{I\setminus\{j\}}\subseteq R_r.
$$
Hence
$$
  \psi^{-1}(\phi_{J'}(R_{r-1}))=\phi_{J''}(R_{r-1}+Z_{I\setminus\{j\}})\subseteq\phi_{J''}(R_r).
$$
Now $J''\notin D_r$ by choice of $J'$, so $\phi_{J''}(R_r)$ is not dense. Hence $\phi_{J'}(R_{r-1})$ is not dense, so $J'\in D_r\setminus D_{r-1}$. Hence $R_r\not\subseteq\overline{R_{r-1}+Z_{J'}}$. But $Z_J\subseteq Z_{J'}$, so again $R_r\not\subseteq\overline{R_{r-1}+Z_J}$.
We have shown $R_r\not\subseteq\overline{R_{r-1}+Z_J}$ whenever $|J|=ab-m$. Since $R_r$ is irreducible, it follows that
$$
  R_r\not\subseteq\bigcup_{J\subseteq I\atop|J|=ab-m}\overline{R_{r-1}+Z_J},
$$
as required.

Finally note that the conjecture is false for a finite field. Indeed a rank $2$ matrix over a field of size $q$ can only have $q+1$ distinct rows up to scalar multiple, so the rank can be reduced by changing at most $\frac{q}{q+1}n^2$ entries. This is less than $(n-1)^2$ for $n$ sufficiently large.


text:
Q: Problem in the proof of the Second Sylow Theorem I'm missing a detail in the following proof of the Second Sylow Theorem:

Let G be a finite group and p a divisor of $|G|$. Let $|G| = p^km$
  with $p \nmid m$. Then if $H \le G$ is a p-subgroup then there exists
  $P \le G$ p-subgroup such that $H \le P$.

The proof begins with a lemma which goes as follows (I put it here for completeness):

Let $P$ be a p-subgroup of Sylow of $G$ and $H \le G$ a p-subgroup
  such that $H \le N_G(P)$ then $H \le P$.

The proof of theorem goes as follows:
Let $S$ be the set of p-subgroups of Sylow and let's take the conjugation action of $G$ on $S$. Let $P_1 \in S$  be a p-subgroup and $T = O(P_1)$ be the orbit of such p-subgroup then I understand the following facts:

*

*$P_1 \trianglelefteq N_G(P_1) \le G$ and therefore $[G:P_1] = [G:N_G(P_1)][N_G(P_1):P_1]$

but I don't understand why

*$[G:P_1] = m$

which should lead to the fact that $p \nmid |T| = [G:N_G(P_1)]$.
I'd say that it is really simple but I'm stuck, thanks for your answers.

A: Note that $P_1$ was chosen from the set of $p$-Sylow subgroups, so
$$[G:P_1]=\vert G\vert / \vert P_1\vert$$
And as $P_1$ is a $p$-Sylow, $\vert P_1\vert=p^k$, so that lets you what you want.
The point of $p\not\mid [G:N_G(P_1)]$ is because $P_1\leq N_G(P_1)$, so $\vert N_G(P_1)\vert= p^kr$ with $1\leq r\leq m$, so again:
$$[G:N_G(P_1)]=\vert G\vert / \vert N_G(P_1)\vert=m/r$$
That is prime to $p$.


text:
Q: How to make the Background behind Alert Box clickable? I have a application where i make all Divs clickable by using this code :
$("html").click(function(){
 alert("Click");
 return false;
});

This one work normally for all divs. Well, when Alert popup, the Background behind alert box cannot be clicked. How can i turn that to be clickable too?
PS: Right Click on the Background dont work too.

A: Thats not possible. You have to use a JS plugin doing the alert, so you can influence the behaviour (like the jquery ui modal widget, mentioned here). But with the browser alert this is not possible, as far as i know.

A: Not sure how to do exactly what you're asking (if it's possible). Maybe someone else can shed some light on that.
But a solution you could look into would be the dialog widget from jQuery UI. You can easily create pop-ups, modal or non-modal (meaning with the background faded out or not).
http://jqueryui.com/dialog/
They have some demos there, but it's as simple as created a div with some text and calling...
$("#the_div_id").dialog();

Other config parameters can be found from the API:
http://api.jqueryui.com/dialog/

A: By default its modal popup behaviour ,If you want to clickable
Assuming you are using Jquery Ui dialog
Try with the option modal
 $('#selector').dialog("option","modal",false);

http://api.jqueryui.com/dialog/#option-modal


text:
Q: What does $.support.placeholder mean in jQuery? I don't understand this condition: $.support.placeholder
Can anyone explain to me what this is for?
if ($.support.placeholder) {
  alert("Testing");
} else {
  return;
}

A: It's checking to see if the placeholder property on the $.support object is truthy¹ and, if so, it does the alert; if not, it does a return, exiting the function this code is in.
jQuery's support object (long deprecated, it shouldn't be used anymore) tells you what the current browser supports. From the link:

A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support.

(my emphasis)
In this case, the check is seeing if the browser supports the placeholder attribute on input elements. But see above, the check is unreliable. If jQuery no longer needs to know this information internally, the property may be removed, and that code would be tricked into thinking the browser didn't support placeholder (which nearly all do) because getting the value of a property that doesn't exist results in undefined, which is falsy.
In fact, the current version of jQuery as of this writing (v3.3.1) doesn't have placeholder:

console.log("typeof $.support.placeholder:", typeof $.support.placeholder); // "typeof $.support.placeholder: undefined"
var input = document.createElement("input");
input.type = "text";
var supportsPlaceholder = "placeholder" in input;
console.log("supportsPlaceholder: ", supportsPlaceholder); // "supportsPlaceholder: true" (in nearly all browsers)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

The code in the question would incorrectly report that your browser doesn't have placeholder support even when it does.

¹ a truthy value is a value that coerces to true when used as a boolean, such as in an if. A falsy value is one that coerces to false. The falsy values are null, undefined, 0, NaN, "", and of course, false; all other values are truthy.


text:
Q: Pause AnimationDrawable and resume from the same frame I am trying to animate a set of images using AnimationDrawable. The user should have the ability to pause/resume the animation on a click of a button. I am doing so, using setVisible(boolean visible, boolean restart). Not completely sure if I understand the documentation correctly, but every time pause is pressed, the animation starts from the beginning.
Is there any way to resume the animation from the same frame?
From AnimationDrawable API:

...If restart is false, the drawable will resume from the most recent frame

Just to be clear:
activityAnimation.setVisible(false, false); Should stop the animation.
activityAnimation.setVisible(true, false); Should resume the animation from the same frame (it doesn't).

Here is my code:
The animation start() is called in onWindowFocusChanged.
The animation and the buttons are created in onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_content);

    ImageView activityImage = (ImageView) findViewById(R.id.activity_image);
    activityImage.setBackgroundResource(R.drawable.anim);
    activityAnimation = (AnimationDrawable) activityImage.getBackground();

    ....
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ImageButton b = (ImageButton) v;
            if ((Integer)b.getTag() == R.drawable.pause) {
                b.setImageResource(R.drawable.play);
                b.setTag(R.drawable.play);
                activityAnimation.setVisible(false, false);
            } else {
                b.setImageResource(R.drawable.pause);
                b.setTag(R.drawable.pause);
                activityAnimation.setVisible(true, false);
            }
        }
    });...
}

This is the content of the XML file
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">

    <item android:drawable="@drawable/one" android:duration="1000" />
    <item android:drawable="@drawable/two" android:duration="1000" />
    <item android:drawable="@drawable/three" android:duration="1000" />
    <item android:drawable="@drawable/four" android:duration="1000" />

</animation-list>

I have noticed several of these old posts, but non had the answer.
How to reset AnimationDrawable (The other side of this issue)
How do I pause frame animation using AnimationDrawable? [Closed]

A: To pause and resume AnimationDrawable, simply customize it and handle with only one variable.
class CustomAnimationDrawable1() : AnimationDrawable() {

private var finished = false
private var animationFinishListener: AnimationFinishListener? = null
private var isPause = false
private var currentFrame = 0

fun setFinishListener(animationFinishListener: AnimationFinishListener?) {
    this.animationFinishListener = animationFinishListener
}

interface AnimationFinishListener {
    fun onAnimationFinished()
}

override fun selectDrawable(index: Int): Boolean {
    val ret = if (isPause) {
        super.selectDrawable(currentFrame)
    } else {
        super.selectDrawable(index)
    }

    if (!isPause) {
        currentFrame = index
        if (index == numberOfFrames - 1) {
            if (!finished && ret && !isOneShot) {
                finished = true
                if (animationFinishListener != null) animationFinishListener!!.onAnimationFinished()
            }
        }
    }
    return ret
}

fun pause() {
    isPause = true
}

fun resume() {
    isPause = false
}

}

A: Since I needed a timer on the screen as well, the answer in my case was simply to create a runnable replace the ImageView background every second.
Here is the general idea:

*

*Create the runnable, ImageView and few helpers:
ImageView exImage = null;

long startTime = 0;
long pauseTime = 0;
long pauseStartTime = 0;

List<Integer> animList = new ArrayList<>();
int animIt = 0;

Handler timerHandler = new Handler();
Runnable timerRunnable = new Runnable() {
    @Override
    public void run() {

        long millis = System.currentTimeMillis() - startTime - pauseTime;
        double dSecs = (double) (millis / 100);
        int pace = 10;

        if (dSecs % pace == 0.0 && !animList.isEmpty()) {
            animIt = (animIt == animList.size() - 1) ? 0 : animIt + 1;
            exImage.setBackgroundResource(animList.get(animIt));
        }
        timerHandler.postDelayed(this, 100);
    }
};

*In OnCreate bind the pause and play buttons, fire the timer and set the first ImageView
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_exercise);

    // Set the image view
    exImage = (ImageView) findViewById(R.id.image_zero);
    exImage.setBackgroundResource(R.drawable.fe_0);

    // Start the timer
    timerHandler.postDelayed(timerRunnable, 0);

    // Bind the buttons
    ImageButton pp = (ImageButton) findViewById(R.id.button_play_pause_toggle);
    pp.setImageResource(R.drawable.pause);
    pp.setTag(R.drawable.pause);

    pp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ImageButton pp = (ImageButton) v;
            //Pause
            if ((Integer) pp.getTag() == R.drawable.pause) {
                pauseStartTime = System.currentTimeMillis();
                timerHandler.removeCallbacks(timerRunnable);
            } else { // Resume
                pauseTime += System.currentTimeMillis() - pauseStartTime;
                timerHandler.postDelayed(timerRunnable, 0);
            }
        }
    });
}


text:
Q: Lua - match HTTP GET by string.match I want to parse informations in GET by lua's string.match.
My information in GET is: "SSID=My+ssid&PASS=mypass123&IP=192.168.1.100".
I use this code:
local _GET = {}
vars="SSID=My+ssid&PASS=mypass123&IP=192.168.1.100"
print(vars)
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
        print(k)
        print(v)
            end

And my result is:
SSID
My
PASS
mypass123
IP
192

How can I get full information? For exmaple not only first part of digits in IP address?

A: Try this:
vars="SSID=My+ssid&PASS=mypass123&IP=192.168.1.100"
vars=vars.."&"
for k, v in string.gmatch(vars, "(%w+)=(.-)&") do
        print(k)
        print(v)
end


text:
Q: Download file with low priority using Python and urllib2 I'm writing simple tool to keep every image that I've copied (URL of image)
I'm using pythoncom and pyhook to catch keyboard "Copy" combination.
The problem here is that when Image starts downloading it causes major slowdown, so I have to wait for 0.5-2 seconds for script to finish. Here's the code:
response = urllib2.urlopen (URL)
image_file = response.read()
file = open (path + filename, 'wb')
file.write (image_file)
file.close()

So, the question is - is there a way to get rid of this delay?

A: The question in its current state (unedited) is not really that clear. But I am under the impression your problem is the fact you have to download the image from somewhere before processing it. To get around that, I would use either of the two:

*

*Pre-emptive downloading. You start download the image(s) that is most likely the user will wish to download during program's idle time, so that when/if the user eventually choose to download it, you simply "pick it" from the pre-downloaded cache.

*You get an asynchronous process to download it for you. This case is more tricky to manage in terms of program logic. You should look at the multiprocessing module documentation. This module is part of the standard lib since version 2.6.


text:
Q: Relationship Between Moment-Generating Functions and Laplace Transforms According to Wikipedia, the moment-generating function $M_X (t)$ of a probability distribution $f_X (x)$ is given by $M_X (t) = \int_{-\infty}^\infty e^{tx}f_X (x)\ dx$.

*

*Is $t$ time?  If so, why does it appear in the output of this transform rather than the input?  In Differential Equations, the Laplace Transform transforms the time domain into the frequency domain.  In this scenario, is the $x$ domain "one hop in the direction opposite the frequency domain" relative to the time domain, so that the Laplace Transform transforms the $x$ domain to the time domain, and a composition of two Laplace Transforms would transform the $x$ domain to the frequency domain?

*Why is $t$ negated relative to the Laplace Transform?  My understanding from the derivation of a Laplace Transform from a power series is that making the exponent negative is a substitution choice.  Doesn't choosing to make the exponent positive make the integral much less likely to converge?

A: In an MGF, $t$ isn't time or any other physical quantity, but a "dummy variable" whose dimension is inverse to that of $X$ (so if $X$ is dimensionless $t$ is too, but we certainly wouldn't pair a spatial length with time). The symbol $t$ is arbitrary; $k$ is often used instead, as is $s$.
Similarly, a Laplace transform doesn't require a physical interpretation such as the time/frequency one you gave, but note again this relates two physical quantities whose product is dimensionless. (This requirement exists because we exponentiate such a product; $e^z=1+z+z^2/2+\cdots$ only makes sense for dimensionless $z$.) Any physical examples, such as time and frequency or length and wavenumber, results from some physical context in which a Laplace transform naturally arises. Actually, this is even more commonplace with Fourier transforms.
The Laplace transform of a function $f(x)$ is defined as $\int_0^\infty e^{-sx}f(x)dx$, thus a function of $s$ (and if you prefer, change $x$ and $s$ to whichever letters you like). Note the integral is only over $x\ge0$, so the $e^{-sx}$ factor helps convergence if $\Re s$ is large enough. For example, the choice $f(x)=e^{ax}$ leads to a convergence Laplace transform provided $\Re s>\Re a$. The resemblance to MGFs is superficial.


text:
Q: Infinite scrolling issue I found example of infinite scrolling and tried to perform it the same, but after fixing all mistakes I've found it still doesn't work.
Here's the directive:
module.exports = /*@ngInject*/
function scrollDirective($rootScope) {
    return {
        link: function (scope, elm, attr) {
            var raw = elm[0];

            elm.bind('expressly', function() {
            if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
                scope.$apply(attr.scrollDirective);
            }
        });
        }
    };
};

Then how it goes on in controller (I have JSON-data in promise)
module.exports = /*@ngInject*/
function cardController($scope, dataFactory) {
  var promise = dataFactory.get();
  promise.then(function(data) {
    $scope.data = data;
    $scope.items = [];
    //$scope.items.push($scope.data[0]);
    var counter = 0;

    $scope.loadMore = function() {
      for (var i = counter; i < counter+9; i++) {
          $scope.items.push($scope.data[i]);
      }
      counter += 9;
    };

    $scope.loadMore();
    }, function(reason) {
      console.log('Failed: ' + reason);
    });
};

And finally html:

    <md-card>

      <md-card-content>
        <md-icon >photo_album</md-icon>

{{ item.title }}

      </md-card-content>
    </md-card>

A: Actually it turned up pretty simple. In directive instead of elm I used $document and pass parameter i to the function. After exploring the guts of i, I found all parameters I needed through i.target.activeElement. Here is the solution:
function scrollDirective($rootScope,$document) {
    return {
        link: function (scope, elm, attr) {
            var raw = elm[0];

            $document.bind('scroll', function (i) {
                if (i.target.activeElement.scrollTop+i.target.activeElement.offsetHeight +5>= i.target.activeElement.scrollHeight){
                    scope.$apply(attr.scrollDirective);
                }
            });
        }
    };
};


text:
Q: Samsung button click effect While I was creating Calculator app same as installed in my S6 edge, I stuck when
design buttons. I want to make buttons look exactly same as calc app which comes in all samsung phones.I tried state button pressed but they have design like fading colors in and out for seconds which I ain't sure how to create.

A: by simple way create new xml file called clickable_button.xml
inside it write this code
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_clicked" android:state_pressed="true"/>
    <item android:drawable="@drawable/button"/>
</selector>

don't for get to make two drawable files one seem clicked and another not clicked
finally set your button background with clickable_button ;)


text:
Q: How to dynamically populate pick list right side values I am using rich:popuppanel component and having issues with populating values in picklist.
My requirement is as below.

*

*Populate extended data table

*Select a row using check box - User ID in that row will be passed to backing bean

*Click assign button

*Popup panel should open with a picklist containing all users and assigned users
The issue is, getAllUsers() call returns all users and left side of picklist is populated properly. But getAssignedUsers() is not called at all. So right side of pick list always empty.
XHTML code is as below.
<h:form id="audit">
...
   <h:commandButton id="Assign" value="Assign"
      immediate="true" action="#{userBean.getSelectedUsers}">
        <f:ajax execute="@this" render="popupScript" />
   </h:commandButton>
   <h:panelGroup id="popupScript">
            <h:outputScript rendered="#{userBean.assignClicked}">
                #{rich:component('assignUser')}.show();
            </h:outputScript>
   </h:panelGroup>
...
</h:form>
<rich:popupPanel id="assignUser" autosized="true" resizeable="false">
           <f:facet name="header">
                <h:outputText value="#{msg.assignPopupHeader}">
                </h:outputText>
           </f:facet>
           <h:form name="assign" id="assign">
                 <h:panelGrid cellspacing="5" id="popupGrid">
                      <a4j:outputPanel id="a4jPanel">
                             <rich:pickList value="#{userBean.assignedUsers}"
                                     showButtonsLabel="false" sourceCaption="Available Users"
                                     align="center" targetCaption="Assigned Users" listWidth="165px"
                                     listHeight="100px" orderable="true" addText=">" removeText="<">
                                  <f:selectItems value="#{userBean.allUsers}" />
                             </rich:pickList>
                      </a4j:outputPanel>
                      <center>
                             <h:panelGrid columns="2" cellspacing="3" cellpadding="4">
                                     <a4j:commandButton id="assign" value="#{msg.userAssign}"
                                                 action="#{userBean.assignUser}"/>
                                     <h:commandButton value="#{msg.userCancel}"
                                                 onclick="#{rich:component('assignUser')}.hide();return false">
                                     </h:commandButton>
                            </h:panelGrid>
                      </center>
              </h:form>
</rich:popupPanel>

My understanding is the issue is due to bean scope. My bean is view scoped, so the data in both left and right side panels are pre-populated when bean is initialized.
@PostConstruct
public void init() {

    setAllUsers(userService.getAllUsers());
    setAssignedUsers(userService.getAllAssignedUsers(userBean.getSelectedIdforAssign()));
}

I tried calling setAssignedUsers() with hardcoded id in init() itself. It works fine.
What I need is a way to dynamically pass the ID and call getAssignedUsers().
Please suggest how to perform this and how to reRender the picklist when popup is opened.
Thanks!

A: The problem seems to be the selection of the users.
Without the code of the table and the checkboxes I cannot say whether you do it right or not. ViewScope should be sufficient.
<f:ajax execute="@this" render="popupScript" />

This might be wrong though. Probably your checkboxes never get evaluated. Try to change @this to @form.


text:
Q: Is there a verb to express moving files within a cloud, similar to "to upload" and "to download" Writelatex is an awesome cloud solution to write LaTeX documents online. Through one of their dialogs one can "upload" files to the cloud. However, when looking at the options offered, all but one - i.e. "My Computer" - are actually not an "upload", but more a transfer of files between clouds.

A related answer, states

Downloading/uploading is generally used when you connect the computer to a distant source, for example a server on internet. If you use it for small devices, it's not as obvious which direction is up or down.

In the case of writelatex there  isn't a direction up or down, either, except of course the first option where files are effectively uploaded.
Is there a synonym for both "upload" and "download" that would reflect what actually happens, that is files are transferred from one cloud to the other?

A: If the file disappears from the first location and reappears in the new location, the word would be migrate.
If it's duplicated instead of moving, the word would be replicate.

A: One can use the terms migrate and replicate (as mentioned in a previous answer) but note that the simpler terms  move ("...to change place...") and  copy ("To produce an object identical to a given object") will serve quite as well or better.
However, for cloud-to-cloud moves and copies, one might consider the term waft [pronounced /wɒft/ (wŏft)] apropos:

To (cause to) float easily or gently through the air.
  To be moved, or to pass, on a buoyant medium; to float.

Link sources: Wiktionary


text:
Q: Sharepoint 2007 - Custom List provisioning - are List Forms needed at deployment? I have a feature which is provisioning 1 document library and 2 custom lists. A folder is included for each list containing the schema.xml for that list. Each folder also contains the associated forms (AllItems, DispForm, EditForm, NewForm, etc.). Everything deploys/works correctly but it seems a little redundant having the same forms copied into each list's folder. There is nothing special about these lists - the are basically a default doc library/generic list with additional fields provided through new content types (derived from Item/Document).
As far as I can tell these forms are pretty generic. Are there pre-installed forms that I can reference from my list  so I don't have to deploy all of these extra files? Is there any reason I would not want to do this?
Update - moving xml in comment to original question for readability:
<Forms>
    <Form Type="DisplayForm" Url="Forms/DispForm.aspx" WebPartZoneID="Main"/>
    <Form Type="EditForm" Url="Forms/EditForm.aspx" WebPartZoneID="Main"/>
    <Form Type="NewForm" Url="Forms/Upload.aspx" WebPartZoneID="Main"/>
    <Form Type="NewFormDialog" Path="EditDlg.htm">
    ....

A: There are virtual defaults that are used if you don't specify a concrete page.
All lists use these template defaults unless you use a tool like SharePoint designer to customize the page. Then the template is used to create the concrete page and you can customize the look for a particular list without affecting others.
For my custom definitions, I use
<List>
   ...
   <MetaData>
      ...
      <Forms>
         <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
         <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
         <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      </Forms>
   </MetaData>
</List>

If you have no reason to customize the out of the box version of these forms, you can use the virtual form and not deploy copies.


text:
Q: add a element to json array with Key/value using angular js I have a json array object like below
$scope.Json = [{
  Id:"5464",
  Class:"9",
  Rank:"4"
}]
I want to add a item "Name":"Vicky" to the Json. So that my result should be as below.
$scope.Json = [{
  Id:"5464",
  Class:"9",
  Rank:"4",
  Name:"Vicky"
}]
I am new to angular, can anyone help on this?

A: Use Array map() method.
DEMO

var json = [{ Id:"5464", Class:"9", Rank:"4" }];

json.map(function(item) {
  item.Name = 'Vicky';
});

console.log(json);

A: First of all, the object $scope.Json is not a JSON but a string. To get a JSON, you need to parse the string like the following:
$scope.Json = JSON.parse(<string>) ;

Second, your input is a peculiar JSON as it is an array with one element (in its turn having 3 elements. I guess you wanted this:
$scope.Json = JSON.parse({ Id:"5464", Class:"9", Rank:"4" }) ;

Once you have this, you can add the element you want as:
$scope.Json.Name = "Vicky" ;


text:
Q: Infinite sum of normalized Hermite polynomials Is it known any closed-form function of the infinite sum of the normalized probabilist's Hermite polynomials, i.e.,
\begin{align}
\sum_{j=0}^\infty  \frac{He_j(t)}{\sqrt{j!}}
\end{align}
where $He_j(t)$ is the probabilist's Hermite polynomial of degree $j \ge 0$. This was previously asked in this thread but not solved yet. Numerically, it seems to be converged to some deterministic function, but still unclear whether it indeed converges. Any comment or suggestion would be greatly appreciated. Thanks!


text:
Q: Access to Table Function in Another HDI Container I have one HDI container (HDI1) that access an Table Function (TF_1) in another HDI container (HDI2), I create the synonym, It`s OK, working fine.
But when the TF_1 calls another Table Function (TF_2) in HDI2 I get "Insufficient Privilege" error. I have to create a synonym to TF_2.
Is It Correct? Why I don`t need to do this for another object Type (E.g. Calculation Views)
Thank you

A: I've reproduced this scenario without HDI, but with plain SQL schemas and users instead.
Creating and running TF_1 and TF_2 as the owner of HDI 2 is working fine.
Granting EXECUTE on TF_1 to the owner of HDI 1 works also fine. HDI 1 can successfully run TF_1 afterward, but not TF_2.
So far, so good.
With HDI the situation becomes more complex as your developer user is not the owner of HDI 1 schema.
Instead, upon activation/deployment of your code, the HDI infrastructure connects as the actual owner of HDI 1 to create the objects and then runs a series of GRANTs to other users, including your developer user to allow the execution of the function.
Now, in order to grant the execute privilege further, the GRANT OPTION* needs to be used in the grant-statement. That is a detail that is usually covered correctly by the HDI infrastructure.
In this case, however, it is clear, that the users that manage HDI 1 do not have the GRANT OPTION to further the privilege to other users.
I recommend reviewing the activation logs, what GRANTS have been declared for the cross-container access, and look out for "missing privilege" errors during activation.


text:
Q: Java file upload applet - Suggestions needed I want to build a simple file uploading applet in Java. It will be used to upload files to a regular linux web server. So if someone went to:
http://site.com/file-upload-applet

And uploaded a file there via the applet, it will be accessible at:
http://site.com/uploads/your-file.jpg

The user should be able to click 'Browse', and then look through the folders on his computer ,and be able to select as many files, or every file in a folder, if he wanted. Then, when he hits upload, he should be shown a progress bar while the files are uploaded.
Any thoughts about this, and how this could be accomplished in Java as an applet? I will just need some pointing in the right direction, such as which Libraries to use.

A: You'd need to have a signed applet, as unsigned applets do not have access to the filesystem.
I found an article about signed Applets.
As for the other components, you'll most likely need a JFileChooser, JProgressBar, and a JButton (that uses Apache HttpClient's PostMethod with a MultipartRequestEntity that wrape the JFileChooser's file in a FilePart).

A: I used the Apache Commons File Upload, and it worked like a charm. It took away most of the problems I was worried about, and was very easy to use.


text:
Q: 'The following arguments were not expected: environment.yml --file create' when making new Mamba environment I need to test the model described in the IceNet paper but I am having issues making the Mamba environment.
After installing Mamba as described here, if I run the command mamba env create --name esports --file environment.yml I get the error The following arguments were not expected: environment.yml --file create Run with --help for more information.
Is there a way I can fix that? Also, I am working with an A100 GPU. Does it still make sense to use Mamba (the code was originally developed to run on a laptop) or am I already fine using Conda as usual?

A: Mamba should have the same API a Conda so the command yo tried should be correct. The error you get is likely due to a typo.
Note that I was able to trigger this exact error using Micromamba which has a different API than Mamba. Micromamba only has the micromamba create command that handles both YAML and list environment files. In that case, the correct command is:
micromamba create --name esports --file environment.yml


text:
Q: Create new column in dataframe passing existing column to an SQL function I have a data frame which contains NAME as a column.
I have a DB statement which returns the FIRST_NAME when NAME is passed.
I am writing a python script something like below:
def fname(row):
 cursor.execute(select case when df['name'] = fname then fname else blank end as fname from dual;)
 return cursor.fetchone()[]

df[fname]=df.apply(fname)

It seems to throw "expects the first argument to be string or unicode"
How do I pass name value one by one to the function above and store it in a new column in the same dataframe?

A: You need to specify axis=1, by default the axis =0 which mean it reads the indexes.
df[name]=df.apply(fname, axis=1)

axis{0 or 'index', 1 or 'columns'}, default 0
Axis along which the function is applied:
0 or 'index': apply function to each column.
  1 or 'columns': apply function to each row.

For more details , refer the documentation

A: found the issue. since i am passing the dataframe as row in the function, i have to refer the dataframe as row inside this function
def fname(row):
 cursor.execute(select case when row['name'] = fname then fname else blank end as fname from dual;)
 return cursor.fetchone()[]
df[fname]=df.apply(fname)


text:
Q: mkmapview refresh mapview im using mkmapview to show route between current location and a coordinate.
 im using polyline to show the route. i have added annotation to start and destination. im using the following api to get the in between coordinates.
http://routes.cloudmade.com/8ee2a50541944fb9bcedded5165f09d9/api/0.3/51.22545,4.40730,[51.22,4.41,51.2,4.41],51.23,4.42/car.js
now if i change the coordinates the already existing route also is visible. how do i remove the existing route and add a  new route?
thanks in advance.

A: Unless I'm missing something in your question, if you already have the app calculating and displaying an MKPolyline then all you need to do is remove the old one and add the new one. Your code would look something like
// generating new data, do this however you like
MKPolyline *routeLine = [self generateNewRoutLine];
MyPinAnnotation *startPin = [self generateNewStartPin];
MyPinAnnotation *endPin = [self generateNewEndPin];

// removing old overlays and adding new
[myMapView removeOverlays:myMapView.overlays]; // removes all overlays
[myMapView removeAnnotations:myMapView.annotations]; // removes all pins
[myMapView addOverlay:routeLine];
[myMapView addAnnotations:[NSArray arrayWithObjects:startPin, endPin, nil]];


text:
Q: Inheritance Behaviour class A {

  public void print(A a) {
    System.out.println("A");
    a.add();
  }

  public void add() {
    System.out.println("At A.add()");
  }
}

class B extends A {

  public void print(B b) {
    System.out.println("B");
    b.add();
  }

  public void add() {
    System.out.println("At B.add()");
  }
}

public class MDemo {

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    A a = new B();
    a.print(a);
    ;
  }
}

Output
A
At B.add()

Please clarify output.
Reference From
Selecting overriding method java with multiple options


text:
Q: Mysql 5.5, how to avoid varchar field truncation error for executing session Mysql 5.5, how to avoid varchar field truncation error, for executing session.
I'm using java hibernate mysql 5.5
I'm looking for something like:
set SESSION sqlMode="AUTO_TRUNCATE_FIELDS"

instead of getting an error.
Is it possible to do it in a programatic way for the current executing session?

A: Meanwhile I've implemented via java-connection.mysql as shown here:
userDAO.s.doWork(
        new Work() {
            @Override
            public void execute(Connection arg0) throws SQLException {
                DatabaseMetaData databaseMetaData = arg0.getMetaData();
                ResultSet rs=databaseMetaData.getColumns(null, null, "event", "%");
                while (rs.next()) {
                    if ("title".equals(rs.getString("COLUMN_NAME"))) {
                        titleColumSize=rs.getInt("COLUMN_SIZE");
                    }
                }
        }
        }
    );

then:
if (title.length()>titleColumSize)
    title=title.substring(0, titleColumSize-7)+" [...]";

If any configuration solution is available I will appreciate!! Thanks!


text:
Q: JQuery slideDown not working; both HTML elements displayed, slider effect not happening My JQuery is not working and I cannot figure out why. I wonder if it has to do with recently upgrading to Windows 10, but I don't know. Here is my entire HTML page. Note: Even if I take out all links and scripts and just leave in the one for JQuery, it still doesn't work.
    <!DOCTYPE html>

    <title>Practice Search Results webpage</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="style.css">

We found results near you!

 Atomic Numbers

Here are the details about Atomic Numbers

A: You have to understand what slidedown() does. Your p tag is already displayed in the html. So it will not do anything with slidedown(). If you want to see the effect, do this:
 $("#details").hide().slideDown("slow");

A: I got it to work with the following code. Thanks everyone.
#details {
     display: none;
}

I did not realize "display: none;" was needed.


text:
Q: C# - Drawing a Rounded Rectangle on a panel I am currently trying to draw a gradient filled rounded rectangle onto a panel bar in a form.
From some research I found some code that allowed me to create a custom rectangle :
static class CustomRectangle
{
    public static GraphicsPath RoundedRect(Rectangle bounds, int radius)
    {
        int diameter = radius * 2;
        Size size = new Size(diameter, diameter);
        Rectangle arc = new Rectangle(bounds.Location, size);
        GraphicsPath path = new GraphicsPath();

        if (radius == 0)
        {
            path.AddRectangle(bounds);
            return path;
        }

        // top left arc
        path.AddArc(arc, 180, 90);

        // top right arc
        arc.X = bounds.Right - diameter;
        path.AddArc(arc, 270, 90);

        // bottom right arc
        arc.Y = bounds.Bottom - diameter;
        path.AddArc(arc, 0, 90);

        // bottom left arc
        arc.X = bounds.Left;
        path.AddArc(arc, 90, 90);

        path.CloseFigure();
        return path;
    }

    public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius)
    {
        if (graphics == null)
            throw new ArgumentNullException("graphics");
        if (brush == null)
            throw new ArgumentNullException("brush");

        using (GraphicsPath path = RoundedRect(bounds, cornerRadius))
        {
            graphics.FillPath(brush, path);
        }
    }

Credit to this page
Next using this custom rectangle, I have tried using the paint method for the bar panel.
private void quickMenuBar_Paint(object sender, PaintEventArgs e)
    {
        LinearGradientBrush myBrush = new LinearGradientBrush(new Point(20, 20), new Point(120, 520), Color.DarkBlue, Color.RoyalBlue);
        System.Drawing.Graphics formGraphics = this.CreateGraphics();

        CustomRectangle.FillRoundedRectangle(formGraphics, myBrush, new System.Drawing.Rectangle(20, 20, 100, 500), 25);
        myBrush.Dispose();
        formGraphics.Dispose();
}

But after executing this code, it only prints a rounded rectangle directly onto the form and behind the bar panel.
I have other methods that fill a panel with a standard rectangle using  PaintEventArgs e:
e.Graphics.FillRectangle(myBrush , otherBar.ClientRectangle);

So obviously I need to use PaintEventArgs e in my custom rectangle method, but I do not know how or where to.
If there are better ways than this way of drawing a rounded rectnagles, please share.

A: You generally should never be using CreateGraphics(). Simply remove this line:
System.Drawing.Graphics formGraphics = this.CreateGraphics();

And use e.Graphics where you would previously use formGraphics. The Paint event is basically asking you to "paint something for me, here's the graphics object to paint on".
Since you're already providing a Graphics object instance to your rounded rectangle method, no changes are required there.


text:
Q: Bash script to automatically close a process given the process name As you might have guessed from the title i'm trying to write a bash script to close all processes given a program name, but have close to 0 experience in doing that. What i've found is that with:
ps -aux | grep $processToClose

i can get all the processes with the name, but then to kill them i just manually use:
kill -9 $processPID

Any idea on how i could automate the process killing part?
(if you want to know why i want to do such thing: i use anydesk on my work laptop and my everyday PC so that i have to use just one, but sometimes (basically every day) anydesk chooses to not work and so i have to close it using the commands i wrote above)

A: That's what pkill is for.
pkill regexp

Kills (with SIGTERM like with kill, you generally don't want to use SIGKILL (9)) the processes whose name (as reported by ps or ps -o comm) matches the regular expression.
pkill -f regexp

For those whose arglist (assuming they or one of their ancestors have executed a command) as reported by ps -f (or ps -o comm or your BSD-style ps aux) matches the extended regexp.
Add the -x option for the regexp to match the name/arglist as a whole. For instance, so that pkill -x xterm kills the processes running xterm and not the ones running lxterm or xterminator as pkill xterm would.
So to kill the processes whose name is stored in $processToClose and assuming $processToClose doesn't contain regexp operators (\|$^*()+[]{}.?):
pkill -x -- "$processToClose"

If it contains or may contain regexp operators, they would need to be escaped with \:
LC_ALL=C pkill -x -- "$(
  printf '%s\n' "$processToClose" |
    LC_ALL=C sed 's/[][\\|$^*()+{}.?]/\\&/g')"

Here also setting the locale to C for both pkill and sed to allow process names that don't necessarily form valid text in the users locale.
To see what processes pkill would kill, you can replace pkill with pgrep -l.
pgrep/pkill are not standard commands but are very common.
ps is standard but very unportable. The list of options and the output format varies greatly between implementations. In particular, your ps -aux is likely only going to work with the procps implementation of ps (the one typically found on Linux-based systems). That's the BSD-style ps aux but with a spurious - in front.
The list of options specified by POSIX is very limited.
ps -A -o pid= -o comm= |
  NAME=$processToClose awk '
    NF == 2 && $2 "" == ENVIRON["NAME"] {print $1}' |
  xargs kill

Assuming $processToClose and process names don't contain whitespace would be a standard approach.

A: ps -aux |grep $processName |awk '{print $2}'| xargs -I {} kill {}