text:
Q: Docker Publish Option I am attempting to get a Vue app running locally inside a Docker container and having an issue publishing to a specified port.
Here is my Dockerfile
FROM node:lts-alpine

RUN mkdir -p /app
COPY . /app
WORKDIR /app

RUN npm install
RUN npm run build

EXPOSE 3000

CMD ["npm", "start"]

In the root directory of my project I run
docker build --tag projectname .

This successfully creates an image which I should be able to run in a container.
However, whenever I run the following command I am unable to access the container from my browser at any port.
docker run -p 3000:3000 --name projectname projectname

The output shows some recommendations on splitting code to reduce size, but there are no errors, and it states that I should be able to access the app from http://localhost:8080, but that page provides a connection refused error.
I am under the impression that the publish option should listen on the exposed port 3000 and forward traffic to local port 3000.
However, this doesn't appear to be happening.
I am running Docker for Windows which might also be part of the problem.

A: Try running this command docker run -p 3000:8080 --name projectname projectname and then access the app at localhost:3000 on the docker host machine.
If this works, then either update in your Dockerfile the EXPOSE 3000 into EXPOSE 8080, or start your http server on port 3000 instead of 8080 inside your app. This second step is optional, but it will help other folks understand that the containers launched from that image are supposed to be listening on the port that is mentioned in the Dockerfile.


text:
Q: Selectable rows in a table generated with php I've already searched the site for answers, but I couldn't adapt the code provided for other people to mine.
I have a table generated by PHP using mysql queries, I'd like to make the rows selectable (the whole rows only, and no multi-selection) and extract the value of "CodPezzi" from the selected row for further usage:
This is my table

    Codice
    Tipologia
    Costruttore
    Macchinario
    Quantità

        <?php
        $result=$ SSide->query($sql);
        while($row = mysqli_fetch_assoc($result)) {
            echo " <tr ".$row['CodPezzi']."	". "
                ".$row['Tipologia']."	". "
                ".$row['Macchinario']."	". "
                ".$row['Costruttore']."	". "
                ".$row['sum(Quantita)']."

";
        }
        ?>

I don't want to have the header selectable. Can you provide me a slim code that allows me to do what I want to do?
Edit
This is what I tried before coming here:
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">

            Codice
            Tipologia
            Costruttore
            Macchinario
            Quantità

                <?php
                $result = $SSide->query($sql);
                while($row = mysqli_fetch_assoc ($result)){
                    echo "
 <li ".$row['CodPezzi']."
".
                        "
".$row['Tipologia']."	 ".
                        "
".$row['Macchinario']."
".
                        "
".$row['Costruttore']."
".
                        "
".$row['sum(Quantita)']."

";
                }?>

and also

        Codice
        Tipologia
        Costruttore
        Macchinario
        Quantità

          <?php $result=$ SSide->query($sql); while($row = mysqli_fetch_assoc ($result)){ echo "

            ".$row['CodPezzi']."	". "
            ".$row['Tipologia']."	". "
            ".$row['Macchinario']."	". "
            ".$row['Costruttore']."	". "
            ".$row['sum(Quantita)']."

"; }?>

The rows become highlightable on mouse over, but not selectable.

A: StackOverflow is not a place to ask people to write code for you, but I can point you towards a solution:
When you create your table rows
echo "

   ".$row['CodPezzi']."	". "
   ".$row['Tipologia']."	". "
   ...";

You can include ids and classes like this:
while($row = mysqli_fetch_assoc ($result)){
echo "

   ".$row['CodPezzi']."	". "
   ".$row['Tipologia']."	". "
   ...";

Then you catch the relevant events in jquery:
$("tr.selectableRow").hover(
  function () {
    $(this).css("background","blue");
  },
  function () {
    $(this).css("background","");
  }
);

$("tr.selectableRow").click(function () {
       //
    );

This should help you get on the right track.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does this statment return true Why does this statement,
    if (! $ssh_options{user}) {

    delete $ssh_options{user};

}

return true, but this statement
    if ($ssh_options{user} eq 'undef') {

    delete $ssh_options{user};

}

give me the error,
Use of uninitialized value $ssh_options{"user"} in string eq at analyze.pl line 230.

I thought you always had to have something for perl to compare the value of the variable being compared.
** Update **
@ Quick Joe Smith
I cannot base my comparison on whether the hash keys exist or not because the values for this hash
sub ssh_connect {

my $host = shift;

my %ssh_options = (

    port => shift,
    user => shift,
    password => shift

    );

Come from this function which calls the sub routine
        if ((exists $config_file{user}) && (exists $config_file{password})) {

        my $vmware_user = $config_file{user};

        my $vmware_password = $config_file{password};

        ssh_connect($vmware_host, $vmware_port, $vmware_user, $vmware_password);

    } else {

        ssh_connect($vmware_host, $vmware_port);

    }

A: Use exists for checking hash keys.
if (exists $ssh_options{user}) {
    ...
}

However, in your case, it seems as though you're checking for existing keys whose values may be undefined, in which case:
if (defined $ssh_options{user}) {
    ...
}

The above may be what you want.

As a sidenote, checking to see if the value of any variable is defined in the way you described:
if ($something eq 'undef') {
    ...
}

Is wrong. You're checking to see if the variable contains the string "undef". What you need in those situations is:
unless (defined $something) {
    ...
}

A: Perl hash slots have a number of ways they can be false.  If the key has never been filled, the exists function will return false.  If the key exists but contains an undefined value, exists will be true but the defined function will return false. In normal boolean context, as given by an if statement, a hash key that was never filled, or is undefined,  '', 0 or anything that reduces to those will be false.
From your update, it sounds like what you want is to use defined
delete $ssh_options{user} unless defined $ssh_options{user};

A: But if $ssh_options{"user"} is uninitialized then it it doesn't have a value to compare to.

A: With Perl, undefined evaluates to false in Boolean context.  So your first test 'works' as you expect.  However, it might introduce a bug if zero or an empty string is a legitimate value for $ssh_options{user} to hold, if you don't wish to treat that the same as undef.  That's because your first test doesn't differentiate between false as a value, and false as undefined.  As far as Perl's Boolean evaluation goes, all of the following are "false": 0, '' (empty string), undef, or an empty list.
Your second snippet of code fails because undef should be a bareword, not a quoted string.  'undef' as a quoted string IS a value, which would actually evaluate to 'true' in Boolean tests.  Because you're comparing an actual value to your hash element, Perl warns you that you're comparing something to an undefined value.  In this case, the undefined value is $ssh_options{user}.  It's actually good that Perl is warning you; it's given you a clue as to what you're doing wrong.
If you really want to test whether $ssh_options{user} is defined, use the defined() function.  If you want to test whether $ssh_options{user} exists, use the exists() function.


text:
Q: How do I get list of stocktwit watchlists of an user in jquery I want to retrieve a list of all watch lists created by a user to show in my custom MVC4 application.
I could authenticate the user and could also get the watchlist feed if I knew the watchlistid. In our application, we want the user to select his existing watchlist to show the feed.

A: You will need to authenticate the user. Once this is done you can use the access token and call the https://api.stocktwits.com/api/2/watchlists.json endpoint.
Here is the documentation on this:http://stocktwits.com/developers/docs/api#watchlists-index-docs
This will give you the list of watch lists the user has and then you can use the ID to call the watch list stream.

A: Starting from nowhere in Stocktwits, I found this document incredibly helpful:
http://stocktwits.com/developers/docs/signin
Once you've gotten the flow going, replace the AJAX call to something more like this
$.ajax({
        url: "https://api.stocktwits.com/api/2/watchlists.json?callback=?",
        dataType: 'jsonp',
        timeout: 5000,
        data:{ access_token: token},
        success: function(data) {
           if (data) {
           callback(data);
         }},
        error: function(error){
         //handle error
         }

Now we have a watchlist. After that, you want to write a callback function to use the data you just obtained:
var getWatchlist = function(data){
    if(!data) return undefined;     //Sanity checks are always good!
    if(data.response == undefined) return undefined;

      var postInfo = [];  //A list to put our results on!

  if(data.response.status == "401") { //Represents a bad token. Handle and return
     return;
  }
  var watchlistData = data.watchlists;
  for (var i=0; i<watchlistData.length; i++)
  {
    var watchlistId = watchlistData[i].id;

    var tempInfo = {watchlistId};
    postInfo.push(tempInfo);
  }
return postInfo;    //All of your watchlists!
}

From here, use the similar function described here:
http://stocktwits.com/developers/docs/api#watchlists-show-docs
$.ajax({          //Note you have to put in the watchlist_id
        url: "https://api.stocktwits.com/api/2/watchlists/show/"+watchlist_id+".json?callback=?",
        dataType: 'jsonp',
        timeout: 5000,
        data:{ access_token: token},
        success: function(data) {
           if (data) {
           callback(data);
         }},
        error: function(error){
         //handle error
         }

Do the same sort of thing again with a different callback:
var getWatchlistData = function(data){
    if(!data) return undefined;    //Sanity is still important, for some....
    if(data.response == undefined) return undefined;

     var postInfo = [];  //A list to put our results on!

  if(data.response.status == "401") { //Represents a bad token. Handle and return
     return;
  }
  var watchlistSymbolsData = data.watchlists.symbols;
  for (var i=0; i<watchlistSymbolsData.length; i++)
  {
    var watchlistTicker = watchlistData[i].symbol;
            var watchlistId = watchlistData[i].id;
    var tempInfo = {watchlistTicker, watchlistId};    //You'll probably want some more data here
    postInfo.push(tempInfo);
  }
return postInfo;    //All of your tickers with corresponding ids!
}

Simply make a function to call the AJAX, pass in one of those get functions as the callback, and you'll be well on your way to being able to display anything you'd like.


text:
Q: CSS selectors - how to target specific items I'm using grunticon to embed a different svg from a sprite sheet for each span with an .icon class.
I'm having trouble with the css selectors:

Title

                Title 1

                Title 2

                    Title 3

I've tried:
.section li:nth-of-type(1) .icon
.section li:nth-of-type(2) .icon
.section li:nth-of-type(3) .icon
but they are incorrect and using nth-of-type has performance implications. I have to target the .icon class and I can't use ids. The process is to add each selector to another encoding file which is configured to generate the svgs.
I'm not sure how to be more specific with the limited elements and restrictions. Any pointers would be great.

A: So, you need to target each .icon element separately, but don't want/can't use nth-of-type. You can try:
.section li .icon.svg-icon-1{}
.section li .icon.svg-icon-2{}

@edit
.section li:nth-of-type(1) .icon works for me.
Demo


text:
Q: Code to choose 5.000 numbers in 10.000 randonly I would like some help to make a code in awk that within 10,000 records would randomly choose 5,000.

A: Sort has a randomizer.
Assuming an input filename of 10k,
sort -R 10k | head -5000 > 5k # write selections to "5k"

A: The following method works for single as well as multi-line records or records with specific record-separators.
Define a script random_subset.awk
# Uniform(m) :: returns a random integer such that
#    1 <= Uniform(m) <= m
function Uniform(m) { return 1+int(m * rand()) }

# KnuthShuffle(m) :: creates a random permutation of the range [1,m]
function KnuthShuffle(m,   i,j,k) {
    for (i = 1; i <= m  ; i++) { permutation[i] = i }
    for (i = 1; i <= m-1; i++) {
        j = Uniform(i-1)
        k = permutation[i]
        permutation[i] = permutation[j]
        permutation[j] = k
    }
}

BEGIN{ srand() }
{a[NR]=$0}
END{ KnuthShuffle(NR); for(r = 1; r <= count; r++) print a[permutation[r]] }

Then you can run it as:
$ awk -v count=5000 -f subset.awk inputfile > outputfile

Or if you have a file where the record separator is given by a character like @, then you can do:
$ awk -v count=5000 -v RS='@' -v ORS='@' -f subset.awk inputfile > outputfile

If you want to select random paragraphs, you can do:
$ awk -v count=5000 -v RS='' -v ORS='\n\n' -f subset.awk inputfile > outputfile


text:
Q: Unity 5 does not create new scene I'm newbie to Unity 5 and I have problem with creating new scenes.  After creating a project ,I go to File->New Scene but the scene does not appear at all so I can't do anything with it ! Here's the image from what I see in Unity:

A: Your new scene is there. Your layout is likely messed up.

Click on the Default in the image above(where red arrow points to) then click Default. It should reset everything to normal. You can press Control + S to actually save the scene.

A: Hit Layout in the top right corner, select "2 by 3"
You will see your scene and game view quickly that way.

A: Have you enabled the scene view and switched to it?
Maybe you are viewing the game view. There is nothing in the scene so nothing will be displayed in game view.


text:
Q: Loading an excel(.xlsx/.xls) file from maven project resources folder (src/main/resources) Here i am trying to load an excel file from resources folder(src/main/resources) of a maven project.
Folder Structure
MyWebApp
   |______src/main/java
   |           |____Test.java
   |
   |______src/main/resources
   |            |______test
   |                    |___hello.properties
   |                    |___template.xlsx
   |______target
            |___MyWebApp
                  |____WEB_INF
                         |___classes
                                |__test
                                     |__hello.properties
                                     |__template.xlsx

My Approach
//loading excel file
String resource = "/test/template.xlsx";
System.out.println(this.getClass().getResource(resource) == null); // prints true

//loading properties file
String resource = "/test/hello.properties";
System.out.println(this.getClass().getResource(resource) == null); //prints false

//I have also tried below methods
this.getClass().getClassLoader().getResourceAsStream(resource); //null
new ClassPathResource(resource).getInputStream(); //null

After doing some googling i came to know, maven filters binary contents. To over come that i modified my pom.xml to allow .xlsx,.xls file extenstions not to be filtered with this help.
pom.xml
<configuration>
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <resources>
            <resource>
                 <directory>${basedir}/src/main/resources</directory>
                     <includes>
                         <include>**/*.xlsx</include>
                         <include>**/*.xls</include>
                     </includes>
             </resource>
         </resources>
</configuration>

I could able to load the properties file, but i could not able to load the excel file by using above approach. From my side i referred the below two links (Rererence-1,
Reference-2) but no success. Please help me if you have some thoughts/ideas on this issue.

A: In the maven documentation page which you've linked in your there is said:

If you have both text files and binary files as resources it is
  recommended to have two separated folders. One folder
  src/main/resources (default) for the resources which are not filtered
  and another folder src/main/resources-filtered for the resources which
  are filtered.

So you should hold the properties and xlsx files in separate directories.
There is also an information about excluding binary files from filtering:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
      ...
      <nonFilteredFileExtensions>
        <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
        <nonFilteredFileExtension>swf</nonFilteredFileExtension>
      </nonFilteredFileExtensions>
      ...
    </configuration>
 </plugin>


text:
Q: Sorting Arraylist created using Generic Class in Java I have created a class called Pair which is a generic type of L and R which would basically allow me to store pairs.
I am using an Arraylist to store the type Pair but I am not sure how to sort (and potentially search all elements) the arraylist based on the key/value and also print the ArrayList.
    ArrayList<Pair> a = new ArrayList<Pair>();

    Pair p = new Pair(1,1);
    a.add(p);
    a.add(new Pair(1,3));

    //System.out.println(help please);

Below is the Pair Class
class Pair<L,R> {

        L left;
        R right;

      public Pair(L left, R right) {
        this.left = left;
        this.right = right;
      }

      public L getLeft() { return left; }
      public R getRight() { return right; }

      @Override
      public int hashCode() { return left.hashCode() ^ right.hashCode(); }

      @Override
      public boolean equals(Object o) {
        if (!(o instanceof Pair)) return false;
        Pair pairo = (Pair) o;
        return this.left.equals(pairo.getLeft()) &&
               this.right.equals(pairo.getRight());
      }

    }

A: Your Pair class could for example implement Comparator<Pair> interface. After that you implement the method
@Override
public int compare(Pair o1, Pair o2) {
    // here you need to implement how one Pair can be compared to another
    // in the scope of ordering them
    // you need to fulfil the contract of the Comparator.compare interface
}

A: Here's a working code example for you (it's using some Java 8 features but these can be swapped out if you're restricted to a lower version).  Hope this helps!
Thanks,
Duncan
package com.hiveit;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Pair<L extends Comparable<L>, R extends Comparable<R>> implements Comparable<Pair<L, R>> {

  L left;
  R right;

  public Pair(final L left, final R right) {
    this.left = left;
    this.right = right;
  }

  public L getLeft() {
    return left;
  }

  public R getRight() {
    return right;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + (left == null ? 0 : left.hashCode());
    result = prime * result + (right == null ? 0 : right.hashCode());
    return result;
  }

  @Override
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Pair<?, ?> other = (Pair<?, ?>) obj;
    if (left == null) {
      if (other.left != null) {
        return false;
      }
    } else if (!left.equals(other.left)) {
      return false;
    }
    if (right == null) {
      if (other.right != null) {
        return false;
      }
    } else if (!right.equals(other.right)) {
      return false;
    }
    return true;
  }

  @Override
  public int compareTo(final Pair<L, R> other) {

    final int compareLeft = left.compareTo(other.left);

    if (compareLeft != 0) {
      return compareLeft;
    }

    return right.compareTo(other.right);
  }

  @Override
  public String toString() {
    return "Pair [left=" + left + ", right=" + right + "]";
  }

  public static String listToString(final List<?> list) {
    return list.stream().map((pair) -> {
      return pair.toString();
    }).collect(Collectors.joining(", "));
  }

  public static void main(final String[] args) {

    final List<Pair<Integer, Integer>> a = new ArrayList<>();

    a.add(new Pair<>(1, 1));
    a.add(new Pair<>(2, 1));
    a.add(new Pair<>(2, 3));
    a.add(new Pair<>(1, 2));
    a.add(new Pair<>(1, 3));
    a.add(new Pair<>(2, 2));

    final List<Pair<Integer, Integer>> sortedByKey = new ArrayList<>(a);
    sortedByKey.sort((o1, o2) -> {
      return o1.getLeft().compareTo(o2.getLeft());
    });

    sortedByKey.stream().map((pair) -> {
      return pair.toString();
    }).collect(Collectors.joining(", "));

    final List<Pair<Integer, Integer>> sortedByValue = new ArrayList<>(a);
    sortedByValue.sort((o1, o2) -> {
      return o1.getRight().compareTo(o2.getRight());
    });

    final List<Pair<Integer, Integer>> sortedByKeyAndValue = new ArrayList<>(a);
    sortedByKeyAndValue.sort((o1, o2) -> {
      return o1.compareTo(o2);
    });

    System.out.println("Original                  = " + listToString(a));
    System.out.println("Sorted by Left            = " + listToString(sortedByKey));
    System.out.println("Sorted by Right           = " + listToString(sortedByValue));
    System.out.println("Sorted by Left then Right = " + listToString(sortedByKeyAndValue));

  }
}

A: The Collections API provides are sort utility for this.
http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html
You simply need to write a class to implement a Comparator for your Pair class.

A: Don't use your Pair class. If what you need is a sorted, traversable and efficient collection of key/value pairs with generic types use a TreeMap.


text:
Q: How does convergence imply continuity? I have a problem:

Let $M$ and $N$ be metric spaces and let $f : M \rightarrow N$ be a map. Show that $f$ is continuous if an only if it takes convergent sequences to convergent sequences and limits to limits, that is, if and only if $x_i \rightarrow x $ in $M$ implies $f(x_i) \rightarrow f(x) $ in $N$.

I don't really understand what convergence has to do with continuity. In an effort to understand this better I've come up with a counterexample.
$$f : \mathbb{R} \rightarrow \mathbb{R}\\f(x) = 2x+IntegerPart[x]$$
Let:
$$x_i= \sum\limits_{n=0}^i  ( \frac{4}{5})^n  $$
Thus when $x_i \rightarrow 5, f(x_i) \rightarrow f(5)=15$. $f$ is not continuous at 5, but it seems to be converging.
The chart blow shows the $x_i$ sequence in red and the $f(x_i)$ sequence in green:

How does convergence imply continuity?

A: Two things here.
Your "counterexample" isn't a counterexample: $f(x_i) \to 14$, not 15. Indeed, if $x_i < 5$ then $2 x_i + \text{Int}(x_i) < 10 + 4 = 14$.
Secondly, even if it did converge to the right thing (15), that still wouldn't be enough to show that the function wasn't continuous. Continuous iff all sequences have $f$ tending to the right thing, and discontinuous iff some sequence has $f$ tending to the wrong thing. Showing that one sequence tends to the right thing tells you nothing.

A: Well you can start by contradiction.
Assume f is not continuous at some point $x_0$. This implies $f(B_\delta(x_0))$ is not contained in $B_\epsilon(f(x_0))$. Now consider the sequence $$\{x_n\}= (B_1(x_0), B_1/2(x_0),\cdots,B_1/n(x_0),...)$$ You can see that this $\{x_n\}$ converges to $x_0$ but $f(x_n)$ does not converge to $f(x_0)$. This breaches what we had said
in the contradiction.
Hence proved


text:
Q: transform 3x3 OpenCV Mat to Android Matrix I got a 3x3 matrix in OpenCV format (org.opencv.core.Mat) that I want to copy into android.graphics.Matrix. Any idea how?
[EDIT]
Here's the final version as inspired by @elmiguelao. The source matrix is from OpenCV and the destination matrix is from Android.
static void transformMatrix(Mat src, Matrix dst) {

    int columns = src.cols();
    int rows = src.rows();

    float[] values = new float[columns * rows];
    int index = 0;
    for (int x = 0; x < columns; x++)
        for (int y = 0; y < rows; y++) {
            double[] value = src.get(x, y);
            values[index] = (float) value[0];

            index++;
        }

    dst.setValues(values);
}

A: Something along these lines:
cv.Mat opencv_matrix;
Matrix android_matrix;
if (opencv_matrix.isContiguous()) {
    android_matrix.setValues(cv.MatOfFloat(opencv_matrix.ptr()).toArray());
} else {
    float[] opencv_matrix_values = new float[9];
    // Undocumented .get(row, col, float[]), but seems to be bulk-copy.
    opencv_matrix.get(0, 0, opencv_matrix_values);
    android_matrix.setValues(opencv_matrix_values);
}

A: This function also respects the Mat's data type (float or double):
static Matrix cvMat2Matrix(Mat source) {
    if (source == null || source.empty()) {
        return null;
    }
    float[] matrixValuesF = new float[source.cols()*source.rows()];

    if (CvType.depth(source.type()) == CvType.CV_32F) {
        source.get(0,0, matrixValuesF);
    } else {
        double[] matrixValuesD = new double[matrixValuesF.length];
        source.get(0, 0, matrixValuesD);
        //will throw an java.lang.UnsupportedOperationException if type is not CvType.CV_64F
        for (int i=0; i<matrixValuesD.length; i++) {
            matrixValuesF[i] = (float) matrixValuesD[i];
        }
    }

    Matrix result = new Matrix();
    result.setValues(matrixValuesF);
    return result;
}


text:
Q: Visual Studio products version compatibility (eg. express, ultimate) I would like to use two scenarios:
In first I would like to mix Visual Studio Community and Visual Studio 2015 Professional.
In second scenario I would like to mix Visual Studio 2013 Express and Visual Studio 2013 Ultimate.
Assuming that seniors will use Ultimate/Professional and other devs will use Community/Express:

*

*Is there any differences which one will create solution? Can I create solution using Ultimate and use it with Express without any loss for Ultimate and Express versions?

*Is there any differences which one will compile solution? If Express compile whole solution, will be any performance loss in comparison to compilation made by Ultimate?

A: VS2013
I currently work in an environment where there are people using VS2013 Ultimate, VS2013 Pro, and VS2013 Express.  This project has been going for over a year and we haven't had any issues with managing the solution or solution compilation.
VS2015
I don't have any experience with VS2015 in the scenarios outlined, but based on my experience with VS2013, I can't imagine there would be any differences for your 2 questions.  FYI:  You can find a comparison of the VS2015 products and features here
FWIW:
We actually had some people who were using VS2013 Express upgrade to VS2015 community and that is the only time we had an issue.  I can't seem to find what the issue was; but it was something with the way VS2015 did things.


text:
Q: Primefaces - Not displayed dialog requires input I've tried to develope a simple webapp with a "login-feature" for that I've created a dialog with primefaces.
If I click on login, the dialog opens, I can login and also logout. But If I changed the site then I can't logout because the dialog want's that I enter the required fields
I'm running Primefaces 5.2 on Glassfisch 4.0
Here is a complete war file with all the code that shows the problem. (Credentials for login are user: admin | password: admin)
issueShowCase.war
template.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <ui:insert name="head" />
</h:head>
<h:body>
    <h:form id="mainForm">
        <p:growl id="messages" showDetail="true" showSummary="false"/>
        <h:messages />
        <p:menubar>
            <p:submenu label="Sites" icon="ui-icon-document">
                <p:menuitem value="Recipes" outcome="page1.xhtml"/>
                <p:separator />
                <p:menuitem value="Categories" outcome="page2.xhtml"/>
            </p:submenu>
            <f:facet name="options">
                <h:panelGroup id="loginLogout">
                    <p:commandButton rendered="#{not empty user}" value="Logout" title="Logout #{user}" icon="ui-icon-extlink" actionListener="#{loginController.logout}" update="loginLogout messages content" />
                    <p:commandButton rendered="#{empty user}" value="Login" icon="ui-icon-extlink" onclick="PF('loginDlg').show();" />
                </h:panelGroup>
            </f:facet>
        </p:menubar>
        <h:panelGroup id="content">
            <ui:insert name="content"></ui:insert>
            <ui:insert name="body"></ui:insert>
        </h:panelGroup>
        <p:dialog header="#{i18n['title.login']}" widgetVar="loginDlg" modal="true">
            <h:panelGrid columns="2" cellpadding="5">
                <h:outputLabel for="username" value="Username:" />
                <p:inputText id="username" value="#{loginController.userName}" required="true" label="username" />
                <h:outputLabel for="password" value="Password:" />
                <p:password id="password" value="#{loginController.password}" required="true" label="password" />
                <f:facet name="footer">
                    <p:commandButton value="Login" update="loginLogout messages content" actionListener="#{loginController.login}" oncomplete="handleLoginRequest(xhr, status, args)" />
                </f:facet>
            </h:panelGrid>
        </p:dialog>
    </h:form>
    <script type="text/javascript">
        function handleLoginRequest(xhr, status, args) {
            if (args.validationFailed || !args.loggedIn) {
                PF('loginDlg').jq.effect("shake", {
                    times : 3
                }, 500);
            } else {
                PF('loginDlg').hide();
            }
        }
    </script>
</h:body>
</html>

A: Thanks Kukeltje for your help. With thinking about the problem that I now need to use the process-attribute on every button I found the solution.
I put the dialog in an own form-tag and now it works like a charm.
    <h:panelGroup id="content">
        <ui:insert name="content"></ui:insert>
        <ui:insert name="body"></ui:insert>
    </h:panelGroup>
</h:form>
<h:form id="dlgForm">
    <p:dialog header="#{i18n['title.login']}" widgetVar="loginDlg" modal="true">
        <h:panelGrid columns="2" cellpadding="5">
            <h:outputLabel for="username" value="Username:" />
            <p:inputText id="username" value="#{loginController.userName}" required="true" label="username" />
            <h:outputLabel for="password" value="Password:" />
            <p:password id="password" value="#{loginController.password}" required="true" label="password" />
            <f:facet name="footer">
                <p:commandButton  value="Login" update=":mainForm:loginLogout :mainForm:messages :mainForm:content" actionListener="#{loginController.login}" oncomplete="handleLoginRequest(xhr, status, args)" />
            </f:facet>
        </h:panelGrid>
    </p:dialog>
</h:form>

A: Add a process attribute on the logout button to only process the commandbutton, so give it a value of '@this'
<p:commandButton process="@this" rendered="#{not empty user}" value="Logout" title="Logout #{user}" icon="ui-icon-extlink" actionListener="#{loginController.logout}" update="loginLogout messages content" />


text:
Q: How can I list/add Nodes to my Pylon App from python command line? I have a Pylons application that I inherited. It has a MySQL database. There is a Model called Node in the applicaiton. I want to first list all the Nodes in the database. Then, I'd like to be able to add a node. So far, I have been trying:
import myapp.model as model
nodes = model.Session.query(model.Node).all()
for node in nodes:
    print node

The above code throws an error which I have seen in other questions like this one:
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 1579, in all
    return list(self)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 1689, in __iter__
    return self._execute_and_instances(context)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 1694, in _execute_and_instances
    mapper=self._mapper_zero_or_none())
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py", line 717, in execute
    engine = self.get_bind(mapper, clause=clause, **kw)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/session.py", line 851, in get_bind
    raise sa_exc.UnboundExecutionError(
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|Node|node, SQL expression or this Session

I feel like I am missing a step or something. I'm accustom to working with models in Django and this is my first time working with a Pylon application. I think that this has something to do with Sessions but I'm not sure. Does anyone know how I could list all the Nodes and then add a Node?

A: I figured out was was wrong. I never set up a session with my database:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import myapp.model as model

engine = create_engine("mysql://username:password@localhost/myapp")
conn = engine.connect()
session = Session(bind=conn)
nodes = session.query(model.Node).all()
for node in nodes:
    print node


text:
Q: QGIS Server when builds the UPDATE query to postgis sets date field ='' instead of =null which raises an error in the DB I noticed in QGIS Server 2.18.3 and using QGIS Desktop 2.18.3 client the following:
I have a postgis table with a date field called "fecha_inst".
A user is updating the table using WFS-T protocol from outside our network.

*

*When de user updates a feature and does not fill this "fecha_inst" date field, the field remains null and there is no problem.

*After this the user fills the field (with the date QGIS Widget) and it is updated in the DB ok.

*But after this, when the field is already filled and the user deletes its content and saves, when the QGIS Server converts the HTTP package to SQL UPDATE query, it sets "fecha_inst"='' instead of "feach_inst"=NULL. This raises the following error in the BD which is shown also in QGIS:
"PostGIS error while changing attributes: ERROR: invalid input syntax for date: <<>>"
I created an issue in QGIS Application issues repository: http://hub.qgis.org/issues/16125
I created a trigger before update on the table that sets the date to NULL when the value is ='09/09/1999' and told the user to insert this date when he wants to delete the date. This is very ugly...
Anyone has any other workaround to this problem?


text:
Q: Providing warnings and accuracy features on map for legal reasons I work in a big corporation and one of my many responsibilities is making maps for field-workers. I usually make them very basic maps, as they know what infrastructure to look for, they just need the basic road directions, and they know what rate of accuracy our data is in. As a one-time assignment, My boss asked me to make a map for a new contractor and as one of the regular features is "dangerous places" (that the field workers should avoid) he said I should write a so-called legal comment on the map that states the user should not rely only on the map and to state the accuracy. And that got me thinking.
I know none of you are lawyers, and neither am I, but what do you do on your maps?
Right now, I only put the statement on "outside jobs".
Is that a mistake?
Should I put it also on "inside" jobs?
Do I have Individual responsibility and can be sued personally, or does my company "vouch" for me?

A: Map Disclaimers:
Information shown on these drawings/maps/charts is compiled from numerous sources and may not be complete or accurate.
(in 2 point font if possible).
While the 'Big Corporation' and its suppliers have attempted to provide accurate information on our mapping, which we hope you find useful information will always be accurate and up to date.
The 'Big Corporation' cannot be held responsible for the misuse or misinterpretation of any information and offers no warranty guarantees or representations of any kind in connection to its accuracy or completeness.
The 'Big Corporation' accepts no liability for any loss, damage or inconvenience caused as a result of reliance on the mapping.
(in 3 point font)
Best Ever seen:
Do NOT Trust this Map (for skydiving or any other activity...)
(12 BOLD font)

A: Here's a disclaimer relating to "geospatial data products" that "appear to represent property boundaries", which is soon to be required by law in Texas:

This product is for informational purposes and may not have been
  prepared for or be suitable for legal, engineering, or surveying
  purposes. It does not represent an on-the-ground survey and represents
  only the approximate relative location of property boundaries.


text:
Q: Alternatives to Google Refine? Can anyone recommend a tool for cleaning/scrubbing data other than Google Refine?  I don't have any particular reason for not wanting to use Google Refine, I just want to evaluate some alternatives.  Ideally, the tool would be able to operate on millions of records.  I've heard that Google Refine has some issues with large data sets.  I'm just starting to evaluate these products, so I haven't witnessed any issues personally yet.
(Can't add a tag for google-refine)
Editorial Note: Google Refine is now called OpenRefine.

A: I suggest taking a look at Data Wrangler http://vis.stanford.edu/wrangler/.  It appears to be a web service.


text:
Q: How do I find the sum of the following series? I have to find the sum of the series $\sum_{n=1}^{\infty}1/((n+2)(2n+5))$. I performed partial fraction  decomposition and this is what I got:
$\sum_{n=1}^{\infty}(\frac{1}{n+2}-\frac{2}{2n+5})$. So that makes my series:
$\sum_{n=1}^{\infty}(\frac{1}{3}-\frac{2}{7})+(\frac{1}{4}-\frac{2}{9})...$
How do I proceed from here?
Thanks in advance!!

A: hint
Put $$n+2=k$$
the sum becomes
$$\sum_{k=3}^{+\infty}(\frac 1k-\frac{2}{2k+1})=$$
$$2\sum_{k=3}^{+\infty}(\frac{1}{2k}-\frac{1}{2k+1})$$


text:
Q: Dyamically table JavaScript I am trying to make a table like in the pictures in loops but I do not understand how to do it.

*

*Create a JavaScript file and write the code for a function that draws the table.

*Invoke the function when the visitor clicks on the original page.

*Load the file at the end of the body in HTML.

A: this way
function createTable( rowCount, columnCount )
  {
  let newTable = document.body.appendChild(document.createElement('table'))
  for(let r=0;r<rowCount;++r)
    {
    let newRow = newTable.insertRow()
    for(let c=0;c<columnCount;++c)
      {
      newRow.insertCell().textContent = `${r}-${c}`
      }
    }
  }


text:
Q: How do you see that $\theta x + (1-\theta)y$, $\theta \in \mathbb{R}$ is the straight line passing through $x,y$? A set $S$ is called affine if $ \theta x + (1-\theta)y \in S$, for all $x,y, \in S$, $\theta \in \mathbb{R}$
How do you see that $S$ contains all the straight lines passing through $x,y$?
It is easier to visualize for convex sets, because you can actually plug in the value of $\theta \in [0,1]$ to see that whatever the number you get must be contained in the line segment.
But here it is much more difficult to think about.

A: This is nothing more than the vector equation of a line:
$$
s=\theta(x-y)+y
$$
If $S$ contains all $s$ elements, then $S$ contain the straight line(s) passing through $x$ and $y$.


text:
Q: How to best cover one shape with another I was asking myself a pretty simple question today, but no matter how much i try i am not able to find a satisfying answer anywhere, nor could i come up with one.
If you have two shapes e.g. an L shape and a circle. Where the thickness of the L shape is NOT negligible and we have the following rules:
The diameter of the circle is larger than the thickness of the L shape but smaller than the lenght of the L shape.
The thickness of the L shape is smaller than the length.
How to you position the circle to cover the maximum Area of the L shape, and why so ?


text:
Q: Searching for multiple facetsValues in Algolia I have an array of Facet Values that I need to gather from an Algolia Indices.
For example, these are: "Beds", "Occupancy". and "Floor".
At the moment, i've got the below code which will go to my Algolia Table, grab me all of the possible values for each of the above but I have to do a query into Algolia for each one. This results in 3 network calls to Algolia.
index.searchForFacetValues(
{
   facetName: val,
   facetQuery: "",
   maxFacetHits: 100,
   query: "2019"
},
function(err, content) {
   return content
})

Is there a way that I can get all the facet values for "Beds", "Occupancy". and "Floor" in a single query resulting in only one network call?
Also, i'm using https://www.algolia.com/doc/api-client/getting-started/install/javascript/

A: You can use an empty search and specify which facets you want to receive values for:
client.search({
  query: '',
  facets: ['Beds', 'Occupancy', 'Floor'],
  attributesToRetrieve: [],  // a little optimisation for response transfer speed
});

The response will contain something like this:
{
  "facets": {
    "Beds": {
      "2": 1245,
      "4": 893,
      ...
    },
    "Floor": {
      ...
    },
    ...
  }
}

So the first level of keys in facets are your facet names, and within each nested facet object you have one key/value per facet value/hits count.
If you don't know in advance the list of facet names you want to get, use facets: '*' in your query parameters.


text:
Q: Tочное значение термина "unhandled exception" Какие исключения относятся к необработанным? Те, которые не были обёрнуты в try-catch?  Исключение, которое создаётся в методе, объявленном с throws Exception, относится к обработанным? Т.е. это уже "handled exception"?
И следующее исключение будет "handled" или "unhandled"?
public static void main(String[] args) throws Exception {
        throw new Exception("ololo");
}

A: Исключения обрабатываются в соответствующем (внешнем, подходящем по типу) блоке catch. Соответственно, обработанное исключение — то, которое отлавливается одним из блоков catch, а необработанное — то, которое не отлавливается.
В спецификации Java конкретное определение «необработанное исключение» я не нашел. Вместо этого определяются перехваченные исключения и точно описано, что произойдет с неперехваченными исключениями:

Chapter 11. Exceptions.
  ...
  During the process of throwing an exception, the Java Virtual Machine abruptly completes, one by one, any expressions, statements, method and constructor invocations, initializers, and field initialization expressions that have begun but not completed execution in the current thread. This process continues until a handler is found that indicates that it handles that particular exception by naming the class of the exception or a superclass of the class of the exception (§11.2). If no such handler is found, then the exception may be handled by one of a hierarchy of uncaught exception handlers (§11.3) - thus every effort is made to avoid letting an exception go unhandled.
  ...
11.3. Run-Time Handling of an Exception
  ...
  If no catch clause that can handle an exception can be found, then the current thread (the thread that encountered the exception) is terminated. Before termination, all finally clauses are executed and the uncaught exception is handled according to the following rules:
   - If the current thread has an uncaught exception handler set, then that handler is executed.
   - Otherwise, the method uncaughtException is invoked for the ThreadGroup that is the parent of the current thread. If the ThreadGroup and its parent ThreadGroups do not override uncaughtException, then the default handler's uncaughtException method is invoked.
Глава 11. Исключения.
  ...
  В процессе генерации исключения JVM немедленно поочередно завершает все выражения, инструкции, вызовы методов и конструкторов, инициализаторы и выражения инициализации полей, которые были начаты, но не завершены в текущем потоке. Этот процесс продолжается до тех пор, пока не будет обнаружен обработчик, который указывает, что он обрабатывает это конкретное исключение, путем именования класса исключения или его суперкласса. Если такой обработчик не найден, то исключение может быть обработано одним из элементов иерархии обработчиков неперехваченных сообщений ($11.3). Таким образом, делается все возможное, чтобы не допустить возможности существования неперехваченного исключения.
  ...
$11.3. Обработка исключений времени выполнения.
  ...
  Если конструкция catch, способная обработать сгенерированное исключение, не найдена, то текущий поток выполнения (поток, в котором сгенерировано исключение) завершается. Перед завершением выполняются все конструкции finally, а неперехваченное исключение обрабатывается в соответствии со следующими правилами.
   - Если текущий поток имеет установленный обработчик неперехваченных исключений, вызывается этот обработчик.
   - В противном случае для группы ThreadGroup, которая представляет собой родителя текущего потока, вызывается метод uncaughtException. Если ThreadGroup и ее родительские ThreadGroup не перекрывают uncaughtException, то вызывается метод uncaughtException обработчика по умолчанию.

На практике фраза «unhandled exception» обычно употребляется в более узком контексте и относится не к JVM, а к какому-либо процессу/классу/методу. В этом случае имеется ввиду неожиданное исключение, которое выбрасывается в вызывающий код. Например: «исключения, не обработанные при разборе файла, должны быть отражены в журнале ошибок».
Конструкция throws в объявлении метода не связана напрямую с перехватом/обработкой исключений. Если нужно как-то назвать перечисленные типы исключений, то скорее подойдет «объявленные типы исключений» («declared exception types»).


text:
Q: Read binary data image JavaScript So I am using mongoDB as my database and I have saved an image in mongoDB in binary format.
The image below is how the data is being displayed in my database.

I have tried the following:
<img src="data:image/jpeg;base64{<%= user.img.data %>}"/>

But the above code does not seem to work. Please note I am using EJS as a tempting engine.
After doing the inspect element on google chrome I found that the data was being shown like so:

I am not sure how to read this binary image and display it in a img tag in html.
UPDATE:
After making the changes recommended by Alex Matos in the comments I get the following output:

A: If you really got the images data and saved it i mongo db, you could render the image in a canvas and append it wherever you need.
// Renders the image data in a canvas off screen
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
var data = ctx.putImageData(YOUR_MONGODB_DATA,0,0);

// Initializes a new image from canvas and appends it to the parent you want
var image = new Image();
image.id = "rendered-picture"
image.src = canvas.toDataURL();
document.getElementById('PARENT_ID').appendChild(image);

A: Try returning data from your server using base64_encode.
For example:
    <?php
        $picture = base64_encode(user.img.data);
       <img src="data:image/jpeg;base64{<%= picture %>}"/>
    ?>


text:
Q: jquery date picker locale setting not working the documentation seems simple enough, but in practice, this feature is not working!
I need the date to be in dd/mm/yyyy format.
$(function() {
    $("#txt_date").datepicker($.datepicker.regional['en-GB']);
});

Can you help?
Currently the date is outputted as mm/dd/yyyy.
Many thanks

A: You need to create language specific files if you need to use the Localization.
See this post http://docs.jquery.com/UI/Datepicker/Localization
If you only need one date format, dd/mm/yyyy, just use this
$( "#txt_date" ).datepicker({ dateFormat: 'dd/mm/yy' });


text:
Q: Find lowest value in results set I am trying to find the cleanest method of turning this set of results into an array and then finding the lowest value.
if (!$result) die($conn->error);
while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
{
    $low_score_1 = $row['low_score_1'];
    $low_score_2 = $row['low_score_2'];
    $low_score_3 = $row['low_score_3'];
    $low_score_4 = $row['low_score_4'];
    $low_score_5 = $row['low_score_5'];
    $low_score_6 = $row['low_score_6'];
    $low_score_7 = $row['low_score_7'];
    $low_score_8 = $row['low_score_8'];

}

A: This should do what you want. Its a bit simple and long hand but sometimes thats easier
if (!$result) die($conn->error);

// read first row and seed the variables with these values
$row=mysqli_fetch_array($result, MYSQLI_ASSOC);
$low_score_1 = $row['low_score_1'];
$low_score_2 = $row['low_score_2'];
$low_score_3 = $row['low_score_3'];
$low_score_4 = $row['low_score_4'];
$low_score_5 = $row['low_score_5'];
$low_score_6 = $row['low_score_6'];
$low_score_7 = $row['low_score_7'];
$low_score_8 = $row['low_score_8'];

while($row=mysqli_fetch_array($result, MYSQLI_ASSOC))
{
    $low_score_1 = ($row['low_score_1'] < $low_score_1) ? $row['low_score_1'] : $low_score_1;
    $low_score_2 = ($row['low_score_2'] < $low_score_2) ? $row['low_score_2'] : $low_score_2;
    $low_score_3 = ($row['low_score_3'] < $low_score_3) ? $row['low_score_3'] : $low_score_3;
    $low_score_4 = ($row['low_score_4'] < $low_score_4) ? $row['low_score_4'] : $low_score_4;
    $low_score_5 = ($row['low_score_5'] < $low_score_5) ? $row['low_score_5'] : $low_score_5;
    $low_score_6 = ($row['low_score_6'] < $low_score_6) ? $row['low_score_6'] : $low_score_6;
    $low_score_7 = ($row['low_score_7'] < $low_score_7) ? $row['low_score_7'] : $low_score_7;
    $low_score_8 = ($row['low_score_8'] < $low_score_8) ? $row['low_score_8'] : $low_score_8;

}

// lowest of the entire set
$t = array($low_score_1,$low_score_2,$low_score_3,$low_score_4,
            $low_score_5,$low_score_6,$low_score_7,$low_score_8)

echo min($t);

Or you could do
while($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    $low1[] = $row['low_score_1'];
    $low2[] = $row['low_score_2'];
    $low3[] = $row['low_score_3'];
    $low4[] = $row['low_score_4'];
    $low5[] = $row['low_score_5'];
    $low6[] = $row['low_score_6'];
    $low7[] = $row['low_score_7'];
    $low8[] = $row['low_score_8'];
}

$low_score_1 = min($low1);
$low_score_2 = min($low2);
$low_score_3 = min($low3);
$low_score_4 = min($low4);
$low_score_5 = min($low5);
$low_score_6 = min($low6);
$low_score_7 = min($low7);
$low_score_8 = min($low8);

// lowest of the entire set
$t = array($low_score_1,$low_score_2,$low_score_3,$low_score_4,
            $low_score_5,$low_score_6,$low_score_7,$low_score_8);

echo min($t);


text:
Q: Counting results from different tables in one query I have orders, order_attachments, order_preship_check, order_preship_check_attachment, order_log, order_log_attachments tables
The only common thing in these columns are order_id. Right now in the query I am only checking those order_attachments which are type 1 and type 2 using the following query
SELECT
    COUNT(file_id) AS totalFiles
FROM
    orders_files
WHERE
    order_id = '88125'
AND attachment_type IN ('1', '2')

So if it returns I show an ATTACHMENTS icon with that order. Now I need to combine preship attachments and log attachments in this as well. There are no additional checks, individual queries for both are as follows
SELECT
    COUNT(file_id) AS totalFiles
FROM
    orders_preship_check_attachment
WHERE
    order_id = '88125'

and
SELECT
    COUNT(id) AS totalFiles
FROM
    orders_log_attachment
WHERE
    order_id = '88125'

I need to combine these 3 queries in one query. So if each table have 1 records, I just need to get the count of 3, even 3 is not important. Means if any of these records have attachments I need to show the icon, TRUE or FALSE. I hope it makes it more clear

A: Use UNION or UNION ALL but this must have the same type and number of columns.
Example code:
    SELECT 'Customer' AS type, id, name FROM customer
    UNION ALL
    SELECT 'Supplier', id, name FROM supplier

If your query contains different number of columns try using joins.

A: Try this
SELECT SUM(totalFiles) AS totalFiles
  FROM (
    SELECT COUNT(file_id) AS totalFiles
      FROM orders_files
     WHERE order_id = '88125' AND
           attachment_type IN ('1', '2')
     UNION ALL
    SELECT COUNT(file_id) AS totalFiles
      FROM orders_preship_check_attachment
     WHERE order_id = '88125'
     UNION ALL
    SELECT COUNT(id) AS totalFiles
      FROM orders_log_attachment
     WHERE order_id = '88125'
    ) t

or
SELECT COUNT(file_id) AS totalFiles
  FROM (
    SELECT file_id
      FROM orders_files
     WHERE order_id = '88125' AND
           attachment_type IN ('1', '2')
     UNION ALL
    SELECT file_id
      FROM orders_preship_check_attachment
     WHERE order_id = '88125'
     UNION ALL
    SELECT id
      FROM orders_log_attachment
     WHERE order_id = '88125'
    ) t


text:
Q: Java - Ignore warnings on directory/package level Some of our code is auto-generated (by Apache Axis) and it reports a ton of warnings. An example would be:
private java.util.HashMap faultExceptionNameMap = new java.util.HashMap();

Here, the warning would be

HashMap is a raw type. References to generic type HashMap should be parameterized.

Of course it makes no sense to actually address these warnings, as we have to trust Apache Axis anyway and it would simply re-create the code as-is again.
Because our team uses different IDEs, from VSCode to IntelliJ IDEA to Eclipse, I'm looking for an IDE-agnostic way to exclude warnings coming from the auto-generated package/directory. It would be best if this option could be set for the workspace by being under version control.
In TypeScript, I'd set an exclude array in tsconfig.json
Does Java, for example, have an equivalent?

A: i only find this way to solve the issue now:
add @SuppressWarnings("rawtypes") to your method or variable like:
@SuppressWarnings("rawtypes")
private java.util.HashMap faultExceptionNameMap = new java.util.HashMap();

A: I would recommend adding the @SuppressWarnings to the auto-generated code after its generated:
<plugin>
   <groupId>com.google.code.maven-replacer-plugin</groupId>
   <artifactId>maven-replacer-plugin</artifactId>
    <version>1.3.2</version>
   <executions>
    <execution>
     <phase>prepare-package</phase>
     <goals>
     <goal>replace</goal>
     </goals>
     </execution>
    </executions>
    <configuration>
    <includes>
      <include>target/generated-sources/apache/blahblah//*.java</include>
    </includes>

   <regex>true</regex>
   <regexFlags>
    <regexFlag>MULTILINE</regexFlag>
   </regexFlags>

  <replacements>
   <replacement>
     <token>^(@SuppressWarnings\(.*?\)\s+)?public class</token>
   <value>@SuppressWarnings("all") public class</value>
    </replacement>
   </replacements>
  </configuration>
</plugin>

The configuration above would essentially do this through maven. If you have other build tools you would do something similar.


text:
Q: Use string column as tooltip in c3js I have a CSV file which looks like this:
date,size,time,hash
"2016-07-26T17:01:49","0","108.99","c3262c23c3538fd5b9b0f28fb3cbd239e466bb10"
"2016-07-26T18:04:28","0","267.30","58f584d2c58d41f12667538e6a32ad2ce2975bf6"
"2016-07-26T19:02:14","0","133.23","58f584d2c58d41f12667538e6a32ad2ce2975bf6"
"2016-07-26T20:01:32","0","92.50","58f584d2c58d41f12667538e6a32ad2ce2975bf6"
"2016-07-26T21:02:02","0","121.96","a5251ee2a52824ef69fc28b801bdb825c73308f4"
"2016-07-26T22:01:39","0","98.96","a5251ee2a52824ef69fc28b801bdb825c73308f4"

I want to add the last column(hash) which is a string as a tooltip when I hover on the line chart.
The following code is able to generate the graph, but I am unable to add "hash" column as tooltip.
function generateChart(div, data){
        var chart = c3.generate({
            bindto: div,

            data: {
                x: 'date',
                xFormat: '%Y-%m-%dT%H:%M:%S',
                json: data,
                type: 'line',
                keys: {
                    x: 'date',
                    value: ['size', 'time']
                }
            },
            axis:{
                x: {
                    type: 'timeseries', //date format in CSV file needs to be 2000-06-14
                    tick: {
                        format: '%m-%d %H:00'
                    }
                }
            },
            zoom: {
                enabled: true
            },
            subchart: {
                show: true
            }
        });
    }
}

Can you please help me in adding the last column as tooltip for all data points on graph?

A: Try tooltip.format.value to get this working.
Provide a callback function which indexes the data, formats and returns the value to show in tooltip overlay, as shown below.
Please copy and paste below code in the c3.js example code

var data = [
{'date': "2016-07-26T17:01:49",'size': "0",'time': "108.99",'hash': "c3262c23c3538fd5b9b0f28fb3cbd239e466bb10"},
{'date': "2016-07-26T18:04:28",'size': "0",'time': "267.30",'hash': "58f584d2c58d41f12667538e6a32ad2ce2975bf6"},
{'date': "2016-07-26T19:02:14",'size': "38",'time': "133.23",'hash': "58f584d2c58d41f12667538e6a32ad2ce2975bf6"},
{'date': "2016-07-26T20:01:32",'size': "0",'time': "92.50",'hash': "58f584d2c58d41f12667538e6a32ad2ce2975bf6"},
{'date': "2016-07-26T21:02:02",'size': "0",'time': "121.96",'hash': "a5251ee2a52824ef69fc28b801bdb825c73308f4"},
{'date': "2016-07-26T22:01:39",'size': "0",'time': "98.96",'hash': "a5251ee2a52824ef69fc28b801bdb825c73308f4"}];

var chart = c3.generate({
    //bindto: div,
    data: {
        x: 'date',
        xFormat: '%Y-%m-%dT%H:%M:%S',
        json: data,
        type: 'line',
        keys: {
            x: 'date',
            value: ['size', 'time']
        }
    },
    axis:{
        x: {
            type: 'timeseries', //date format in CSV file needs to be 2000-06-14
            tick: {
                format: '%m-%d %H:00'
            }
        }
    },
    tooltip: {
        grouped: false,
        format: {
            //title: function (d) { return 'Data ' + d; },
            value: function (value, ratio, id, index) {
                //var format = id === 'data1' ? d3.format(',') : d3.format('$');
                //console.log('index '+index+' ,value '+value+' ,tooltip'+data[index]);
                //return format(value);
                return data[index]['hash'];
            }
            // value: d3.format(',') // apply this format to both y and y2
        }
    },
    zoom: {
        enabled: false
    },
    subchart: {
        show: false
    }
});


text:
Q: windows 7 boot screen logo issue I have a problem with my Lenovo b50-70, I installed Ubuntu and Windows 7 in two different disk partitions, but when I choose Windows in the grub I see that instead of windows boot logo:

So, I formatted my HD and installed only Windows and the problem was solved, but I want have Linux too on my laptop, so I installed Debian in the second partition and now I see that:

After that, Windows works, but I would solve that problem.
Any ideas?

A: Thanks, I've solved in this way: Edit /etc/default/grub (as root) and uncomment # GRUB_TERMINAL="console" (remove the #) after that, run sudo update-grub


text:
Q: Map showing the keys, not only the values If I have this object:
const json = {
  products: [
    {
      id: 0,
      name: "Chair Roby",
      style: "Leather",
      color: "red",
    }
  ]
};

I can map over the array inside of it and show all the items in the object inside the array like this:
const prod = json.products.map(item => {
  return (

          {item.name}

          {item.style}

          {item.color}

  );
});

This listed me the values, but how could I show also the keys such as name, style and color?

A: Use another nested map over the Object.entries of each item:

const json = {
  products: [
    {
      id: 0,
      name: "Chair Roby",
      style: "Leather",
      color: "red",
    },
    {
      foo: 'bar'
    }
  ]
};

class MyList extends React.Component {
  render() {
    return json.products.map((obj) => (

        {
          Object.entries(obj).map(([key, val]) => (

              {('key: ' + key +  ', val: ' + val)}

          ))
        }

    ));
  }
}
ReactDOM.render(
  <MyList />,
  document.getElementById("react")
);

A: The best aproach is this:
const prod = Object.keys(json.products).forEach(productKey => {
    return (

 {productKey} - {json.products[productKey]}

 );
});

A: Try this
 Object.keys(json).map(Followed by necessary code)

A: const prod = json.products.map(item =>

          {Object.entries(item).map((key, value) =>

{key}: {value}

          }

);


text:
Q: How to compute SFS(Sequential feature selection) with "multiple class" SVM? I can use sequentialfs function to compute the SFS with two-class SVM.
(means the binary output [0 1])
below is my code:
%% x=features, y=binary response.
c = cvpartition(y,'k',10);
opts = statset('display','iter'); [fs,history] = sequentialfs(fun,x,y,'cv',c,'options',opts)

function err = SVM_class_fun(xTrain, yTrain, xTest, yTest)
model = svmtrain(xTrain,yTrain,'Kernel_Function','polynomial','polyorder',2, 'boxconstraint', 1);
 err = sum(svmclassify(model, xTest) ~= yTest); end

My issue is how to compute SFS when y is not binary.
I can't get it to work successfully.

A: I think your problem is that the svmtrain is only for binary classification. If you would include the error message you get when y is not binary, then we could know.
There are several implementations of multi-class SVM in Matlab including:
(1)This from the file exchange which apparently uses a syntax similar to svmtrain, (2) and this from Mathworks itself which uses a slightly different structure.
I haven't personally used it, but I would start with (1) since the syntax is just the same as svmtrain, however it may lack the kernel and boundary options you use. Good luck!


text:
Q: When to take dummy variables in classification problems? I am doing a binary classification problem where I am predicting if a customer will subscribe for a campaign(For Airline Industry).
My data set is at Customer and Campaign name level and there are 43 variables under consideration.
There are certain variables which are decile ( 1 to 10) and variable like education level ( 0 to 5). For education level we can't say 4 is twice as educated as 2. How should I treat my variables?
Do i need to convert these variables to dummy variables( 0 or 1), I am running Logistic regression, random forest, Xgboost in R.
How can I check variable importance if I convert these to dummy variables( factor analysis is throwing errors)

A: You do need dummy variables, in my opinion. How about converting educational level into multiple variables like these:
educational level:1
educational level:2
educational level:3
and so on. Then you can give dummy variables for each of the variable.
For example,
educational level:1 yes:1 no:0
educational level:2 yes:1 no:0
Then fit your data into logistic model and try to resample it with some kind of ways like "cross validation". But I'm not quite sure about "variable importance", do you mean is this variable statistically significant or ...?


text:
Q: How to convert a char 2D array to int in C I have a char 2D array called char newString[][]
I want to convert the 2nd and 3rd rows to integers.
Lets say newString[2]= {1,2} and newString[3]= {2,2]}
I am trying to get int n = 12 and int m = 22 by turning my 2D array into an integer. Because later I want to do m^n  ( m to the power of n).
     char newString[32][32];
     int n;
     int m;

  // let newString[2]= {1,2}
  // let newString[3]= {2,2}
  // convert it to an int

     m = newString[2] - '0'; // I want m = 12
     n = newString[3] - '0';  // n = 22

I know that char - '0' will give you an integer if assigned to an integer, but how to assign a 2d array into an integer
I tried using these, but they only work for 1D arrays, any ideas?

A: the function: strtol() will not do the desired functionality as there is no trailing NUL byte, so no string to convert.
Suggest:
// given
char newString[][] =
{
    { '1', '2'},
    { '2', '2'}
};

// convert to integers
int n = newString[0][0] - '0';
n     = n*10 + (newString[0][1] - '0');

int m = newString[1][0] - '0';
m     = m*10 + (newString[1][1] - '0');

// which results in:
// n contains 12
// m contains 22


text:
Q: Redirect/Subdomain with .htaccess What I have currently:

*

*A wildcard DNS record. So that every subdomain points to www.galop.gr

*A dynamically (php) generated .htaccess file where I append the following code for every subdomain I want working:

RewriteCond %{HTTP_HOST} ^fractalbit.galop.gr$ [OR]
RewriteCond %{HTTP_HOST} ^www.fractalbit.galop.gr$
RewriteRule ^/?$ http://www.galop.gr/index.php?user=1 [R=301]

Everything is working fine, I just want something more if it is possible.
Right now, if someone enters fractalbit.galop.gr will be redirected to http://www.galop.gr/index.php?user=1
Is it possible to do this BUT keep fractalbit.galop.gr to the address bar of the browser?

A: [R=301] means: do a redirection, and since you're using an absolute address it will also force a redirection, i would just change the rules to this:
RewriteCond %{HTTP_HOST} ^fractalbit.galop.gr$ [OR]
RewriteCond %{HTTP_HOST} ^www.fractalbit.galop.gr$
RewriteRule ^/?$ /index.php?user=1 [L]


text:
Q: For loop float into integer For loop float to integer
Hello guys, how can I change the this for loop on thanos that are float to integer?
thanos = 1
for(let day =1; day < 51; day){
console.log(day, thanos)
day++
Math.floor(thanos)
if(day % 3 == 0){
thanos /= 2
    }
else{
thanos *= 3

    }
}

The output is

1 1
2 3
3 1.5
4 4.5
5 13.5

How can i make thanos *= 3 that are 1.5 *= 3 into 1 *= 3 so the output
1 1
2 3
3 1
4 3
5 9

Thank you.

A: Math.floor() returns a new number, doesn't modify the old one
thanos = Math.floor(thanos)

Also, remember to declare variables. I would write your code like that:
let thanos = 1
for(let day = 2; day < 51; day += 1){
  if(day % 3 == 0){
    thanos = Math.floor(thanos / 2)
  } else {
    thanos *= 3
  }
}

A: This outputs your desired result

thanos = 1
for(let day =1; day < 51; day){
  console.log(day, thanos)
  day++
  if(day % 3 == 0){
    thanos /= 2
  } else {
    thanos *= 3
  }
  thanos = Math.floor(thanos)
}


text:
Q: Is it possible to use propensity score matching (or something similar) to create a control group if you do not yet have outcome data? I am looking into using PSM to help determine the effects that an academic intervention has on student dropout rates, and I have a question about how to use it.
Currently, I have information on whether a student was in the treatment, and some demographic information that I want to use as covariates. I do not yet have information on whether or not students dropped out.
I am trying to do as much of my analyses upfront as I can. I would like to create a control group that I can compare to my treatment group in the future, when I have drop out data. Is that possible with PSM? Or do I need to wait to get the dropout data before I can do PSM?

A: Not only can you do that, this this one of the main motivations for using matching methods (such as PSM) over other methods. You can perform the matching to select a subset of individuals that you need to follow up on instead of collecting outcome data on the full sample. This is especially useful when getting outcome data is expensive or challenging. It also ensures there is a separation between the design and analysis stages, since if you pre-publish your matched sample, you can't try a bunch of different matching methods after you've collected the outcome to try to find one that gives you the largest treatment effect.
You do need to know which outcome variable(s) you will collect, because to decide what variables you need to match on is to decide which variables are confounders, which are variables that cause both selection into treatment and the outcome. A confounder of one outcome may not be a confounder for another, so it is important to have a causal theory for the outcomes you plan on collecting data for in order to know which covariates you need to match on.

A: It's not strictly pertinent to your question, but without outcome data you can also use unsupervised machine learning techniques (eg clustering) to get better insights on your study population, and potentially inform patient characterization.


text:
Q: Select multiple columns from a spark data frame more concisely So I have the following piece of code that works:
import org.apache.spark.rdd.RDD
case class Person(name: String, age: Int, gender: String)
val peopleRDD: RDD[Person] = sc.parallelize(Seq(Person("Jack Ryan", 10, "M"),
                                              Person("Remi Lekan", 11, "M"),
                                              Person("Lola Adeyemi", 8, "F")))
val people = peopleRDD.toDS
val delim="^"
def mySimpleHashModel(params: Map[String, Any])={params("name") +  delim +
                               params("age").toString() + delim + params("gender")}
val simpleHashUdf = udf { (name: String, age: Int, gender: String) =>
               mySimpleHashModel(Map("name"->name, "age"->age, "gender"->gender))}
val resDf= people.withColumn("data",
                           simpleHashUdf(col("name"),col("age"), col("gender")))
resDf.show()

This code works, but I'm fairly new to Scala Spark so I'm wondering how to make this code a bit more concise.

*

*Is there a more concise way to specify the arguments to simpleHashUDf instead of listing the individual columns as in simpleHashUdf(col("name"),col("age"), col("gender")) ?

*Is there more concise way to create the Map rather than specifying each element as in mySimpleHashModel(Map("name"->name, "age"->age, "gender"->gender) ?
I'm asking this because the actual case I will work on actually has much more than 2 columns like in this example.
Any help will be greatly appreciated.

A: Let's assume you have a list of column names as strings in a variable val colnames. I'd still suggest to use the concat spark function as the others have suggested, just with a little change:
import org.apache.spark.sql.functions._

df.withColumn("data", concat(colnames.map(x => col(x)): _*))

The : _* extracts each element from the list as a parameter into the concat function.

A: Yes, Spark has concat function.
import org.apache.spark.sql.functions._
df.withColumn("data", concat(col("name"), col("age")))

A: I would also suggest using built-in concat function. I'm not quite sure why you want to work with a Map in this case. But if you wish, you could rewrite our code like this:
val concatUdf = udf { (row:Row) =>
  // creates map from all fields
  concatModel(row.getValuesMap[Any](row.schema.fieldNames))}

val resDf= people.withColumn("data",
  concatUdf(struct("*")) // select all fields of dataframe
)


text:
Q: How to add two dataframes with different dimensions? I have two dataframes in Python, which needs to be added, but want the output as the last table not the one that's an outcome of performing df1+df2.
df1:
index   6   12  24
2010    2   3   4
2011    2   3   4
2012    2   3   4

df2:
index   6   12
2011    2   3
2012    2   3

df1+df2:
index   6   12
2011    4   6
2012    4   6

Required Output:
index   6   12  24
2010    2   3   4
2011    4   6   4
2012    4   6   4

A: Yes, use:
df1.add(df2, fill_value=0)


text:
Q: Domain without SPF DKIM and DMARC I am looking for domains that don't have SPF DKIM and DMARC records.
The biggest issue is I can't verify that if a domain is using DKIM,
does anybody konw any domain which doesn't have those 3 authentication records?

A: It's true that you can't tell very easily, because you can't find out the DKIM selectors to look up in DNS. You can look for a _domainkey policy record that might contain something like o=~, though that's a leftover from the older domainkeys spec rather than DKIM. Best case, you'll have an email from the domain that does or does not contain a DKIM signature. A domain is very unlikely to have DMARC if it doesn't have DKIM.
If you're really desperate, and really want just any domain that you can show failing a test, just register a domain yourself and don't make those records for it - a bit like neverssl.com does for SSL.


text:
Q: How do you keep a webSocket connection alive? I need to design a web app that has a constant server connection, but the connection keeps failing.

A: You just have to use the following javaScript: webSocket.onclose=webSocket.open;. You can use webSocket.onclose=undefined; to force a connection to close.


text:
Q: Form only Submitting on 2nd Attempt I have created a form for a quiz, where you have to enter the answers and a PHP script will total them and send them to en E-Mail address and save them to a file. However, the user is only redirected on the 2nd attempt (submission) of the form. The results are totalled and sent on the first submission, but it does not redirect. On the 2nd submission, the results are not totalled, but an e-mail is sent and the user is redirected to the completion page.
Here is my code:-
<!DOCTYPE html>

<title>Quiz</title>
<link rel="stylesheet" type="text/css" href="../styles.css" />
<link rel="shortcut icon" href="../img/favicon.ico" type="image/x-icon" />

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
if (isset($_SESSION['username'])) $username = $_SESSION['username'];
else header("Location: http://quiz.dibdibguy.com/client/index");

include_once($_SERVER['DOCUMENT_ROOT']."/scripts/sql.php");
$qid = $_SESSION['quiz'];
$con = connect();
$data = mysqli_query($con, "SELECT * FROM `qs` WHERE `id`='$qid' LIMIT 1");
$qinfo = mysqli_fetch_array($data, MYSQLI_ASSOC);
?>

Quizzes

Quiz: <?php echo($qinfo['name']); ?>

<?php if ($qinfo['desc'] == NULL) echo($qinfo['name'] . ", has no description available."); else echo($qinfo['desc']); ?>

<?php
$table = $qinfo['table'];
$questionsTable = mysqli_query($con, "SELECT * FROM `$table`");
?>

Please Remember: For questions that require you to type an answer, you must spell it correctly, as the system cannot detect spelling errors.

    Playing as: <?php echo($_SESSION['username']); ?>

    <form method="post" name="quiz" action="">
    <?php
    $amt = mysqli_num_rows($questionsTable);
    $count = 1;
    echo($questions['que']);
    while($ques = mysqli_fetch_array($questionsTable)){
        echo("Question: " . $ques['que'] . "
");
        echo("Answer: <input type=\"text\" name=\"$count\">

");
        $count = $count + 1;
    }
    ?>
    <input type="submit" name="submit" value="Submit Answers" id="btn">
    </form>

<?php
if (isset($_POST['submit'])){
    $answers = mysqli_query($con, "SELECT `ans` FROM `$table`");
    $u_answers = $_POST;
    $correct = 0;
    while($answer = mysqli_fetch_assoc($answers)){
        echo("Hi");
        foreach($u_answers as $u_ans){
            if ($answer['ans'] == strtolower($u_ans)) $correct = $correct + 1;
            $count = $count + 1;
        }
    }
    header("Location: http://quiz.dibdibguy.com/client/index");
    #WRITE DATA TO FILE
    $file = fopen("../results/" . strtoupper($_SESSION['username']) . "_" . date("d-m-Y_h:i_sa") . "_" .  strtoupper($_SESSION['quiz'] . ".txt"), 'w');
    fwrite($file, ($correct) . "/" . ($amt));
    fclose($file);

    mail("aaron@dibdibguy.com", $_SESSION['username'] . "quiz results", $correct . "/" . $amt);
    $_SESSION['quiz'] = $qinfo['name'];
}
close($con);
?>

<?php include "../footer.php"; ?>

On the 1st attempt, if I get 1 question correct, I receive an e-mail stating; '1/39', which is what should happen, but on the 2nd attempt, I get an e-mail stating '0/', even if I get some correct.
Thanks in advance for any assistance. If you need anything else, please, E-Mail me (aaron@dibdibguy.com), or comment on this question!
Web Host: unlimitedwebhosting
PHP Version: 5.5

A: I see two problems.
First - HTML headers have to be sent before any content is sent. If you look in your error logs there are likely warnings about this. You print quite a lot of html to the page before your location header is used for the redirect. Since it's too late for headers it's ignored (you don't get redirected).  To fix this either move the redirect logic further up the page before any output (and plain HTML counts as output) or use output_buffering to keep the output from being sent to the browser until you've sent all your headers.
Second - The '0/' email seems to be an error in your logic. If you look at this block:
if (isset($_POST['submit'])){

    ... Other Stuff

    mail("aaron@dibdibguy.com", $_SESSION['username'] . "quiz results", $correct . "/" . $amt);

    ... More Stuff
}

The logic you've written says that the email will be sent any time the submit button is pressed. You never did a 'sanity check' to see if you actually have any valid information in the form first.


text:
Q: Removing stray CRLF embedded in a CSV file column I need some direction on how to solve a problem I am working on. The root issue is that I need to work with CSV files in another program. The source system that creates the CSV files does not strip out CRLF in any of the data fields that get exported (meaning some fields have an embedded CRLF). As a result I receive a CSV file that has malformed rows in it. My end goal is an utility that will

*

*check the first column of each row (which if correct is a GUID with a length of 36, or

*count the columns in each row (which is the example below).

In the example below I am looking at the column count. If the correct count is 18 then I want it to write that row to a new file. If the column count is not correct I want to remove the CRLF from that row until the column count is correct.
Again, two ways to solve the issue that I know of:

*

*Check the length of the first column for a length of 36 (before the first comma and excluding the first row which is the title row), or

*count the columns and remove any trailing CRLF until the column count is equal to 18 (the total column count).

My issue with the code so far is being able to write out a valid row to a new file. Currently it writes out System.String[] instead of the actual row.
Public Class Form1
    Private Sub btnFixit_Click(sender As Object, e As EventArgs) Handles btnFixit.Click
        Dim iBadRowNumber As Integer = vbNull
        Dim strFixedFile As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(Me.txtFixedFile.Text, True)
        Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(Me.txtBaselineFileToProcess.Text)
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
            Dim currentRow As String()

            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    If currentRow.Count = 18 Then
                        strFixedFile.WriteLine(currentRow)
                    Else
                        ' Future code here to fix the line
                    End If
                Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message &
                    "is not valid and will be skipped.")
                End Try
            End While
        End Using
       strFixedFile.Close()
    End Sub
End Class

Here is an example of 2 correct rows with one incorrect row in the middle. In this example the row beginning with Sometown is really part of the prior row. I have also seen that one true row may be broken into three or more partial rows like similar to what you see in the Sometown row.
CustomerId,CustomerName,Status,Type,CustomerNumber,DBA,Address1,Address2,City,State,ZipCode,WebAddr,EMail,SalesCode,ServiceCode,DivisionCode,BranchCode,DepartmentCode
6d0125cd-70cf-4048-9ee1-8d9682e426a5,"Smith,James",Active,Customer,8,,103 Long Dr,,AnotherTown,NJ,000000,,,!!S,!%9,!!#,!!#,"!""."
35ed375c-c226-4879-a789-469cae63383c,"Doe, John",Active,Customer,55281,,28 Short Drive,,
Sometown,CA,12345,,
email@domain.com,"!$,",!$^,!!#,!!#,!!K
a5972bce-408f-4def-b77c-4ae0148dd045,"Duck,Donald",Active,Customer,25,,236 North Main St,,Mytown,PA,11111,,,!!2,!%9,!!#,!!#,"!""."

There may be much more elegant ways to perform the specific task. I am open either to corrections to my logic above or a totally different way to solve the problem either in VB.net or PowerShell.

A: Normally, csv can have multiline fields without a problem. But those need to be surrounded with quotes.
In your example this doesn't seem the case, but on the other hand there is no multiline field either, the field with value Sometown starts at a new line. So I wonder if this is the original data.
In case your multiline fields are surrounded with quotes you need to inform your parser about it.
But even with the single lines you will have problems caused by the fields with a seperator inside. Luckily those are quoted (as they should be), so you need to set the TextFieldParser.HasFieldsEnclosedInQuotes property as wel.
Now, if your multiline fields happen to be quoted (as they should be), the above setting should solve everything.

Update
You could do something like this:
currentRow = MyReader.ReadFields()
If currentRow.Count = 18 Then
    strFixedFile.WriteLine(currentRow)
Else
    'Write current row without newline
    'Read next line/row
    'WriteLine this row
End If

But you'll have to take care of fields like "Smith,James" with a seperator inside. Make sure your parser handles quoted fields properly (see above).

A: The most straightforward approach would probably be a variation of your first validation check:

*

*Read the file line-by-line and keep both the current and the previous line in a buffer.

*Check if the beginning of the line is a proper GUID (e.g. with a regular expression).

*If the current line does not start with a GUID, append it to the previous line.

*Otherwise write the previous line to the output file unless it's empty, then replace it with the current line.

I don't know VB.net, but in PowerShell it would look somewhat like this:
$reader = New-Object IO.StreamReader ('C:\path\to\input.csv')
$writer = New-Object IO.StreamWriter ('C:\path\to\output.csv', $false)

$writer.WriteLine($reader.ReadLine())  # copy CSV header

$output  = ''  # output buffer
$current = ''  # pre-buffered current line from input file
while ($reader.Peek() -ge 0) {
  # read line into pre-buffer
  $current = $reader.ReadLine()

  $hasGUID = $current -match '^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12},'

  # append line to output buffer if it doesn't have a GUID, otherwise
  # write the output buffer to file if it contains data and move the
  # current line to the output buffer
  if (-not $hasGUID) {
    $output += $current
  } else {
    if ($output) { $writer.WriteLine($output) }
    $output = $current
  }
}
# write remaining pre-buffered line (if there is one)
if ($current -and $hasGUID) { $writer.WriteLine($current) }

$reader.Close(); $reader.Dispose()
$writer.Close(); $writer.Dispose()


text:
Q: How to speed up web scraping in python I'm working on a project for school and I am trying to get data about movies.  I've managed to write a script to get the data I need from IMDbPY and Open Movie DB API (omdbapi.com).  The challenge I'm experiencing is that I'm trying to get data for 22,305 movies and each request takes about 0.7 seconds.  Essentially my current script will take about 8 hours to complete.  Looking for any way to maybe use multiple requests at the same time or any other suggestions to significantly speed up the process of getting this data.
import urllib2
import json
import pandas as pd
import time
import imdb

start_time = time.time() #record time at beginning of script

#used to make imdb.com think we are getting this data from a browser
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }

#Open Movie Database Query url for IMDb IDs
url = 'http://www.omdbapi.com/?tomatoes=true&i='

#read the ids from the imdb_id csv file
imdb_ids = pd.read_csv('ids.csv')

cols = [u'Plot', u'Rated', u'tomatoImage', u'Title', u'DVD', u'tomatoMeter',
 u'Writer', u'tomatoUserRating', u'Production', u'Actors', u'tomatoFresh',
 u'Type', u'imdbVotes', u'Website', u'tomatoConsensus', u'Poster', u'tomatoRotten',
 u'Director', u'Released', u'tomatoUserReviews', u'Awards', u'Genre', u'tomatoUserMeter',
 u'imdbRating', u'Language', u'Country', u'imdbpy_budget', u'BoxOffice', u'Runtime',
 u'tomatoReviews', u'imdbID', u'Metascore', u'Response', u'tomatoRating', u'Year',
 u'imdbpy_gross']

#create movies dataframe
movies = pd.DataFrame(columns=cols)

i=0
for i in range(len(imdb_ids)-1):

    start = time.time()
    req = urllib2.Request(url + str(imdb_ids.ix[i,0]), None, headers) #request page
    response = urllib2.urlopen(req) #actually call the html request
    the_page = response.read() #read the json from the omdbapi query
    movie_json = json.loads(the_page) #convert the json to a dict

    #get the gross revenue and budget from IMDbPy
    data = imdb.IMDb()
    movie_id = imdb_ids.ix[i,['imdb_id']]
    movie_id = movie_id.to_string()
    movie_id = int(movie_id[-7:])
    data = data.get_movie_business(movie_id)
    data = data['data']
    data = data['business']

    #get the budget $ amount out of the budget IMDbPy string
    try:
        budget = data['budget']
        budget = budget[0]
        budget = budget.replace('$', '')
        budget = budget.replace(',', '')
        budget = budget.split(' ')
        budget = str(budget[0])
    except:
        None

    #get the gross $ amount out of the gross IMDbPy string
    try:
        budget = data['budget']
        budget = budget[0]
        budget = budget.replace('$', '')
        budget = budget.replace(',', '')
        budget = budget.split(' ')
        budget = str(budget[0])

        #get the gross $ amount out of the gross IMDbPy string
        gross = data['gross']
        gross = gross[0]
        gross = gross.replace('$', '')
        gross = gross.replace(',', '')
        gross = gross.split(' ')
        gross = str(gross[0])
    except:
        None

    #add gross to the movies dict
    try:
        movie_json[u'imdbpy_gross'] = gross
    except:
        movie_json[u'imdbpy_gross'] = 0

    #add gross to the movies dict
    try:
        movie_json[u'imdbpy_budget'] = budget
    except:
        movie_json[u'imdbpy_budget'] = 0

    #create new dataframe that can be merged to movies DF
    tempDF = pd.DataFrame.from_dict(movie_json, orient='index')
    tempDF = tempDF.T

    #add the new movie to the movies dataframe
    movies = movies.append(tempDF, ignore_index=True)
    end = time.time()
    time_took = round(end-start, 2)
    percentage = round(((i+1) / float(len(imdb_ids))) * 100,1)
    print i+1,"of",len(imdb_ids),"(" + str(percentage)+'%)','completed',time_took,'sec'
    #increment counter
    i+=1

#save the dataframe to a csv file
movies.to_csv('movie_data.csv', index=False)
end_time = time.time()
print round((end_time-start_time)/60,1), "min"

A: Use Eventlet library to fetch concurently
As advised in comments, you shall fetch your feeds concurrently. This can be done by using treading, multiprocessing, or using eventlet.
Install eventlet
$ pip install eventlet

Try web crawler sample from eventlet
See: http://eventlet.net/doc/examples.html#web-crawler
Understanding concurrency with eventlet
With threading system takes care of switching between your threads. This brings big problem in case you have to access some common data structures, as you never know, which other thread is currently accessing your data. You then start playing with synchronized blocks, locks, semaphores - just to synchronize access to your shared data structures.
With eventlet it goes much simpler - you always run only one thread and jump between them only at I/O instructions or at other eventlet calls. The rest of your code runs uninterrupted and without a risk, another thread would mess up with our data.
You only have to take care of following:

*

*all I/O operations must be non-blocking (this is mostly easy, eventlet provides non-blocking versions for most of the I/O you need).

*your remaining code must not be CPU expensive as it would block switching between "green" threads for longer time and the power of "green" multithreading would be gone.
Great advantage with eventlet is, that it allows to write code in straightforward way without spoiling it (too) much with Locks, Semaphores etc.
Apply eventlet to your code
If I understand it correctly, list of urls to fetch is known in advance and order of their processing in your analysis is not important. This shall allow almost direct copy of example from eventlet. I see, that an index i has some significance, so you might consider mixing url and the index as a tuple and processing them as independent jobs.
There are definitely other methods, but personally I have found eventlet really easy to use comparing it to other techniques while getting really good results (especially with fetching feeds). You just have to grasp main concepts and be a bit careful to follow eventlet requirements (keep being non-blocking).
Fetching urls using requests and eventlet - erequests
There are various packages for asynchronous processing with requests, one of them using eventlet and being namederequests see https://github.com/saghul/erequests
Simple sample fetching set of urls
import erequests

# have list of urls to fetch
urls = [
    'http://www.heroku.com',
    'http://python-tablib.org',
    'http://httpbin.org',
    'http://python-requests.org',
    'http://kennethreitz.com'
]
# erequests.async.get(url) creates asynchronous request
async_reqs = [erequests.async.get(url) for url in urls]
# each async request is ready to go, but not yet performed

# erequests.map will call each async request to the action
# what returns processed request `req`
for req in erequests.map(async_reqs):
    if req.ok:
        content = req.content
        # process it here
        print "processing data from:", req.url

Problems for processing this specific question
We are able to fetch and somehow process all urls we need. But in this question, processing is bound to particular record in source data, so we will need to match processed request with index of record we need for getting further details for final processing.
As we will see later, asynchronous processing does not honour order of requests, some are processed sooner and some later and map yields whatever is completed.
One option is to attach index of given url to the requests and use it later when processing returned data.
Complex sample of fetching and processing urls with preserving url indices
Note: following sample is rather complex, if you can live with solution provided above, skip this. But make sure you are not running into problems detected and resolved below (urls being modified, requests following redirects).
import erequests
from itertools import count, izip
from functools import partial

urls = [
    'http://www.heroku.com',
    'http://python-tablib.org',
    'http://httpbin.org',
    'http://python-requests.org',
    'http://kennethreitz.com'
]

def print_url_index(index, req, *args, **kwargs):
    content_length = req.headers.get("content-length", None)
    todo = "PROCESS" if req.status_code == 200 else "WAIT, NOT YET READY"
    print "{todo}: index: {index}: status: {req.status_code}: length: {content_length}, {req.url}".format(**locals())

async_reqs = (erequests.async.get(url, hooks={"response": partial(print_url_index, i)}) for i, url in izip(count(), urls))

for req in erequests.map(async_reqs):
    pass

Attaching hooks to request
requests (and erequests too) allows defining hooks to event called response. Each time, the request gets a response, this hook function is called and can do something or even modify the response.
Following line defines some hook to response:
erequests.async.get(url, hooks={"response": partial(print_url_index, i)})

Passing url index to the hook function
Signature of any hook shall be func(req, *args, *kwargs)
But we need to pass into the hook function also the index of url we are processing.
For this purpose we use functools.partial which allows creation of simplified functions by fixing some of parameters to specific value. This is exactly what we need, if you see print_url_index signature, we need just to fix value of index, the rest will fit requirements for hook function.
In our call we use partial with name of simplified function print_url_index and providing for each url unique index of it.
Index could be provided in the loop by enumerate, in case of larger number of parameters we may work more memory efficient way and use count, which generates each time incremented number starting by default from 0.
Let us run it:
$ python ereq.py
WAIT, NOT YET READY: index: 3: status: 301: length: 66, http://python-requests.org/
WAIT, NOT YET READY: index: 4: status: 301: length: 58, http://kennethreitz.com/
WAIT, NOT YET READY: index: 0: status: 301: length: None, http://www.heroku.com/
PROCESS: index: 2: status: 200: length: 7700, http://httpbin.org/
WAIT, NOT YET READY: index: 1: status: 301: length: 64, http://python-tablib.org/
WAIT, NOT YET READY: index: 4: status: 301: length: None, http://kennethreitz.org
WAIT, NOT YET READY: index: 3: status: 302: length: 0, http://docs.python-requests.org
WAIT, NOT YET READY: index: 1: status: 302: length: 0, http://docs.python-tablib.org
PROCESS: index: 3: status: 200: length: None, http://docs.python-requests.org/en/latest/
PROCESS: index: 1: status: 200: length: None, http://docs.python-tablib.org/en/latest/
PROCESS: index: 0: status: 200: length: 12064, https://www.heroku.com/
PROCESS: index: 4: status: 200: length: 10478, http://www.kennethreitz.org/

This shows, that:

*

*requests are not processed in the order they were generated

*some requests follow redirection, so hook function is called multiple times

*carefully inspecting url values we can see, that no url from original list urls is reported by response, even for index 2 we got extra / appended. That is why simple lookup of response url in original list of urls would not help us.

A: When web-scraping we generally have two types of bottlenecks:

*

*IO blocks - whenever we make a request, we need to wait for the server to respond, which can block our entire program.

*CPU blocks - when parsing web scraped content, our code might be limited by CPU processing power.

CPU Speed
CPU blocks are an easy fix - we can spawn more processes. Generally, 1 CPU core can efficiently handle 1 process. So if our scraper is running on a machine that has 12 CPU cores we can spawn 12 processes for 12x speed boost:
from concurrent.futures import ProcessPoolExecutor

def parse(html):
    ...  # CPU intensive parsing

htmls = [...]
with ProcessPoolExecutor() as executor:
    for result in executor.map(parse, htmls):
        print(result)

Python's ProcessPooolExecutor spawns optimal amount of threads (equal to CPU cores) and distributes task through them.
IO Speed
For IO-blocking we have more options as our goal is to get rid of useless waiting which can be done through threads, processes and asyncio loops.
If we're making thousands of requests we can't spawn hundreds of processes. Threads will be less expensive but still, there's a better option - asyncio loops.
Asyncio loops can execute tasks in no specific order. In other words, while task A is being blocked task B can take over the program. This is perfect for web scraping as there's very little overhead computing going on. We can scale to thousands requests in a single program.
Unfortunately, for asycio to work, we need to use python packages that support asyncio. For example, by using httpx and asyncio we can speed up our scraping significantly:
# comparing synchronous `requests`:
import requests
from time import time

_start = time()
for i in range(50):
    request.get("http://httpbin.org/delay/1")
print(f"finished in: {time() - _start:.2f} seconds")
# finished in: 52.21 seconds

# versus asynchronous `httpx`
import httpx
import asyncio
from time import time

_start = time()

async def main():
    async with httpx.AsyncClient() as client:
        tasks = [client.get("http://httpbin.org/delay/1") for i in range(50)]
        for response_future in asyncio.as_completed(tasks):
            response = await response_future
    print(f"finished in: {time() - _start:.2f} seconds")

asyncio.run(main())
# finished in: 3.55 seconds

Combining Both
With async code we can avoid IO-blocks and with processes we can scale up CPU intensive parsing - a perfect combo to optimize web scraping:
import asyncio
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
from time import sleep, time

import httpx

async def scrape(urls):
    """this is our async scraper that scrapes"""
    results = []
    async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
        scrape_tasks = [client.get(url) for url in urls]
        for response_f in asyncio.as_completed(scrape_tasks):
            response = await response_f
            # emulate data parsing/calculation
            sleep(0.5)
            ...
            results.append("done")
    return results

def scrape_wrapper(args):
    i, urls = args
    print(f"subprocess {i} started")
    result = asyncio.run(scrape(urls))
    print(f"subprocess {i} ended")
    return result

def multi_process(urls):
    _start = time()

    batches = []
    batch_size = multiprocessing.cpu_count() - 1  # let's keep 1 core for ourselves
    print(f"scraping {len(urls)} urls through {batch_size} processes")
    for i in range(0, len(urls), batch_size):
        batches.append(urls[i : i + batch_size])
    with ProcessPoolExecutor() as executor:
        for result in executor.map(scrape_wrapper, enumerate(batches)):
            print(result)
        print("done")

    print(f"multi-process finished in {time() - _start:.2f}")

def single_process(urls):
    _start = time()
    results = asyncio.run(scrape(urls))
    print(f"single-process finished in {time() - _start:.2f}")

if __name__ == "__main__":
    urls = ["http://httpbin.org/delay/1" for i in range(100)]
    multi_process(urls)
    # multi-process finished in 7.22
    single_process(urls)
    # single-process finished in 51.28

These foundation concepts sound complex, but once you narrow it down to the roots of the issue, the fixes are very straight and already present in Python!
For more details on this subject see my blog Web Scraping Speed: Processes, Threads and Async