text:
Q: How can you pass props into a modal dialog in vuejs? In a Vuejs app, I have a modal dialog box pop up when user clicks a button. I need to pass a prop into this modal component. Normally, I have no trouble passing props to child components. Why is this case different? I'd rather not store any data in the store if avoidable. When the modal opens the prop collaboratorSelected is an empty String, i.e. it does not register the new prop value the parent is passing, but instead keeps the initial value set when the parent component mounts. This prop needs to be responsive.
Parent component...
    <template>

            Edit

       <EditShare @editedShare="editedShare" :collaboratorSelected="collaboratorToEdit" ref="modal" ></EditShare>

    </template>

Child modal component...
    <template>
      <form @submit.prevent="handleSubmit">

Add Share

                    {{collaboratorSelected}}

      </form>
    </template>

A: I believe that given that you're using jQuery, the jQuery code is executing before the property value is propagated to the child component.
Try wrapping the jQuery code in a $nextTick method and see if that works. Something like this:
this.collaboratorToEdit = collaborator;
  this.$nextTick(function(){
    let element = $('#editShare');
    $(element).modal('show');
  });

I did some experiments in this pen and I was able to see how the code in the function doesn't wait for the property value to propagate (as you have it) and how it waits for it when using $nextTick.
Let me know if it works.


text:
Q: Best way to incorporate a theme's code into MEAN.js application I am trying to incorporate all of the files (css, js, plugins) from a theme I purchased into a MEAN.js application I scaffolded out with yeoman. I am very unsure where to place the theme folders/how to call them in the layout.server.view.html page or even if that is the right page to be calling the files. Any suggestions would be great since I have not had much luck researching this topic on google.

A: FOR MEANJS 0.4 : (did not tried but should work for meanjs 0.3)
I did a custom service to suits my needs. One default skin and the user can choose a personnal skin. Skins comes from Bootswatch and are free to use.
'use strict';

angular.module( 'core' )
  .service( 'ThemeService', [ 'Authentication', '$rootScope', '$document', '$q', '$timeout',
      function (Authentication, $rootScope, $document, $q, $timeout ) {

      var defaultTheme = 'flatly';
      var defaultPath = 'themes/';
      var defaultExtension = '.min.css';
      var defaultIgnore = 'require';
      var themes = [
        'bootstrap',
        'cerulean',
        'custom',
        'cyborg',
        'darkly',
        'flatly',
        'journal',
        'lumen',
        'paper',
        'readable',
        'sandstone',
        'simplex',
        'slate',
        'spacelab',
        'superhero',
        'united',
        'yeti'
      ];

      this.themes = themes;

      var loadCSS = function (href) {
        var deferred = $q.defer();
        var style = $document[0].createElement('link');
        style.rel = 'stylesheet';
        style.type = 'text/css';
        style.href = href;
        style.onload = style.onreadystatechange = function (e) {
          $timeout(function () {
            deferred.resolve(e);
          });
        };
        style.onerror = function (e) {
          $timeout(function () {
            deferred.reject(e);
          });
        };
        $document[0].head.appendChild(style);
        return deferred.promise;
      };

      var theme = defaultTheme;
      if ( Authentication.user !== undefined )
        theme = Authentication.user.theme;

      var currentTheme = defaultTheme;

      var disableThemes = function (name) {
        var links = [];
        links = document.getElementsByTagName( 'link' );
        for ( var i = links.length - 1; i >= 0; i-- ) {
          if ( links[ i ].href.indexOf( defaultPath ) > -1 ){
            if( (links[ i ].href.indexOf( defaultPath + name ) === -1) && (links[ i ].href.indexOf( defaultPath + defaultIgnore ) === -1))
              links[ i ].disabled = true;
            else
              links[ i ].disabled = false;
          }
        }
      };

      var enableTheme = function ( name ) {
        var links = [];
        links = document.getElementsByTagName( 'link' );
        for ( var i = links.length - 1; i >= 0; i-- ) {
          if ( links[ i ].href.indexOf( defaultPath + name ) > -1 )
            links[ i ].disabled = false;
          currentTheme = name;
        }
      };

      var loadTheme = function ( name ) {
        if ( themes.indexOf( name ) === -1 ) // Theme do not exist
          return false;
        if ( name === currentTheme ) // Theme is already the current theme
          return console.log('Current theme');

        loadCSS( defaultPath + name + defaultExtension ).then( function ( ) {
          disableThemes(name);
          currentTheme = name;
        } ).
        catch ( function () {
          loadTheme( defaultTheme );
        } );
      };

      this.loadTheme = loadTheme;

      loadTheme( theme );

      $rootScope.$on( 'themeChange', function (e, theme) {
        loadTheme( Authentication.user.theme );
      } );

    } ] );

To change the skin, you can just send an event : "themeChange" to the root scope like :
$rootScope.$emit( 'themeChange', 'readable' );

This should be called on skin change, and on login.
Additionally, you should add the personnal theme to the user model.
If you just aim to set ONE custom theme, edit ./config/assets/production.js and ./config/assets/default.js.
Else you can just add the CSS files into CSS folder of you client module.

A: There are many ways to do this....But I can't tell you which one is right for you.
Create a theme folder within the public repository of the app and lets assume you use scss. In this theme folder, you can have a folder for scss, fonts, images. In the root of the theme folder, a parent scss file, which will call the partials of all files in the scss folder. Each partial could be named after a package. You get the gist.
Alternatively with mean package generator , and for each package you can have a css file in it. Mean.js will automatically compile all these files together , this is a grunt task (clientCSS: ['public/modules/**/*.css'] ...)
Both approaches work, your team's call to choose.

A: I've been doing this myself, it can get tricky depending on what you're trying to bring into your project.
The best way in my opinion is to keep things modular and stick to the conventions meanjs sets up.
You can create a seperate folder for your themes css and reference those files inside of your default.js, just to stay organized.
Next, take a look at the plugins that are being used, theres a good chance you can use bower to include these packages/plugins into your project. Make sure you include these in your dependencies to use throughout your app.
Take a look at your current theme, see what you can put into directives (ex: navigation, side menu, sliders, etc.) that way you have organized reusable code. Build your views by using these directives throughout.
Do one thing at a time and you'll be able to slowly bring over a theme.
Good luck!

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does a vertical arrow get rendered incorrectly? I am drawing a table with arrows in it. All the arrows are fine except for vertical ones pointing down.  Here is a MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

  \tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={rectangle,text width=1.5em,align=center},
        text height=1.1ex,
        nodes in empty cells,
    },
}
\begin{tikzpicture}
    \matrix (mat) [table]{
    &&0&0\\
    &0&1&2\\
    1&1&1&2\\
    1&2&2&2\\
    1&3&3&3\\
};

\begin{scope}[shorten >=7pt,shorten <= 7pt]

\draw[->]  (mat-1-3.center) -- (mat-2-4.center);
\draw[->]  (mat-2-4.center) -- (mat-3-4.center);

\end{scope}

\end{tikzpicture}
\end{document}

The arrow pointing down is rendered in a very strange way.

How can I fix this?

A: Why don't you increase the space between rows?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=3ex,
        column sep=-\pgflinewidth,
        nodes={rectangle,text width=1.5em,align=center},
        text height=1.1ex,
        nodes in empty cells,
    },
}
\begin{document}
\begin{tikzpicture}[shorten >=7pt,shorten <= 7pt]
    \matrix (mat) [table]{
    &&0&0\\
    &0&1&2\\
    1&1&1&2\\
    1&2&2&2\\
    1&3&3&3\\
};
\draw[->]  (mat-1-3.center) -- (mat-2-4.center);
\draw[->]  (mat-2-4.center) -- (mat-3-4.center);
\end{tikzpicture}
\end{document}

You could also use tikz-cd and simplify your code:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
    &&0\ar[dr]&0\\
    &0&1&2\ar[d]\\
    1&1&1&2\\
    1&2&2&2\\
    1&3&3&3\\
\end{tikzcd}
\end{document}

Edit: it's very difficult to have a table with 27 rows and columns and also arrows.
I tried with adjustbox:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{adjustbox}
\begin{document}
\noindent Some blind text just to show that the table is larger than text width. Blah blah

\begin{adjustbox}{width=.9\paperwidth, center}
\begin{tikzcd}[column sep=8pt,
row sep=12pt]
    1\ar[dr] &  2\ar[r] &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10\ar[r] &  11  &   12  &   13  &   14\ar[dr]   &   15  &   16\ar[d]    &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
2   &   2\ar[d] &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
3   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
4   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
5   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
6   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
7   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
8   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
9   &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
10  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
11  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
12  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
13  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
14  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
15  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
16  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
17  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
18  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
19  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
20  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
21  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
22  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
23  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
24  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
25  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
26  &   2   &   3   &   4   &   5   &   6   &   7   &   8   &   9   &   10  &   11  &   12  &   13  &   14  &   15  &   16  &   17  &   18  &   19  &   20  &   21  &   22  &   23  &   24  &   25  &   26  &   27  \\
27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  &   27  \\
\end{tikzcd}%
\end{adjustbox}
\end{document}


text:
Q: Error: list indices must be integers not float The code following should take the list of marks from the dictionary of a student and calculate the average marks of the student. I am getting the "TypeError: list indices must be integers, not float" error.
alice = {
    "name": "Alice",
    "homework": [100.0, 92.0, 98.0, 100.0],
    "quizzes": [82.0, 83.0, 91.0],
    "tests": [89.0, 97.0]
}

# Averege function is given below for calculating avg
def average(lst):
    l=float(len(lst))
    total = 0.0
    #code works till here the error occoured below
    for item in lst:
        add = int(lst[item])
        print add
        total+=add
    return total//l

print average(alice['tests'])
print alice['tests']

A: The issue is on this line:
for item in lst:
    add = int(lst[item])

for item in lst Iterates through each item in the list, not an index. So item is the value of the float in the list.
Instead try this:
for item in lst:
    add = int(item)

Additionally, there is no reason to cast to an integer as this will mess with your average, so you can shorten it further to:
for item in lst:
    add = item

Which means the for loop can be shortened to just:
for item in lst:
    total+= item

Which means we can shorten it even further, using the sum built in:
total = sum(lst)

Since total is now a float, we don't need to specify float division using the double slash, and we no longer need to cast the length to a float, so the function becomes:
def average(lst):
    l=len(lst)
    total = sum(lst)
    return total/l

And lastly, there is no reason to not do this all on one easy to read line:
def average(lst):
    return sum(lst)/len(lst)

A: The for item in lst will let item get each and every item in lst on each iteration. So, change
add = int(lst[item])

to
add = int(item)

For example, try this to understand better
data = ["a", "b", "c"]
for char in data:
    print char

will print
a
b
c

If you ever wanted to get the current index of the item, then you can use enumerate function
data = ["a", "b", "c"]
for index, char in enumerate(data):
    print index, char, data[index]

Output
0 a a
1 b b
2 c c


text:
Q: XNA Game development: Vector2 values randomly change to X:-2147483648 Y:-2147483648 it happens randomly, I checked my whole code and i don't set position anywhere to numbers like this, here is a screenshot, I am using visual studio 2013 and Windows 7.
Link to image: http://imgur.com/QtlNpEP

A: I think you are calculating with integers (although the vector2 are floats) but you might have some casts in your code.
See the following max/min values of ints and my example code which looks a lot like the problem you are having.
Int32.MaxValue: 2,147,483,647
Int32.MinValue: -2,147,483,648

See this example code and the comments with the values:
int a = Int32.MaxValue; // a is 2,147,483,647
a++; // after the ++ a is -2,147,483,648

A: Looks like it's fixed, it was problem with camera class when constructing viewMatrix, some mathematical operation was returning NaN.


text:
Q: How to force item to be rendered in collapsed mode in a card using Bootstrap 4 When the page containing this code below is rendered, the item shows in expanded mode. How can I force it to be closed?

      Collapsible Group Item #1

         some text

A: Remove the show class from the collapse element.

                          Collapsible Group Item #1

                          some text

https://www.codeply.com/go/peokOBkvwh


text:
Q: After running the DO WHILE loop, scanner is not working I have no idea why my scanner for the staffID and staffPassword is not working after I choose to continue typing a new record.
Click to see the output of the code
public class Test {
    public static void main(String args[]){

        String staffID, staffPassword; //Staff Record Variable
        int a = 0;
        boolean validation;
        Staff[] staff = new Staff[1000];
        int staffCount = 0;
        Scanner input = new Scanner(System.in);

        do{
            staff[staffCount] = new Staff();

            System.out.print("Staff ID: ");
            staffID = input.nextLine();
            staff[staffCount].SetStaffID(staffID);

            System.out.print("Password: ");
            staffPassword = input.nextLine();
            staff[staffCount].SetPassword(staffPassword);

            System.out.println("\nEnter 1 to continue, enter 2 to stop.");
            System.out.print("Continue to add more record?(1 or 0): " );
            a = input.nextInt();

        }while(a == 1);
    }
}

A: use input.next() instead of input.nextLine()

A: This is because the nextInt() method doesn't consume the new line after hitting enter for the a variable. It's better to leave the nextLine() in its place because the next() works until it reach a delimiter (default white space). What does that mean? It means that if you're trying to set the staffID with next() like this : "Id For Staff", the actual staffID will be just "Id".
Instead of changing nextLine() to next() I suggest you to use a simple input.nextLine() after the last line of your do while (a = input.nextInt();)


text:
Q: To Prove the relation between HCF and LCM of three numbers if $p,q,r$ are three positive integers prove that
$$LCM(p,q,r)=\frac{pqr \times HCF(p,q,r)}{HCF(p,q) \times HCF(q,r) \times HCF(r,p)}$$
I tried in this way;
Let $HCF(p,q)=x$ hence $p=xm$ and $q=xn$ where $m$ and $n$ are relatively prime.
similarly let $HCF(q,r)=y$ hence $q=ym_1$ and $r=yn_1$ where $m_1$ and $n_1$ are Relatively prime.
Alo let $HCF(r,p)=z$ hence $r=zm_2$ and $p=zn_2$
we have $$p=xm=zn_2$$
$$q=xn=ym_1$$and
$$r=yn_1=zm_2$$
can i have any hint to proceed?

A: I decided to write my comment as an answer. Rather than start with naming $HCF(p,q)$, $HCF(q,r)$ and $HCF(r,p)$, start with $HCF(p,q,r)$. So let's call $HCF(p,q,r) = h$.
Next, write $HCF(p,q) = xh$, $HCF(q,r) = yh$ and $HCF(r,p) = zh$. It should be clear why we can assume the factor $h$ appears in all three, but you also know that $x,y,z$ are relatively prime. (Why?)
Thus, you can write $p = p'xzh$ for some $p'$, and similarly $q = q'xyh$ and $r = r'yzh$ (again, why?). What do you get when you plug those into your equation?

A: To get a start on the problem first let us try to understand it intuitively. We need to show that for three numbers $a,b,c$, $$abc=\frac{LCM(a,b,c) \times HCF(a,b) \times HCF(b,c) \times HCF(c,a)}{HCF(a,b,c)}$$
On the LHS- the product of three numbers $a, b, c$ consists of product of all their factors.
On the RHS- The LCM contains all the factors of $a,b,c$ with common factors only taken once. The pairwise HCF's get us the pair-wise common factors not accounted for by the LCM. However, now the factors common to all the three numbers have been counted 4 times (with the LCM as well as with each pair-wise HCF's), instead of being counted 3 times (once for each number). To fix this  we divide the entire product by $HCF(a,b,c)$ which gets us the factors common to all the three numbers.
We can construct a general proof of the theorem based on above argument as well.
Alternatively, we can see that of the three number $a,b,c$ any number number, for example, $a$ is made of 4 kind of factors-
-Factors only in $a$ (say product of these factors is $\alpha$)
-Factors common between $a,b$ (say product of these factors is $x$)
-Factors common between $a,c$ (say product of these factors is $y$)
-Factors common between all three numbers (say product of these factors is $w = HFC(a,b,c)$).
Thus
$a = \alpha.x.y.w$
Similarly,
$b = \beta.x.z.w$ and
$c = \gamma.y.z.w$
Therefore, by multiplying the equations for three numbers we get,
$abc = \alpha.\beta.\gamma.x^2.y^2.z^2.w^3.$
or, $abc = \frac{\alpha.\beta.\gamma.x^2y^2.z^2.w^4}{w}$
but, $x.w=HCF(a,b)$ and $y.w=HCF(b,c)$ and $z.w=HCF(c,a)$ and $w=HCF(a,b,c)$
therefore,
$abc = \frac{\alpha.\beta.\gamma.x.y.z.w.HCF(a,b).HCF(b,c).HCF(c,a)}{HCF(a,b,c)}$
finally, we also have that $LCM(a,b,c)=\alpha.\beta.\gamma.x.y.z.w$
thus, $$abc = \frac{LCM(a,b,c).HCF(a,b).HCF(b,c).HCF(c,a)}{HCF(a,b,c)}$$

A: Let $P, Q$ and $R$ be the sets of prime factors of the numbers $p,q$ and $r$ respectively. Let the universal set be $P\cup Q\cup R$. Let there be product function $v(S)$ which gives the product of the elements of set S.
Then, celarly,
$$pqr=v(P\cap Q' \cap R')*v(Q\cap P' \cap R')*v(R\cap P'\cap Q')*v^2(P\cap Q\cap R')*v^2(Q\cap R\cap P')*v^2(R\cap P\cap Q')*v^3(P\cap Q\cap R)$$
Now,
$$LCM(p,q,r)=v(P\cap Q' \cap R')*v(Q\cap P' \cap R')*v(R\cap P'\cap Q')*v(P\cap Q\cap R')*v(Q\cap R\cap P')*v(R\cap P\cap Q')*v(P\cap Q\cap R)$$
$$HCF(p,q)=v(P\cap Q\cap R')*v(P\cap Q\cap R)$$
$$HCF(q,r)=v(Q\cap R\cap P')*v(P\cap Q\cap R)$$
$$HCF(r,p)=v(R\cap P\cap Q')*v(P\cap Q\cap R)$$
$$HCF(p,q,r)=v(P\cap Q\cap R)$$
These expressions satisfy your equation.


text:
Q: How to write the java code to get contact list from yahoo
Possible Duplicate:
Taking contact list from hotmail gmail yahoo in java?

How to write the java code to get contact list from yahoo

A: Similar qs asked before .. check that :
Taking contact list from hotmail gmail yahoo in java?


text:
Q: jQuery: Add Height from Variable I'm trying to add height to a few elements based upon a variable. I thought this was the right approach, but it's the line breaking my javascript.
$('#content').css('height': '+=VariableX');

There seems to be so many different approaches to this, I'm not sure what's correct. I know that generally, at least for JSON, everything should have " " around it. Although I believe for primitive values, you can forego the quotes. But ultimately, I would love to be directed towards a guide that shows the best practices for the syntax here. Since clearly I've got it wrong.
Thanks.
In case my calculation is generated something incorrectly, here it is. It should generate a value that is the difference between my container height (540px) after adjustment (browser window width / 960px) less browser window height.
var addHeight = windowH - (540 * (windowW / (960)));

I've added another line of my code as I think it might be breaking as result of the way I'm ordering this zoom effect and the adding height? Maybe not though. Not sure if it matters.
else{

    $('#wrapper').css({'zoom': windowW / (960)});
    $('#content').css('height': '+=' VariableX);

}

A: I would manage the increment outside the JQuery call:
var VariableX = $('#content').height();
VariableX += 1;
$('#content').height(VariableX);

A: A line from your question:

I know that generally, at least for JSON, everything should have " " around it.

This is Javascript, not JSON. Javascript variables should not have "" around them, otherwise they are treated as string literals, not as variables.
What you need here is a string, part of which is formed from a variable. This involves concatenation using the + operator:
$('#content').css('height', '+=' + VariableX);

This builds up a string made up of += followed by the contents of VariableX.

Your error has revealed the problem:
$('#wrapper').css({'zoom': windowW / (960)}),;

That last comma makes invalid Javascript. This will make your code work.
$('#wrapper').css({'zoom': windowW / (960)});


text:
Q: Difference between 1:10 and 0.1:1.0 I was wondering why R sees (1:10) as an vector counting from 1 to 10
And (0.1:1.0) as 0.1?
Should i define the steps from 0.05 by myself? or is there a trick to do this?

A: The colon makes a sequence from the first number to last with steps of exactly 1. Since in 0.1:1 that is less than one step it only returns the first number. I think you are looking for seq(0.1,1,length=10)?

A: Try 0.1 * (1:10).  It's (imho) clearer to read and easier to remember than the seq syntax, and while it may involve more processing is fine for everyday.


text:
Q: Invoking the Windows Security Dialog (in C# or VB.NET) I would like to know how to invoke the Windows Security Dialog (press ctrl+alt+del on a windows workstation NOTE: I don't want the task manager!) programmatically.
ON AN XP WORKSTATION, don't worry about Win7 or Vista
Ideally with a quick example in C# (or VB.NET if you must)
Ive searched many of the DLL's such as msgina.dll and I can't find it anywhere!
Alternatively just invoking the change password screen would be nice!

A: You can try call WlxLoggedOnSAS function from GINA or WlxSasNotify  from WinLogon.
But, I afraid it won't work. But, maybe it will lead you to working method. And it definitely will not work in Vista/W7.
In other side, it might be that Windows Security Dialog can be called only by secure attention sequence ( ctrl+alt+del) by securytt reasons.

A: Security features might be standing in your way to programmatically manage security-related features like Security Dialog through CtrlAltDel. I've been running into the same kinds of problems.
About your request to invoke password change dialog.
IADsUser
"designed to represent and manage an end-user account on a network [and locally]."
If you find yourself short on solutions, you might whip up your own quick Windows form with password fields and communicate with the  Windows IADsUser Interface using the WinNT provider to bind to a local (instead of network) user account on the XP machine.
GetObject("WinNT://MYCOMPUTER/jeffsmith,user") //WinNT provider

... and use the ChangePassword(..) method (links to code sample).
usr.ChangePassword szOldPass, szNewPass

If you're trying to invoke the Windows features directly to cause the user to trust the process then admittedly a custom form for changing a password might look a bit goofy.
RunDLL32
Another avenue you might try is programmatically invoking RunDLL32.exe at the command line and targeting the correct Win DLL to bring up the password change dialog box. One forum said the following works in XP if SP2 isn't installed. I can't test it because I'm on Vista.
rundll32.exe shell32.dll,Control_RunDLL password.cpl

You can Google for many of these, however it does seem to come up short as far as changing the password or invoking Windows security dialog.
Microsoft's info about Run32Dll

A: You might want to take a look at the SendInput hook in User32:
http://msdn.microsoft.com/en-us/library/ms646310(VS.85).aspx
and
http://pinvoke.net/default.aspx/user32/SendInput.html

A: I would imagine something like this, get the handle of the desktop, using 'GetDesktopWindow', make sure the focus is set to the handle, and Send a keystroke 'Ctrl+Alt+Del' using 'SendInput' or use the 'SendMessage' to send the keystrokes to that handle returned by GetDesktopWindow. It is not guaranteed to work as that is top-off-my-head.
Hope this helps,
Best regards,
Tom.

A: This is a workaround i found on other forum. It works for me.
Private Function IsRunAsAdministrator() As Boolean

    Dim wi = WindowsIdentity.GetCurrent()
    Dim wp = New WindowsPrincipal(wi)

    Return wp.IsInRole(WindowsBuiltInRole.Administrator)

End Function

'i use it on formload, you can have it whenever needed
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If Not IsRunAsAdministrator() Then
        Dim processInfo = New ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase)
        processInfo.UseShellExecute = True
        processInfo.Verb = "runas"
        Try

            Process.Start(processInfo)

        Catch ew1 As Exception
            MessageBox.Show("Sorry, this application must be run as Administrator.")
        End Try
        'Application.Current.Shutdown()
        Application.ExitThread()
    Else
   'your statement here
  End If
End Sub


text:
Q: page-router-outlet not working in my nativescript-ng2-magic project I want to create an app for both web and android using :
https://github.com/NathanWalker/nativescript-ng2-magic.
I have created 2 components HomePageComponent and AddPageComponent
but this code doesn't seem to work in my app.component.tns.html:
<page-router-outlet></page-router-outlet>

It should show me what's in my homepage.component.tns.html:
<ActionBar title="Home Page"></ActionBar>

here is the code in my app.routing.ts
import {HomePageComponent} from "./components/homepage/homepage.component";
import {AddPageComponent} from "./components/addpage/addpage.component";

export const AppRoutes: any= [
   {path:'', component: HomePageComponent},
   {path:'addpage', component: AddPageComponent}
];

export const AppComponents: any = [
   HomePageComponent,
   AddPageComponent
];

and the code of app.module.ts :
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/platform";
import {AppRoutes, AppComponents} from "./app.routing";
import {NativeScriptRouterModule} from "nativescript-angular/router";
import {NativeScriptFormsModule} from "nativescript-angular/forms"

import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent, ...AppComponents],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    NativeScriptModule,
      NativeScriptFormsModule,
      NativeScriptRouterModule,
      NativeScriptRouterModule.forRoot(AppRoutes)
  ],
  schemas: [NO_ERRORS_SCHEMA],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

A: It is very important to wrap <page-router-outlet></page-router-outlet> with a layout container so try this:
<StackLayout>
  <page-router-outlet></page-router-outlet>
</StackLayout>

Also try adding this as well to your HomeComponent to see it:
<ActionBar title="Home Page"></ActionBar>
<StackLayout>
  <Label text="Home"></Label>
</StackLayout>

EDITED 12/11/16:
The order of your imports could be the culprit. You want the {N} platform import first; Also try using the next tag of nativescript-angular in your package (note with next tag, the import location changed to all import from same barrel), then clear node_modules, platforms again (rm -rf node_modules platforms) and reinstall. Plus you don't want to use the other angular imports so try updating to this:
import {
  NativeScriptModule,
  NativeScriptFormsModule,
  NativeScriptHttpModule,
  NativeScriptRouterModule
} from "nativescript-angular";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { AppRoutes, AppComponents } from "./app.routing";
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent, ...AppComponents],
  imports: [
    NativeScriptModule,
    NativeScriptFormsModule,
    NativeScriptHttpModule,
    NativeScriptRouterModule.forRoot(AppRoutes)
  ],
  schemas: [NO_ERRORS_SCHEMA],
  bootstrap: [AppComponent]
})
export class AppModule { }


text:
Q: Int array in vb.net I have this int array:
0,1
0,2
0,3
0,4
1,5
1,6
1,7
1,8
etc

What I need to do is to make a function that gives me an array that is something like this
0,1
0,2
0,3
0,4

It returns all the results that have the same number in the index 0.
And the next time I call it, it should return:
1,5
1,6
1,7
1,8

And so on. Or it can also return this
0,1,2,3,4
1,5,6,7,8

and so on
Help please :(

A: Assuming that you have something like
Dim variable(,) as Integer '(2-dimensional array)

then you can use a simple loop for that:
Dim _result as New List(Of String)
For i as Integer = 0 to 1
  For j as Integer = 1 to 4
    _result.Add(variable(i, j+i*4).ToString)
  Next j
  _result.Add(vbCrLf)
Next i
MsgBox(Join(_result.ToArray,","))

It is a bit dirty, would be better to combine each line and do another join with vbCrLf, because this way you have another comma in front of every additional line, but it should be sufficient to understand how it works.
Updated
Well, I doubt that you need those places from the array, but not the answer fits to it. 4 Elements, so the second array can just be accessed with 1 to 4 plus 4 * first array index

A: Arrays are fantastic, but you may also want to try this using more 'modern' objects like Dictionaries and Lists
Try this:
' Load the data
Dim x As New Dictionary(Of Integer, List(Of Integer))
x.Add(1, New List(Of Integer)({1, 2, 3, 4}))
x.Add(2, New List(Of Integer)({5, 6, 7, 8}))

' Access the data
Debug.Print("items under 1")
For Each i As Integer In x.Item(1)
    Debug.Print(i)
Next

Debug.Print("items under 2")
For Each i As Integer In x.Item(2)
    Debug.Print(i)
Next

This gives output like:
items under 1
1
2
3
4
items under 2
5
6
7
8


text:
Q: How to create horizontal scroll bar for a div I have the following items.
left arrow  slide1 slide2 slide3 slide4 slide5... right arrow

I want to be able to have horizontal scroll bar in my div.
I have something like this

css
#slide-container{
    width: 970px;
    height: 190px;
    line-height: 190px;
    border:solid 1px #EEEEEE;
    position: relative;
    overflow: scroll;
}

I can only see the vertical scroll bar and my slides are vertically aligned. I was hoping someone here can help me to keep my slides aligned horizontally and show a scroll bar for it.
My brain is fried...
Thanks a lot!

A: To #slide-container add white-space: nowrap; overflow: auto;.
For #slide-list li add display: inline-block;.

A: Please replace your style with this
   #slide-container{
    width: 970px;
    height: 190px;
    line-height: 190px;
    border:solid 1px #EEEEEE;
    position: relative;
    overflow-y:hidden;
    overflow-x: scroll;
    display:block;
}
#slide-list
{
    width:1500px; /*i put this for see the scrolling/*
}


text:
Q: Mobile site/app - capture data offline and push to live database I have an existing site which involves ongoing data capture from the site's member base. I want to provide a mobile friendly version of the site which can handle offline form submissions. I also want the mobile site not to be a native app and I would prefer to develop it as a web app which would work across iOS, Android etc - mainly due to not having the necessary development time to develop platform specific versions. But, is this realistic alongside my aim of handling offline form submission? Does anyone have any advice on this? The site is currently PHP/MySQL based.
Thanks for any pointers.

A: You should look into HTML5 offline storage.
There is a answer about this on SO
https://stackoverflow.com/questions/1194784/which-browsers-support-html5-offline-storage

A: Use HTML5 offline app, and localStorage (see these in action on html5demos.com).  To find out what browsers support this HTML5 functionality, go to http://www.quirksmode.org/webkit.html and look for appcache and localStorage.
You also need to figure out when to post the data to your server. So you'll also need some javascript code as part of your offline app that knows when the user is online, knows that there is data in localStorage and knows and when to post the data.
Take a look at Sencha Touch, it is a framework for mobile apps and may help you.


text:
Q: Determine whether $F^\times$ has a cyclic subgroup of order $10$ where $F=\mathbb{R}((t)),\mathbb{C}((t))$ I wanted to verify my attempt:

Determine whether $F^\times=\langle F\setminus \{0\},\cdot, 1\rangle$ has a cyclic subgroup of order $10$ where:

*

*$F=\mathbb{C}((t))$.

*$F=\mathbb{R}((t))$.

*

*We notice that $\langle \zeta\rangle\subset\mathbb{C}\subset F$ where $\zeta=\exp({\pi i\over5})$ is a cyclic subgroup of $F$ of order $10$.

*If $\langle\alpha\rangle$ is a cyclic subgroup of $F$ of order $10$ then it must have that $\alpha\in\mathbb{R}((t))$ is a primitive unit root of order $10$. Then we must have $$\alpha=\exp({\pi i k\over 5})$$ where $k=1,2,3,4,6,7,8,9$. But in all of these cases $\alpha\notin\mathbb{R}((t))$. Thus we conclude that there isn't a cyclic subgroup of $\mathbb{R}((t))$ of order $10$.


text:
Q: Replace all the occurrences of a sub-string that matches certain pattern in SQL Server 2014 I want to replace all the occurrences of the pattern AI[0-9][0-9][0-9] with another string so that the final output would be like :
Input string:
'blah blah bhal AI dbo.AI001abc AI787abc AIWS find AI333xyz'

Output string:
'blah blah bhal AI dbo.AI001abc op.AI787abc AIWS find op.AI333xyz'

In other words if AI[0-9][0-9][0-9] pattern is found, I need to append "op."
Thanks in advance.


text:
Q: Dynamic css classes in react I'm trying to add css classes dynamically.
I have a array of colors that i want to get random color each time component rendered.
Here is what i did :
import styles from './UsersBoxItem.module.scss'
let colors = ['red', 'blue', 'green', 'pink', 'orange'];

class UsersBoxItem extends Component {
    render() {
        let colorClass = colors[Math.floor(Math.random() * colors.length)];
        colors = colors.filter(item => item !== colorClass)
        return (
            <div className={`${styles.box} ${styles.colorClass}`}>

I'm using css-modules but this ${styles.colorClass} won't work and i got undefined.
Here's my code : https://codesandbox.io/embed/cocky-cloud-lomzr
Any ideas ? Thanks

A: @Sung M. Kim solution work ok, I do not think that what do you want.
https://codesandbox.io/s/thirsty-lewin-k3j1y

A: You'd need to add actual class declarations in your CSS.
.red {
  color: red;
}
.blue {
  color: blue;
}
.green {
  color: green;
}
.pink {
  color: pink;
}
.orange {
  color: orange;
}

Forked sandbox


text:
Q: jQuery accordion w/input, how do you get the input to not close the accordion & still be able to control it? This is more of a proof of concept for myself, to fool around and learn what I can and can't do with jQuery, and I have had partial success.
I created an accordion that contains two spans, which serve as name and description, as well as a button that is independently click-able (ie, it does not open or close the accordion.)
Taking that concept, I decided to try and make the name and description editable by turning the name and description spans into text inputs / text areas, which worked fairly well.
The problem however is that when I take the same technique I used on the button and use it on the input and textarea, clicking it does not allow you to move the cursor to different positions. There does not seem to be a way for me to get around this behavior.
I tried event.preventDefault(), which does not work at all.
I tried event.stopPropagation(), which gives the partially working behavior.
and I tried return false, which worked the same way as stopPropagation.
I was wondering if anyone could provide any insight on this issue.
I included the jQuery javascript below, but for a much more concise example I will provide a jsfiddle link here (http://jsfiddle.net/Rakshasas/xFhN3/) which gives you a much more clear example of what I am doing. Note that when you click the accordion to expand it, the spans are hidden and inputs are shown. Clicking the inputs does not close the accordion, but it also does not allow you to position the cursor.
Also, if you do attempt to change the text in the inputs, closing the accordion does indeed update the spans which is the intended result. This is why I am saying my concept partially works.
Thank you.
$(function() {
    $(".accordion").accordion({
        header: 'h3',
        collapsible: true,
        active: false,
        change: function(event, ui) {
            var id = ui.newHeader.find('input:last').val();
            $("#status").text(id);

            ui.newHeader.find('div.headerContainer input.name').val(ui.newHeader.find('div.headerContainer span.name').text());
            ui.newHeader.find('div.headerContainer textarea.desc').val(ui.newHeader.find('div.headerContainer span.desc').text());

            ui.oldHeader.find('div.headerContainer span.name').text(ui.oldHeader.find('div.headerContainer input.name').val());
            ui.oldHeader.find('div.headerContainer span.desc').text(ui.oldHeader.find('div.headerContainer textarea.desc').val());

            ui.newHeader.find('div.headerContainer span').hide();
            ui.newHeader.find('div.headerContainer input, div.headerContainer textarea').show();

            ui.oldHeader.find('div.headerContainer span').show();
            ui.oldHeader.find('div.headerContainer input, div.headerContainer textarea').hide();
        }
    });

    $('input.name, textarea.desc').click(function(event){
        event.stopPropagation();
    });

    $(".delButton").button({
        icons: {primary: 'ui-icon-trash'},
        text: false
    }).click(function(event) {
        //Display user friendly text
        return false;
    });
});

A: If someone is facing this issue, this is a little trick that worked for me.
PROBLEM: nested jquery accordions with input/textareas elements, cannot gain focus with normal click in Firefox (if you use jquery accordions with NO nested accordions on it, everything works fine). Confirmed by above users.
The sympton relates only to normal click (left click). If you try optional click (right click), the element (input/textarea) WILL gain focus. Weird.
SOLUTION: Just declare this in your document ready function
$(function() {

    //some code ...

    $("input, textarea").click( function(){
        $("input, textarea").blur();
        $(this).focus();
    });

    //more code ...

});

Confirmed (by me) working on IExplorer, Firefox and Chrome.

A: Seems to work fine in Chrome. This might be browser dependent.

"Clicking the inputs does not close the accordion, but it also does not allow you to position the cursor"
Also fine in Chrome.


text:
Q: CSS style "position" is not work in keyframes on IOS I use animation in css.
I am trying to move a div to the top of the page with animation.
The following example code works in Google Chrome and Android.
It does not work on iOS11.

        <title>animate</title>

                    A

                    B

This solution does not work for me:
keyframe animation does not work on safari for iOS
I tried:
 -webkit-animation-name: movToTop;
 -webkit-animation-duration: 1s;

instead of
-webkit-animation: moveToTop 3s;

That did not work.
When I move the position:absolute; out of the keyframes, it works. But I have to put position:absolute; in the keyframes block.


text:
Q: I am looking to use textfiles to validate a username and password login I am looking to use textfiles to validate a username and password in VB.NET.
I have the username validated but I can not validate the passsword and anything entered in txtpassowrd.text will result in a login.
The code I used is this:
Imports System.IO
Public Class frmReceptionist
    Function IsInFile(ByVal person As String) As Boolean
        If File.Exists("receptionistUser.txt") And File.Exists("receptionistPassword.txt") Then

            Dim sr As StreamReader = File.OpenText("receptionistUser.txt")
            Dim individual As String

            Do Until sr.EndOfStream
                individual = sr.ReadLine

                If individual = person Then
                    sr.Close()
                    Return True
                End If

            Loop
            sr.Close()
        End If
        Return False

    End Function

    Private Sub btnConfirm_Click(sender As Object, e As EventArgs) Handles btnConfirm.Click
        'Determine if a person is in the file
        Dim person As String = txtUsername.Text

        If person <> "" Then
            If IsInFile(person) Then

                MessageBox.Show(person & " Welcome Receptionist", "Bia Duitse")
                Me.Hide()
                frmBiaDuitse.Show()

            Else
                MessageBox.Show(person & " Incorrect Login", "No")

            End If
        Else
            MessageBox.Show("You must enter Details", "Information")
        End If
        txtUsername.Clear()
        txtUsername.Focus()

    End Sub
    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Me.Hide()
        frmSelectJob.Show()

    End Sub

End Class

A: This is definitely not the way you should be doing this.
For learning purposes, you could load up your files into a Dictionary() like this:
Private Credentials As Dictionary(Of String, String)

Private Sub LoadCredentials()
    If IsNothing(Credentials) Then
        Credentials = New Dictionary(Of String, String)()
        If File.Exists("receptionistUser.txt") And File.Exists("receptionistPassword.txt") Then
            Dim users() As String = File.ReadAllLines("receptionistUser.txt")
            Dim passwords() As String = File.ReadAllLines("receptionistPassword.txt")
            If users.Length = passwords.Length Then
                For i As Integer = 0 To users.Length - 1
                    Credentials.Add(users(i), passwords(i))
                Next
            End If
        End If
    End If
End Sub

Function IsInFile(ByVal person As String) As Boolean
    LoadCredentials()
    If Not IsNothing(Credentials) Then
        Return Credentials.ContainsKey(person)
    End If
    Return False
End Function

Function Checkpassword(ByVal person As String, ByVal password As String) As Boolean
    LoadCredentials()
    If Not IsNothing(Credentials) Then
        Return Credentials.ContainsKey(person) AndAlso password = Credentials(person)
    End If
    Return False
End Function


text:
Q: Buscar Linux directorios con mismo nombre entre directorios masivamente Estoy tratando de buscar una serie de directorios (carpetas) que se que están repetidos pero, está tan anidado que estoy tratando de llegar a ellos con una expresión regular y que me devuelva la localización de los mismos. Así sería el árbol de búsqueda:
└── padre
      └── hijo1
            └──hijo1
                  └──nombre1
      └── hijo2
            └──hijo1
                  └──nombre2
      └── hijo3
            └──hijo1
                  └──nombre3
      └── hijo4
            └──hijo1
                  └──nombre1

Tendría que devolverme algo así:
/padre/hijo1/hijo1/nombre1
/padre/hijo4/hijo1/nombre1

Es decir, necesito saber qué nombres finales están repetidos en una lista. Hay cientos de carpetas, por eso necesito algo como esto.
Edito. Por si ayuda, el nombre del directorio acaba en '.as'. No es una extensión sino que lleva ese sufijo.

A: Me adelanto y contesto lo que creo que necesitás, que es buscar nombres de archivos repetidos:
find padre -mindepth 1 -type f -printf '%p %f\n' | sort -t ' ' -k 2,2 | uniq -f 1 --all-repeated=separate | cut -d' ' -f1

Siendo:
padre
    El directorio desde donde empezar a buscar
-mindepth 1
    Procesar todos los archivos a partir del nivel actual.
-type f
    Buscamos únicamente archivos (file).
-printf '%p %f\n'
    Imprimimos directorio y nombre del archivo, agregando un salto de linea al final
| sort -t ' ' -k 2,2
    Pasamos la salida del find al sort, seteando como separador de campos el ' ' y utilizando la segunda columna devuelta por el find para ordenar
| uniq -f 1 --all-repeated=separate
    Pasamos la salida del sort al uniq, evitando comparar la primera columna e imprimiendo los duplicados separando los grupos mediante una linea nueva
| cut -d' ' -f1
    Pasamos la salida del uniq al cut, seteando el delimitador en ' ' y filtrando unicamente la fila 1 a partir del delimitador

En donde con la siguiente estructura de directorios/archivos (Siendo nombre* archivos y padre e hijo* directorios):
padre/
├── hijo1
│   └── hijo1
│       └── nombre1
├── hijo2
│   └── hijo1
│       └── nombre2
└── hijo3
    └── hijo1
        └── nombre1

Obtengo el siguiente resultado:
padre/hijo1/hijo1/nombre1
padre/hijo3/hijo1/nombre1

A: Puedes intentar con awk.
find padre -mindepth 3 -type d | awk -F / '
!count[$NF]++ {
    registros[$NF] = $0
    next
}
count[$NF] == 2 {
    print registros[$NF]
    delete registros[$NF]
}
{print}'

Donde:

*

*-mindepth 3 es suponiendo que quieres obtener los duplicados del tercer nivel de profundidad:
padre/<primer nivel>/<segundo nivel>/<tercer y último nivel>

*-type d indica que se buscaran archivos tipo directorio, puesto que eso entendí de tu pregunta, pero la respuesta de Magus muestra bien la opción -type f en caso de archivos normales.
La explicación con awk puede ser un poco enredada, pero es simple.
Primero, el parámetro -F / muestra que se usa / como separador.
Respecto al código:
!count[$NF]++ { #  Añade en el array "count" el último campo (el campo 4 en caso de que sean 3 niveles
                #+ (el padre mas los tres "hijos")) como clave (con $NF) y genera un conteo que se guarda como valor.

# Todo este bloque se ejecuta en el caso de que el valor de "count[$NF]" no se haya visto antes.

    registros[$NF] = $0 # En el array "registros", se añade un nuevo elemento con el campo 4 (el nombre de la última capeta)
                        # como clave, y el registro entero (la dirección completa) como valor.

    next # Evita todas las instrucciones subsecuentes y cambia al siguiente registro.
}
count[$NF] == 2 { # En el caso de que el campo (el último campo) esté duplicado,
#                                 |
#                                 |
    print registros[$NF]  # imprime el registro correspondiente,
    delete registros[$NF] # luego borra el registro para no guardarlo en memoria.
}
{print}

El resultado de este comando da:
padre/hijo1/hijo1/nombre1
padre/hijo4/hijo1/nombre1


text:
Q: Javascript: How to get URL before listening for firebase changes? I am trying to create a Chrome Extension but I am having som trouble.
I want to use thing function to listen to updates in my Firebase Database:
firebase
.database()
.ref(`${URLOfCurrentTab}/messages`)
.endAt()
.limitToLast(1)
.on("child_added", function (snapshot) {)}

So I have added this function in my background.js file so i can consistently listen for updates, to do that I need the current URL of the active tab. But the problem is that the firebase "function" runs before the URL is retrieved.
This is how I retrieve the URL. I have added these functions in the background.js file just above the firebase stuff:
  let activeTabId, lastUrl, lastTitle;

  function getTabInfo(tabId) {
    console.log("first");
    chrome.tabs.get(tabId, function (tab) {
      if (lastUrl != tab.url || lastTitle != tab.title) {
        console.log((lastUrl = tab.url));

        lastUrl = tab.url;
      }
    });
  }

  // When tab is clicked on
  chrome.tabs.onActivated.addListener(function (activeInfo) {
    console.log("second");
    getTabInfo((activeTabId = activeInfo.tabId));
  });

  // When update in already clicked tab happens
  chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
    console.log("third");

    if (activeTabId == tabId) {
      getTabInfo(tabId);
    }
  });

Any ideas on what to do?


text:
Q: What is the definition of asymptotically flat convergence? I'm reading an article about a sliding modes control approach which mentions that a given function Ln(cosh(*)) is nearly linear outside the small neighborhood of the origin but partial asymptotically flat near zero.
I'm not quite sure what does "partially flat" means, I thought it might be a reference to a certain kind of convergence rate or maybe the smoothness of the function. Do you have any ideas?


text:
Q: cakephp admin prefix assets I want have cakephp app with 2 part the main site and the admin panel and layout and design of the 2 part are seprate
I created Admin prefix and put my admins controller and template file in Admin folder
I created a folder in webroot named Admin too and put my admin related assets there .
In cakephp config/App.php there is part to specify base url of assets . i's look like this
'App' => [
    'namespace' => 'App',
    'encoding' => env('APP_ENCODING', 'UTF-8'),
    'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),
    'base' => false,
    'dir' => 'src',
    'webroot' => 'webroot',
    'wwwRoot' => WWW_ROOT,
    // 'baseUrl' => env('SCRIPT_NAME'),
    'fullBaseUrl' => false,
    'imageBaseUrl' => '',
    'cssBaseUrl' => 'css/',
    'jsBaseUrl' => 'js/',
    'paths' => [
        'plugins' => [ROOT . DS . 'plugins' . DS],
        'templates' => [APP . 'Template' . DS],
        'locales' => [APP . 'Locale' . DS],
    ],
],

I'm wondering how can i specify defferent dicrectory for assets for Admin ?
Or how should i call css method in Html helper for admin ?
I load css file in main part of site like this
<?= $this->Html->css('custom.css') ?>

But i have to load it for admin side like this
<?= $this->Html->css('../Admin/css/custom.css') ?>

Is there any way i can fix this and load it like i do the main part ?
I also used it like this but it seems not to recognize prefix option
<?= $this->Html->css('custom.css' , ['prefix'=>'Admin']) ?>


text:
Q: Common Table Expression w/ Update Using Postgres 10.5, given the following:
postgres=# begin;
   with updated as (update bippy set id = 100 where id = 1 returning 1)
select id, ts from bippy;
commit;
BEGIN
 id |              ts
----+-------------------------------
 66 | 2019-07-09 10:42:32.062496-04
 80 | 2019-07-09 10:43:28.068512-04
 80 | 2019-07-09 10:43:28.596341-04
 80 | 2019-07-15 14:42:32.062496-04
  1 | 2019-07-09 10:42:23.142809-04
  1 | 2019-07-09 10:42:25.366664-04
  1 | 2019-07-09 10:42:26.142027-04
  1 | 2019-07-09 10:42:26.702398-04
(8 rows)

COMMIT

Why does the above return an id of 1 instead of 100, i.e. per the Common Table Expression?
When I select from the table immediately after, I see that the updates have taken place.
postgres=# select * from bippy;
              ts               | id
-------------------------------+-----
 2019-07-09 10:42:32.062496-04 |  66
 2019-07-09 10:43:28.068512-04 |  80
 2019-07-09 10:43:28.596341-04 |  80
 2019-07-15 14:42:32.062496-04 |  80
 2019-07-09 10:42:23.142809-04 | 100
 2019-07-09 10:42:25.366664-04 | 100
 2019-07-09 10:42:26.142027-04 | 100
 2019-07-09 10:42:26.702398-04 | 100
(8 rows)

A: You need to query the CTE and return * to see the changed data.
   with updated as (update bippy set id = 100 where id = 1 returning *)
   select id, ts from updated;

Or if you want all rows returned (updated and non-updated):
   with updated as (update bippy set id = 100 where id = 1 returning id, ts)
   select id, ts from updated
   UNION ALL
   select id, ts from bippy where id <> 1;

From the documentation:
7.8.2. Data-Modifying Statements in WITH
The sub-statements in WITH are executed concurrently with each other and with the main query. Therefore, when using data-modifying statements in WITH, the order in which the specified updates actually happen is unpredictable. All the statements are executed with the same snapshot (see Chapter 13), so they cannot "see" one another's effects on the target tables. This alleviates the effects of the unpredictability of the actual order of row updates, and means that RETURNING data is the only way to communicate changes between different WITH sub-statements and the main query. An example of this is that in
WITH t AS (
    UPDATE products SET price = price * 1.05
    RETURNING *
)
SELECT * FROM products;

the outer SELECT would return the original prices before the action of the UPDATE, while in
WITH t AS (
    UPDATE products SET price = price * 1.05
    RETURNING *
)
SELECT * FROM t;

the outer SELECT would return the updated data.


text:
Q: Texture displaying on both triangles forming a square instead of only on one I have tried to put a texture on a square, made out of two triangles, but it isn't displaying on the square and it is on both triangles seperately. I followed many tutorials, but they don't go into much details on how to fix this. It seems, that I need to change my shader, but I don't know how to go about this. Please tell me what to change!
This is a picture of the window:

This is my code:
#define GLEW_STATIC
#define STB_IMAGE_IMPLEMENTATION
#include<stdio.h>
#include<GL/glew.h>
#include<GLFW/glfw3.h>
#include<stdbool.h>
#include<string.h>
#include<stb/stb_image.h>

GLint uniColor;
void key_callback();

int main(){
   if(!glfwInit()){
      printf("Failed to initialize glfw!\n");
      return 1;
   }else{
      printf("Successfully initialized glfw!\n");
   }
   glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
   glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
   glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
   GLFWwindow* window = glfwCreateWindow(1054, 1057, "Title", NULL, NULL);
   glfwSetKeyCallback(window, key_callback);
   if(!window){
      printf("Window creation failed!\n");
      return 1;
   }else{
      printf("Window created successfully!\n");
   }
   glfwMakeContextCurrent(window);
   glewExperimental = GL_TRUE;
   if(glewInit() != GLEW_OK){
      printf("Failed to initialize glew!\n");
      return 1;
   }else{
      printf("Successfully initialized glew!\n");
   }
   glfwSwapInterval(1);
   float Vertices[] = {
     -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
     -0.5f,  0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
      0.5f,  0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
      0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f
   };

   GLuint indices[] = {
      0, 2, 1,
      0, 3, 2
   };

   float VerticesSquare[] = {
      -0.5f, 0.5f, 0.0f,
       0.5f, 0.5f, 0.0f,
       0.5f, -0.5f, 0.0f,
      -0.5f, -0.5f, 0.0f
   };
   printf("GLfloat variable called successfully\n");
   GLuint ShaderProgram = glCreateProgram();
   GLuint ShaderObjv = glCreateShader(GL_VERTEX_SHADER);
   GLuint ShaderObjf = glCreateShader(GL_FRAGMENT_SHADER);
   const GLchar* pvs[1];
   const GLchar* pfs[1];
   const char* pVertexShaderText = "#version 330\nlayout(location = 0) in vec3 Position;\nlayout(location = 1) in vec3 incolor;\nlayout(location = 2) in vec2 Tex;\nout vec3 outcolor;\nout vec2 texcoords;\nvoid main(){gl_Position = vec4(Position.x, Position.y, Position.z, 1.0);\noutcolor = incolor;\ntexcoords = Tex;}";
   const char* pFragmentShaderText = "#version 330\nuniform vec3 color;\nuniform sampler2D tex0;\nin vec3 outcolor;\nin vec2 texcoords;\nout vec4 FragColor;\nvoid main(){FragColor = texture(tex0, texcoords);}";
   pvs[0] = pVertexShaderText;
   pfs[0] = pFragmentShaderText;
   GLint LenghtsVertex[1];
   GLint LenghtsFragment[1];
   LenghtsVertex[0] = strlen(pVertexShaderText);
   LenghtsFragment[0] = strlen(pFragmentShaderText);
   glShaderSource(ShaderObjv, 1, pvs, LenghtsVertex);
   glShaderSource(ShaderObjf, 1, pfs, LenghtsFragment);
   glCompileShader(ShaderObjv);
   glCompileShader(ShaderObjf);
   GLint successvs;
   glGetShaderiv(ShaderObjv, GL_COMPILE_STATUS, &successvs);
   if (!successvs) {
       GLchar InfoLog1[1024];
       glGetShaderInfoLog(ShaderObjv, sizeof(InfoLog1), NULL, InfoLog1);
       fprintf(stderr, "Error compiling shader type %d: '%s'\n", GL_VERTEX_SHADER, InfoLog1);
   }
   GLint successfs;
   glGetShaderiv(ShaderObjf, GL_COMPILE_STATUS, &successfs);
   if (!successfs) {
       GLchar InfoLog2[1024];
       glGetShaderInfoLog(ShaderObjf, sizeof(InfoLog2), NULL, InfoLog2);
       fprintf(stderr, "Error compiling shader type %d: '%s'\n", GL_FRAGMENT_SHADER, InfoLog2);
   }
   glAttachShader(ShaderProgram, ShaderObjv);
   glAttachShader(ShaderProgram, ShaderObjf);
   glLinkProgram(ShaderProgram);
   glValidateProgram(ShaderProgram);
   glUseProgram(ShaderProgram);
   GLint uniColor = glGetUniformLocation(ShaderProgram, "color");
   GLint tex0uni = glGetUniformLocation(ShaderProgram, "tex0");
   glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);
   glUniform1i(tex0uni, 0);
   glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   GLuint VBO;
   GLuint VAO = 0;
   GLuint EBO;
   glGenBuffers(1, &VBO);
   glGenVertexArrays(1, &VAO);
   glGenBuffers(1, &EBO);
   glBindBuffer(GL_ARRAY_BUFFER, VBO);
   glBindVertexArray(VAO);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
   printf("Buffer created successfully\n");
   glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
   printf("Buffer data set up successfully\n");
   glEnableVertexAttribArray(0);
   glEnableVertexAttribArray(1);
   glEnableVertexAttribArray(2);
   printf("Enabling buffer successfull\n");
   glBindBuffer(GL_ARRAY_BUFFER, VBO);
   printf("Binding buffer successfull\n");
   int width, height, num;
   unsigned char* bytes = stbi_load("image.png", &width, &height, &num, 0);
   GLuint texture;
   glGenTextures(1, &texture);
   glActiveTexture(GL_TEXTURE0);
   glBindTexture(GL_TEXTURE_2D, texture);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
   float flatcolor[] = {1.0f, 1.0f, 1.0f, 1.0f};
   glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, flatcolor);
   printf("Set parameters successfully\n");
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, bytes);
   glGenerateMipmap(GL_TEXTURE_2D);
   printf("Texture set successfully\n");
   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
   printf("First pointer succeeded\n");
   glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
   printf("Second pointer succeeded\n");
   glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
   printf("Third pointer succeeded\n");
   printf("Setting up VectexAttribPointer successfull\n");

   while(!glfwWindowShouldClose(window)){
      glfwPollEvents();
      glClear(GL_COLOR_BUFFER_BIT);
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      //glDrawArrays(GL_TRIANGLES, 0, 3);
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
      GLenum err;
      if((err = glGetError()) != GL_NO_ERROR){
         printf("OpenGL error: %d\n", err);
      }
      glfwSwapBuffers(window);
   }
   return 0;
}

void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
   if(key == GLFW_KEY_R && action == GLFW_PRESS){
      glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);
   }else if(key == GLFW_KEY_G && action == GLFW_PRESS){
      glUniform3f(uniColor, 0.0f, 1.0f, 0.0f);
   }else if(key == GLFW_KEY_B && action == GLFW_PRESS){
      glUniform3f(uniColor, 0.0f, 0.0f, 1.0f);
   }
}

A: Solved! I had to add glPixelStorei(GL_UNPACK_ALIGNMENT, 1);, because of the odd resolution of the image. As far as I know it limits the bytes sent at the same time to only 1.

A: Your problem has nothing to do with the shader.
The cause are wrong texture coordinates here:
float Vertices[] = {
    -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
     0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
    -0.5f,  0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
     0.5f,  0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f
};

The x and y coordinates and the texture coordinates only match up in the first line.
This is the corrected version:
float Vertices[] = {
    -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
     0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
    -0.5f,  0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f,
     0.5f,  0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f
};


text:
Q: Improve performance of an update with sub-query My select below works fine although the performance is not good. And I think the problem might be that I repeat the sub-query below 9x and I'm sure that it can be improved.
I think the problem is that I repeat the following sub-query for each if the columns to update:
select top 1
    gestor_transac.XXXXXXX
from
    gestor_transac
where
    CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade)
    and gestor_transac.uid_producto = gestor_val_pos.uid_producto
    and id_cartera = @Arg_ID_cartera
order by
     gestor_transac.fecha_tran desc

Could anyone have a look at it?
update gestor_val_pos
set cantidad = (select top 1 gestor_transac.shabal
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        , coste_div_loc = (select top 1 gestor_transac.Coste_LOC_BAL
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
         ,  coste_div_car = (select top 1 gestor_transac.Coste_CAR_BAL
                          from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        ,  POS_cum_Inflows = (select top 1 gestor_transac.TRAN_Cum_inflows
                      from gestor_transac
                     where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        ,  POS_cum_Outflows = (select top 1 gestor_transac.TRAN_Cum_Outflows
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        ,  Descripcion = (select top 1 gestor_transac.descrpcion
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        , Custodio = (select top 1 gestor_transac.custodio
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        , Fecha_compra = (select top 1 gestor_transac.fecha_tran
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
        , Fecha_vencimiento = (select top 1 gestor_transac.fecha_vencimiento
                      from gestor_transac
                      where CONVERT(date,gestor_transac.fecha_tran) <= CONVERT(date,gestor_val_pos.fecha_trade) and gestor_transac.uid_producto= gestor_val_pos.uid_producto and id_cartera= @Arg_ID_cartera
                      order by gestor_transac.fecha_tran desc
                     )
                     where id_cartera= @Arg_ID_cartera and uid_producto= @Arg_UID_pr

A: From what I can tell, you want apply:
update gvp
    set cantidad = gt.shabal,
        . . .
    from gestor_val_pos gvp cross apply
         (select top (1) gt.*
          from  gestor_transac gt
          where convert(date, gt.fecha_tran) <= convert(date, gvp.fecha_trade) and
                gt.uid_producto = gvp.uid_producto and
                gt.id_cartera = @Arg_ID_cartera
          order by gt.fecha_tran
         ) gt;

Then you want an index on gestor_transac(uid_producto, id_cartera, fecha_tran).


text:
Q: Determine how long a phase takes, looking at current row and next row I am working on a project for work, data logging type system. Currently using SQL Server 2008, can upgrade if needed. Currently we are taking 1 minute intervals of the equipment, we are gathering all sorts of information, I am only worried about Time, and Step Number.
I am trying determine the length of time, the machine spends in a certain step before moving out. I have a way I am using that it currently works. However it takes to long to run. (5+ Hours)
I have a view set up currently that looks like this.
With Steps AS (SELECT        *, ROW_NUMBER() OVER (ORDER BY Time) AS RowNum
FROM dbo.Data_All)

SELECT        Steps.Time, Steps.[Production Step]
FROM            Steps INNER JOIN
Steps AS Y ON Steps.RowNum = y.RowNum + 1 AND
Steps.[Production Step] <> y.[Production Step]

Doing that gives me a breakdown, with time that it entered that step. This will take about 30 seconds to run, so not to bad. Realize we have over 250,000 records its looking through, and growing each day.
| Time            | Step #  |
-----------------------------
| 7-25-2014 14:32 | 11      |
| 7-25-2014 15:32 | 13      |
| 7-25-2014 15:40 | 14      |
| 7-25-2014 15:42 | 15      |
| 7-25-2014 15:50 | 8       |

I am then running a query based off that view, to get me, Step, Time, Next Step Time, and Duration. This is query is what is taking to long. So I am looking for a way to do this faster.
With CTE AS (select Time, Row_Numbers=ROW_NUMBER() Over (Order by Time),
[production step]  from Time_In_Step)

  Select [Current Row].[Production Step], [current row].Time,
[next row].Time AS [Next Step Time], Datediff(mi, [current row].Time,
[Next row].time) AS [Duration in Min]
  FROM CTE [Current Row]
  LEFT JOIN CTE [Next Row] ON
  [Next Row].Row_Numbers = [Current Row].Row_Numbers + 1

Doing this I get the following, which is what I want. Just a faster way to do it.
| Time            | Step #  | Next Step Time  | Duration in Min |
-----------------------------------------------------------------
| 7-25-2014 14:32 | 11      | 7-25-2014 15:32 | 60              |
| 7-25-2014 15:32 | 13      | 7-25-2014 15:40 | 8               |
| 7-25-2014 15:40 | 14      | 7-25-2014 15:42 | 2               |
| 7-25-2014 15:42 | 15      | 7-25-2014 15:50 | 8               |
| 7-25-2014 15:50 | 8       | Etc.....        | DateDiff

Anyone ideas on how to optimize this? Please let me know if you need any more ideas about what I am trying to do.

A: I would suggest using cross apply:
select c.[Production Step], c.Time,
       n.Time AS [n Step Time],
       Datediff(mi, c.Time, n.time) AS [Duration in Min]
from time_in_step c cross apply
     (select top 1 n.*
      from time_in_step n
      where c.time < n.time
     ) n;

An index on time would help the performance.

A: You could try the following:
select c.production_step,
       c.time,
       case when f.time = c.time then null else f.time end as next_step_time,
       datediff(mi, c.time, f.time) as dur_in_mins
  from time_in_step c
 cross join time_in_step f
 where f.time = (select min(x.time) from time_in_step x where x.time > c.time)
    or (not exists (select 1 from time_in_step x where x.time > c.time)
   and f.time = c.time)


text:
Q: XPages SSJS - Creating a Document in Another Database I get the error "Exception occurred calling method NotesDatabase.createDocument() null" for the following:
var db:NotesDatabase = session.getDatabase("", viewScope.targetDb);
if (db != null) {
   if(db.isOpen()){
   }else{
        db.open();
    }
} else {
}
var doc:NotesDocument = db.createDocument();

Comments:
The database db is available and "open".
The user has enough rights in the targetDb to create documents.
What is wrong?
I changed db.isOpen to db.isOpen(), according to Paul Stephen Withers tips.
And now db.open() gives the error "Exception occurred calling method NotesDatabase.open() null" although that I can get, in viewScope variables, the server, FilePath, etc.

A: Change
var db:NotesDatabase = session.getDatabase("", viewScope.targetDb);

to
var db:NotesDatabase = session.getDatabase(currentDatabase.getServer(), viewScope.targetDb);

This works on the web as well as XPinC.
 XPages isn't the same as formula, it doesn't like the empty string definition for the server name, which is contrary to the documentation which states (for the server parameter of NotesSession.getDatabase - javascript):]

The name of the server on which the database resides. Use null to
  indicate the session's environment, for example, the current computer

Using null or "" gives error 500, it would appear.

The code from the question will work, if :

*

*the if block is removed entirely

*the viewScope.targetDb variable has a properly specified notes database file path, which exists on the same server as the current database

*the current user has access to the target database ( by the ACL ), with the Create Database right

*the target database has a Maximum Internet name and password above Reader as per @Paul

A: I suspect the cause is you're checking db.isOpen. You should check db.isOpen().
Worth bearing in mind is session.getDatabase(String, String) doesn't return null (unless you're using OpenNTF Domino API). It returns a Database object that is not open. So that if statement is irrelevant. Also best practice is to pass a server name to session.getDatabase() - you'll get a different outcome if the application is ever used in XPiNC with your current code.
Regardless of individuals' user access, "Maximum Internet name and password" on the Advanced tab of the ACL will override that. If maximum internet access is No Access, no one will be able to create documents. But I suspect that's not a factor here.

A: Pro Tip -- Get the Debug Toolbar and use that to print out messages to the XPage debug toolbar to see what is going on and if your viewScope variable is being set.  Also, learn to use the try catch block to catch your exceptions and print out the error message to the debug toolbar. You will find your issue that way.
https://www.openntf.org/main.nsf/project.xsp?r=project/XPage%20Debug%20Toolbar


text:
Q: efficient ways to check prime number in Python Here is my code, and pretty brute force. Seeking smarter solutions. I remember there are some theory in Number Theory to check whether a number is a prime number with high efficiency, but cannot find it out. Anyone have smarter ideas are appreciated.
def isPrimeNumber(self, num):
    i = 2
    while (i <= num / 2):
        if num % i == 0:
            return False
        i = i + 1

    return True

thanks in advance,
Lin

A: One huge and simple optimization you can do to your code is to stop looking for divisors when you reach the square root of your num.

A: It's Improve performance. And loop occur till square root of this number
You can try this:
import math
def isPrimeNumber(self, num):
    for i in range(2, sqrt(num)):
        if num % i == 0:
            return False

    return True


text:
Q: Ionic2 / Angular 2 Platform import I am trying to learn ag2 with ionic 2 and trying most simple things.
I am trying to import platform and get necessary details iin my ionic 2 app.
I followed http://ionicframework.com/docs/v2/api/platform/Platform/
import {Platform} from 'ionic-angular';
@Component({...})
export MyPage {
  constructor(platform: Platform) {
    this.platform = platform;
  }
}

My code -
    import {Component} from '@angular/core';
    import {Platform} from 'ionic-angular';

    @Component({
      templateUrl: 'build/pages/items-map/items-map.html'
    })
    export class ItemsMap {

      constructor(platform: Platform) {
          this.platform = platform;
     }

btainNetworkConnection() {
    this.platform.ready().then(() => {
        this.networkState = navigator.connection.type;

        var states = {};
        states[Connection.UNKNOWN]  = 'Unknown connection';
        states[Connection.ETHERNET] = 'Ethernet connection';
        states[Connection.WIFI]     = 'WiFi connection';
        states[Connection.CELL_2G]  = 'Cell 2G connection';
        states[Connection.CELL_3G]  = 'Cell 3G connection';
        states[Connection.CELL_4G]  = 'Cell 4G connection';
        states[Connection.CELL]     = 'Cell generic connection';
        states[Connection.NONE]     = 'No network connection';

        alert('Connection type: ' + states[this.networkState]);
    });
  }

    }

NOw I am trying to build the codebase by gulp build and getting following output -
[00:06:26] Using gulpfile ~/Documents/Projects/Ionic2_1/MyIonic2Project/gulpfile.js
[00:06:26] Starting 'clean'...
[00:06:26] Finished 'clean' after 14 ms
[00:06:26] Starting 'build'...
[00:06:26] Starting 'sass'...
[00:06:26] Starting 'html'...
[00:06:26] Starting 'fonts'...
[00:06:26] Starting 'scripts'...
[00:06:26] Finished 'html' after 45 ms
[00:06:26] Finished 'scripts' after 43 ms
[00:06:26] Finished 'fonts' after 48 ms
[00:06:26] Finished 'sass' after 637 ms
TypeScript error: /Users/kray/Documents/Projects/Ionic2_1/MyIonic2Project/app/pages/item-map/items-map.ts(10,12): Error TS2339: Property 'platform' does not exist on type 'ItemsMap'.
[00:06:28] Finished 'build' after 2.28 s

I am getting a feeling that I am missing something basic here which I am not sure.
I also checked node_modules for platform related typescript files and they are present. Snapshot -

A: You need to define the variable platform in your Item map.
export class ItemsMap {

platform:Platform//my addition
  constructor(platform: Platform) {
      this.platform = platform;
 }

}

Or use typescript in build constructor shortcut to declare property like
export class ItemsMap {

    //notice modifier on constructor
      constructor(public platform: Platform){

     }

    }

You can see more info on Typescript class here

A: The private/public word is mandatory in the constructor when using Typescript:
constructor(private platform: Platform) {
      //...
 }

Also, you don't need to include the
this.platform = platform;

Because by just adding private platform : Platform in your constructor, that brief syntax does a lot:

*

*Declares a constructor parameter and its type

*Declares a private property of the same name

*Initializes that property with the
corresponding argument when we "new" an instance of the class


text:
Q: In Rails 5, can I construct a scope to get fields of my relation? I want to derive a field from a series of relations in my Rails 5 application (I want to know all the possible uniform colors associated with a player).  I have these models ...
class Player < ApplicationRecord
    ...
    belongs_to :team, :optional => true

class Team < ApplicationRecord
    ...
    has_many :uniforms, :dependent => :destroy

class Uniform < ApplicationRecord
    ...
    has_many :colors, :dependent => :nullify

I want to get all colors associated with the Player model, so I constructed this scope ...
class Player < ApplicationRecord
...
  scope :with_colors, lambda {
    joins(:team => { :uniforms => :resolutions })
  }

However, when I construct an object and attempt to reference the derived field with my scope, I get a method undefined error ...
[12] pry(main)> p.with_colors
NoMethodError: undefined method `with_colors' for #<Player:0x00007fa5ab881f50>

What's the proper way to access the field?

A: The models should look like:
class Player < ApplicationRecord
    ...
    belongs_to :team, :optional => true

class Team < ApplicationRecord
    ...
    has_many :players
    has_many :colors, through: :uniforms
    has_many :uniforms, :dependent => :destroy

class Uniform < ApplicationRecord
    belongs_to :team
    has_many :colors, :dependent => :nullify

class Color < ApplicationRecord
    belongs_to :uniform

Note that the Team has_many :colors, through: :uniforms. This way you can just call @player.team.colors and get all the available colors that uniforms of a team have.
More details on has_many through https://guides.rubyonrails.org/association_basics.html#the-has-many-through-association


text:
Q: left Join with right table filtered for every rows I have two tables:

*

*Customer: customer_id

*Order: order_id, customer_id, createdAt

I want to retry for every customer the only last order.
I tried to do this:
    SELECT C.customer_id, ORD.*
    FROM "Customer" as C
    LEFT JOIN (
            SELECT "Order".customer_id, "Order".order_id, "Order"."createdAt"
            FROM "Order", "Customer"
            WHERE "Order".customer_id = "Customer".customer_id
            ORDER BY "Order"."createdAt" DESC limit 1
    ) ORD ON C.customer_id = ORD.customer_id

but the result is:

Customer.customer_id
Order.order_id
createdAt

1
null
null

2
null
null

3
123
2022-03-04

The result is correct only for a customer. I lose the information of the others.
I also tried to do this:
    SELECT  C.customer_id, ORD.*
    FROM    "Customer" as C
    LEFT JOIN "Order" as ORD
    ON ORD.customer_id = (
                    SELECT  ORD.customer_id
                    FROM    "Order" as ORD
                    WHERE   ORD.customer_id = C.customer_id
                    ORDER BY
                                    ORD."createdAt" DESC limit 1
                    )

the result in this case is:

Customer.customer_id
Order.order_id
createdAt

1
119
2022-01-04

2
120
2022-01-04

3
123
2022-03-04

3
121
2022-02-04

I have more information about customer 3, when I just need the row where order_id is 123.
I've been working on it for a couple of days, could someone help me? Thanks so much.

A: You want the most recent order for each customer. But the LIMIT 1 in your subquery means you only get the single most recent order (for any customer).
Let's work out a subquery to get the most recent order for each customer. Start with the date of each customer's most recent order.
            SELECT customer_id, MAX(createdAt) createdAt
              FROM ORD
             GROUP BY customer_id

Then let's do an inner join to that subquery. This should get us the detail of the latest order for each customer. Test it to convince yourself it works properly.
        SELECT ORD.*
          FROM ORD
          JOIN (
                SELECT customer_id, MAX(createdAt) createdAt
                  FROM ORD
                 GROUP BY customer_id
               ) latest ON ORD.customer_id = latest.customer_id
                       AND ORD.createdAt = latest.createdAt

That's the subquery to use in place of the one you have.
SELECT C.customer_id, ORD.*
FROM "Customer" as C
LEFT JOIN (
        SELECT ORD.*
          FROM ORD
          JOIN (
                SELECT customer_id, MAX(createdAt) createdAt
                  FROM ORD
                 GROUP BY customer_id
               ) latest ON ORD.customer_id = latest.customer_id
                       AND ORD.createdAt = latest.createdAt
    ) ORD ON C.customer_id = ORD.customer_id

This sort of thing probably works on multiple database vendors.

A: Use this query.. Hope it will cover your requirement.
select
  cust.customer_id,
  max(ord.order_id) AS order_id,
  max(ord.createdAt) AS createdAt
from Customer as cust
join "Order" ord on cust.customer_id = ord.customer_id
group by cust.customer_id;

A: Your derived table (subquery in the from clause) only selects one row. Your are using a join syntax here that got deprecated in the early 1990s. Here is your subquery with an up-to-date syntax:
select o.customer_id, o.order_id, o.createdat
from "Order" o
join customer c on c.customer_id = o.customer_id
order by o.createdat desc
limit 1;

Or shorter without the superfluos join:
select customer_id, order_id, createdat
from "Order"
order by createdat desc
limit 1;

In your main query you join this to your customer table and the one row that the subquery produces does get joined. It's just not what you actually intended.
One way to get the last order per customer is by using a window function such as ROW_NUMBER OVER or MAX OVER:
select c.customer_id, ord.*
from customer as c
left join
(
  select
    o.*,
    row_number() over (partition by order_id order by createdat desc) as rn
  from "Order" o
) ord on ord.customer_id = c.customer_id and ord.rn = 1
order by c.customer_id;

Here is another approach using a fetch with ties clause:
select c.customer_id, ord.*
from customer as c
left join
(
  select *
  from "Order"
  order by row_number() over (partition by order_id order by createdat desc)
  fetch first row with ties
) ord on ord.customer_id = c.customer_id
order by c.customer_id;

And here is the same with a lateral join:
select c.customer_id, ord.*
from customer as c
left join lateral
(
  select o.*
  from "Order" o
  where o.customer_id = c.customer_id
  order by o.createdat desc
  fetch first row only
) ord on true
order by c.customer_id;


text:
Q: Theme Customizer for only author.php (per user baisi) How can the Wordpress Theme Customizer be used only for author.php and settings will be saved per user basis. By which every user can customize their own author.php.
How can it be achieved?

A: First, you will need to generate customizer settings depending on the current user. So there are two conditions to be met: the setting must only be accessible to the current user and this setting must be unique to him.
// Only do this for contributors and up
if (current_user_can('edit_posts')) {
   // retrieve author id
   global $current_user;
   get_currentuserinfo();
   $author_id = $current_user->ID
   // generate customizer setting for this author only
   $wp_customize->add_setting( 'header_color_' . $author_id , array(
     'default' => '#000',
     'sanitize_callback' => 'sanitize_hex_color',
     'capability' => 'edit_posts',
     ));

In (the heading of) your author.php you will need to get the id of the author of the current page to retrieve the relevant mod.
$author_id = get_the_author_meta('ID');
get_mod('header_color_' . $author_id);


text:
Q: Adding/Updating to a SharePoint List with AJAX securely? I'm creating a Site Definition that will have a Stack Overflow like Q/A system.
I'm hung up on the upvote/downvote system.
I see a number of ways to do this, but what I think works best is to have a Profiles list, and store the vote state of each user in a text column, in a sort of JSON like format.
{12445:0}{13478:1}
0 being a downvote, 1 being an upvote. The number indicates the ID of the List item being voted upon.
The reason I don't want to have an Upvote/Downvote list, is this could end up being a SUBSTANTIAL list to create, call and organize. This way, when a user loads the page, I get all of his vote history in a parseable string and can search for matches on the page to indicate his voting history.
What I'm hung up on is the vulnerability of exposing the list to AJAX calls. I can imagine a situation where a post gets voted into prominence by a user adding {14509:1} to as many profiles as possible.
I understand that even if I don't build the voting system around AJAX, a sophisticated user could write that kind of code and inject it anyways.
Is there a way to lock down a list to all users, and put the upvote/downvote code in an update panel that still executes server side?

A: How sophisticated are your users? Realistically these sorts of systems are always going to be vulnerable to fixing/gaming. Also storing the voting history against each user doesn't sound very scalable to me. You will end up doing an awful lot of processing to generate any page.
Why not keep the voting essentially anonymous but keep in ASP.NET cache a value which tracks the fact a user has already voted for that particular page. Looking up the user/page combo in cache is quick and light and would prevent multiple calls.
It would likely disappear from cache after a while, say until next app pool reset but then the user would need to repeatedly call every day for a few days to make any sort of difference. Then you just need to track a vote score on the page itself. Much simpler.


text:
Q: What is the word for adjectives like 'correct' which may not provide complete meaning without previous sentence? While working on my project, I came across this sentence:

Obi is correct

My question is can we say that 'correct' in the above sentence defines the state of a man, since is is a form of 'be' - which usually defines the state of the subject or existence of the object.
If yes, can we say 'correct' is a special type of adjective, since a man cannot normally be described as 'correct' or in a 'correct' state.
Are there any other examples of such adjectives?

A: The terms endophora and exophora are relevant to the question asked in the title,

What is the word for adjectives like 'correct' which may not provide complete meaning without previous sentence?

Of exophora, Wikipedia says

In linguistic pragmatics, exophora is reference to something extralinguistic, i.e. not in the same text, and contrasts with endophora. Exophora can be deictic, in which special words or grammatical markings are used to make reference to something in the context of the utterance or speaker. For example, pronouns are often exophoric, with words such as "this", "that", "here", "there", as in that chair over there is John's said while indicating the direction of the chair referred to.

Of endophora, Wikipedia says

Endophora is an expression that refers to something in the same text.
  For example, in the sentences "I saw Sally yesterday. She was lying on the beach", "she" is an endophoric expression because it refers to something already mentioned in the text, i.e. "Sally".
By contrast, "She was lying on the beach," if it appeared by itself, has an exophoric expression; "she" refers to something that the reader is not told about. That is to say, there is not enough information in the text to independently determine to whom "she" refers. It can refer to someone the speaker assumes his audience has prior knowledge of or it can refer to a person he is showing to his listeners. Without further information, in other words, there is no way of knowing the exact meaning of an exophoric term.

In short, an adjective that depends  for meaning on a previous sentence is used exophorically.
Also note the word  deictic in the explanation of  exophora.   Deictic means "Of or pertaining to deixis; to a word whose meaning is dependent on context".  Deixis means  "(linguistics) A reference within a sentence that relies on the context being known to interpret correctly".


text:
Q: Android: Activity not starting from a widget I am trying to launch an activity from a home screen widget. However, the activity is not starting when I click the widget. Below is my code.
@Override
public void onReceive(Context context, Intent i) {

    AppWidgetManager mgr = AppWidgetManager.getInstance(context);

    Intent intent = new Intent(context, MyActivity.class);
    PendingIntent pendingLayout = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widgetlayout);

    views.setOnClickPendingIntent(R.id.widget, pendingLayout);

    ComponentName comp = new ComponentName(context,
            RecentTaskWidget.class.getName());

    mgr.updateAppWidget(comp, views);
}

Thx!
Rahul.

A: You need to use PendingIntent.getActivity() instead of PendingIntent.getService(), probably this is why your code is not working. Hope this helps.


text:
Q: How do I loop excel sheet names inside quotes in GAMS 'GDXXRW? I would like to define a string set in GAMS to loop to read different xlsx sheet names in gdxxrw. However, I didn't find the appropriate code in the help documentation using string formatting and String Substitution as keywords.
'''
SET
sheets /index1, index2, index3/
B /a, b, c/
;

PARAMETER
POP0(B)
POP(B)
;
LOOP(sheets,
* Write Excel data to GDX
put_utility 'exec' / 'gdxxrw.exe Input.xlsx se=0 index='sheets.tl'!a1';
$Load POP0
POP(B)=POP0(B);
execute_unload "Output.gdx"
POP
* Write GDX data to excel
  put_utility 'exec' / 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx index='sheets.tl'!a7';

'''
I read loop in GAMS for scenario generation in excel. But GAMS report error as that
'''
116  Label is unknown
141  Symbol declared but no values have been assigned. Check for missing
        data definition, assignment, data loading or implicit assignment
        via a solve statement.
        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
300  Remaining errors not printed for this line
352  Set has not been initialized
353  The domain for this index position is unknown and the element
        cannot be checked at this point. Missing data statement.
502  GDXIN  file not open - ignore rest of line
509  Dollar control statements are processed during compilation
        and NOT during execution. The use of dollar statements
        that change data may be misleading when inside a LOOP
        or IF statement.

'''
I think the key is the apply of $Load or $loaddc. Does GAMS have a string formatting method control index sheet in quotes?

A: After a night of debugging, I finally solved the problem.
'''
SET
sheets /index1, index2, index3/
B /a, b, c/
;

PARAMETER
POP0(B)
POP(B)
;
LOOP(sheets,
* Write Excel data to GDX
put_utility 'exec' / 'gdxxrw.exe Input.xlsx se=0 index='sheets.tl:0'!a1';
*":0" is needed
* Load data from GDX (substitution of $load)
  execute_load 'data.gdx',
POP0
;

POP(B)=POP0(B);
* Load data from GDX
execute_unload "Output.gdx",
POP
;
* Write GDX data to excel
put_utility 'exec' / 'gdxxrw.exe RESULT.gdx o=RESULT.xlsx index='sheets.tl:0'!a7';

'''
Very thank Lutz!