text:
Q: Custom object drag-and-drop from FX to Swing I'm working on a JavaFX application that should interact with an existing Swing application via drag-and-drop. The data exchange via drag-and-drop actually works, but we want to rework that part of the functionality to actually exchange custom Java objects instead of simple Strings with objects serialized to JSON. The problem is, that the Swing UI does not receive the dragged data, if custom MIME types are used instead of e.g. text/plain. Below you can find a minimal example for both the drag application (JavaFX) and the drop application (Swing).
FxDrag
public class FxDrag extends Application {

    private static final DataFormat format = new DataFormat("application/x-my-mime-type");

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        BorderPane root = new BorderPane();
        root.setOnDragDetected(event -> {
            Dragboard dragboard = root.startDragAndDrop(TransferMode.COPY);
            ClipboardContent content = new ClipboardContent();
            content.putString("Test");
            // content.put(format, "Test");
            dragboard.setContent(content);
            event.consume();
        });
        stage.setScene(new Scene(root, 300, 300));
        stage.setTitle("Drag");
        stage.show();
    }
}

SwingDrop
public class SwingDrop {

    public static void main(String[] args) {
        new SwingDrop().run();
    }

    private void run() {
        JPanel panel = new JPanel();
        panel.setTransferHandler(new TransferHandler() {

            @Override
            public boolean canImport(TransferSupport support) {
                return true;
            }

            @Override
            public boolean importData(TransferSupport support) {
                Stream.of(support.getDataFlavors()).forEach(flavor -> {
                    System.out.println(flavor.getMimeType());
                });
                return super.importData(support);
            }

        });
        JFrame frame = new JFrame();
        frame.setTitle("Drop");
        frame.add(panel);
        frame.setSize(300, 300);
        frame.setVisible(true);
    }
}

When putting a String via putString to the content in the JavaFX application, the Swing application receives the drag and provides the following flavors:
application/x-java-serialized-object; class=java.lang.String
text/plain; class=java.io.Reader; charset=Unicode
text/plain; class=java.lang.String; charset=Unicode
text/plain; class=java.nio.CharBuffer; charset=Unicode
text/plain; class="[C"; charset=Unicode
text/plain; class=java.io.InputStream; charset=unicode
text/plain; class=java.nio.ByteBuffer; charset=UTF-16
text/plain; class="[B"; charset=UTF-16
text/plain; class=java.io.InputStream; charset=UTF-8
text/plain; class=java.nio.ByteBuffer; charset=UTF-8
text/plain; class="[B"; charset=UTF-8
text/plain; class=java.io.InputStream; charset=UTF-16BE
text/plain; class=java.nio.ByteBuffer; charset=UTF-16BE
text/plain; class="[B"; charset=UTF-16BE
text/plain; class=java.io.InputStream; charset=UTF-16LE
text/plain; class=java.nio.ByteBuffer; charset=UTF-16LE
text/plain; class="[B"; charset=UTF-16LE
text/plain; class=java.io.InputStream; charset=ISO-8859-1
text/plain; class=java.nio.ByteBuffer; charset=ISO-8859-1
text/plain; class="[B"; charset=ISO-8859-1
text/plain; class=java.io.InputStream; charset=windows-1252
text/plain; class=java.io.InputStream
text/plain; class=java.nio.ByteBuffer; charset=windows-1252
text/plain; class="[B"; charset=windows-1252
text/plain; class=java.io.InputStream; charset=US-ASCII
text/plain; class=java.nio.ByteBuffer; charset=US-ASCII
text/plain; class="[B"; charset=US-ASCII

I can even drop different data from various applications like browsers etc. and the Swing application provides the respective data flavors in the drop (text, images etc.).
However, if I use my custom format, no flavors are listed at all. Does Swing filter the data flavors transfered via a drag-and-drop application?

A: Old answer did not work between separate applications. New attempt below.

I managed to get this working between separate Swing and JavaFX applications in both directions. I uploaded a working example to a GitLab repository if you want to view it, but I will go over some of the basics here.
If you look at the repository you'll notice I have a Gradle subproject named model that contains the model class com.example.dnd.model.Doctor. This class is Serializable and contains three properties: firstName, lastName, and number. This project is shared between the JavaFX and Swing applications (i.e. they use the same model). In each application I have a table that displays a list of Doctors by those properties: TableView in JavaFX and JTable in Swing.
The applications allow you to drag one or more rows to the other application and append them to the end of the table. They do this by sending a list of the appropriate Doctors.
The example requires Java 10. GIF of example in action.

JavaFX
The JavaFX side I found much simpler to implement. Really, the only thing you need to work out is how to configure the appropriate DataFormat. The MIME type I used was,
application/x-my-mime-type; class=com.example.dnd.model.Doctor

The class= parameter is important on the Swing side; it is used for deserialization. After some trial-and-error I found out that when you try to drag data from Swing to JavaFX the given MIME type is prepended with JAVA_DATAFLAVOR:, making it:
JAVA_DATAFLAVOR:application/x-my-mime-type; class=com.example.dnd.model.Doctor

I had to add that to the DataFormat used in the onDragDetected handler otherwise Swing did not recognize the data format. I don't know why this is the case and I did not find documentation about this. When changing Java versions and/or platforms I'd be careful about this in case this is implementation-dependent behavior (unless you manage to find documentation).
In the end, my DataFormat was declared like so:
DataFormat format = new DataForamt(
    "JAVA_DATAFLAVOR:application/x-my-mime-type; class=com.example.dnd.model.Doctor",
    "application/x-my-mime-type; class=com.example.dnd.model.Doctor"
);

I added two identifiers, one with JAVA_DATAFLAVOR and one without, in an attempt to cover both cases (where it's needed and not). I don't know if this is necessary nor if it helps at all. I then stored this in some static final field for global access.
Then you just implement the onDragXXX handlers as you would expect.

Swing
The Swing side was a little more involved in my opinion; though that could just be because I'm more comfortable with JavaFX. I'd like to mention that the Oracle Tutorials were very useful here. There were three1 important classes related to DnD in Swing:

*

*DataFlavor

*

*Swing's DataFormat, but more complicated

*TransferHandler

*

*Basically the onDragXXX handlers as one class

*Transferable

*

*Represents the transferable data

1 - There are other classes involved but these were the three I found most important in this case.
To get this working I had to create custom implementations of TransferHandler and Transferable.
TransferHandler
import com.example.dnd.model.Doctor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.TransferHandler;

public class DoctorTransferHandler extends TransferHandler {

  @Override
  public boolean canImport(TransferSupport support) {
    return support.isDrop() && support.isDataFlavorSupported(DoctorTransferable.DOCTOR_FLAVOR);
  }

  @Override
  public boolean importData(TransferSupport support) {
    if (!canImport(support)) {
      return false;
    }
    JTable table = (JTable) support.getComponent();
    DoctorTableModel model = (DoctorTableModel) table.getModel();
    try {
      Transferable transferable = support.getTransferable();
      ArrayList<Doctor> list =
          (ArrayList<Doctor>) transferable.getTransferData(DoctorTransferable.DOCTOR_FLAVOR);
      model.addAll(list);
      return true;
    } catch (Exception ex) {
      ex.printStackTrace();
      return false;
    }
  }

  @Override
  public int getSourceActions(JComponent c) {
    return COPY_OR_MOVE;
  }

  @Override
  protected Transferable createTransferable(JComponent c) {
    JTable table = (JTable) c;
    DoctorTableModel model = (DoctorTableModel) table.getModel();
    return new DoctorTransferable(model.getAll(table.getSelectedRows()));
  }

  @Override
  protected void exportDone(JComponent source, Transferable data, int action) {
    if (action == MOVE) {
      JTable table = (JTable) source;
      DoctorTableModel model = (DoctorTableModel) table.getModel();
      model.removeAll(model.getAll(table.getSelectedRows()));
    }
  }

}
Transferable
import com.example.dnd.model.Doctor;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

public class DoctorTransferable implements Transferable {

  public static final DataFlavor DOCTOR_FLAVOR;

  static {
    try {
      DOCTOR_FLAVOR = new DataFlavor("application/x-my-mime-type; class=java.util.ArrayList");
    } catch (ClassNotFoundException ex) {
      throw new RuntimeException(ex);
    }
  }

  private final ArrayList<Doctor> doctors;

  public DoctorTransferable(Collection<? extends Doctor> doctors) {
    this.doctors = new ArrayList<>(doctors);
  }

  @Override
  public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DOCTOR_FLAVOR};
  }

  @Override
  public boolean isDataFlavorSupported(DataFlavor flavor) {
    return DOCTOR_FLAVOR.equals(flavor);
  }

  @Override
  public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (DOCTOR_FLAVOR.equals(flavor)) {
      return doctors;
    }
    throw new UnsupportedFlavorException(flavor);
  }

}

If you look in at the declaration of the DataFlavor, inside the Transferable, you'll see I'm using the same MIME type as in JavaFX minus the JAVA_DATAFLAVOR: bit.
I believe the most import part is creating your own Transferable that handles your custom object. This Transferable will be created in the protected TransferHandler#createTranserfable method. It wasn't until I realized I needed to do this that I managed to get this to work. It's the Transferable that's responsible for reporting the DataFlavor and how to retrieve the objects.
The next two important things you have to do is override canImport and importData. These methods handle whether or not the dragged over data can be successfully dropped and, if it is, how to add it to the Swing component. My example is quite simple and adds the data to the end of the JTable's model.
For exporting data you should also override exportDone. This method is responsible for performing any cleanup if the transfer involved moving data rather than just copying it.

I reached this solution through a decent amount of trial and error. As a result of that, combined with the fact I wanted to keep this as simple as I could, a lot of "standard" behavior is not implemented. For instance, data is always appended to the bottom of the table rather than inserted where dropped. On the JavaFX side the drag handlers are on the entire TableView rather than on each TableCell (which would make more sense, I think).
I hope this works for you. If not, please let me know.

A: Just for convenience, I'll add a combination of the excellent solution by @Slaw and the minimal example from my question. To get a better insight, take a look at his answer, as it is way more detailed.

FxDrag
public class FxDrag extends Application {

    public static final DataFormat FORMAT = new DataFormat(
        "JAVA_DATAFLAVOR:application/x-my-mime-type; class=java.lang.String",
        "application/x-my-mime-type; class=java.lang.String");

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        BorderPane root = new BorderPane();
        root.setOnDragDetected(event -> {
            Dragboard dragboard = root.startDragAndDrop(TransferMode.COPY);
            ClipboardContent content = new ClipboardContent();
            content.put(FORMAT, "Test123");
            dragboard.setContent(content);
            event.consume();
        });

        stage.setScene(new Scene(root, 300, 300));
        stage.setTitle("Drag");
        stage.show();
    }

}

SwingDrop
public class SwingDrop {

    public static final DataFlavor FLAVOR;

    static {
        try {
            FLAVOR = new DataFlavor("application/x-my-mime-type; class=java.lang.String");
        } catch (ClassNotFoundException ex) {
            throw new RuntimeException(ex);
        }
    }

    public static void main(String[] args) {
        new SwingDrop().run();
    }

    private void run() {
        JPanel panel = new JPanel();
        panel.setTransferHandler(new TransferHandler() {

            @Override
            public boolean canImport(TransferSupport support) {
                return support.isDataFlavorSupported(FLAVOR);
            }

            @Override
            public boolean importData(TransferSupport support) {
                if (!canImport(support)) return false;
                try {
                    String data = (String) support.getTransferable().getTransferData(FLAVOR);
                    System.out.println(data);
                    return true;
                } catch (UnsupportedFlavorException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return false;
            }

        });
        JFrame frame = new JFrame("Drop");
        frame.getContentPane().add(panel);
        frame.setSize(300, 300);
        frame.setVisible(true);
    }

}

DragAndDrop operations from the FX applications to the Swing application are possible with these example applications. It is not possible to drag to any other application, even if the transfered data is just a plain String. This works just as intended to improve the usability.


text:
Q: XML Lint parse XML This is my XML file
<?xml version="1.0" encoding="UTF-8"?>
<Environment xmlns="http://schemas.dmtf.org/ovf/environment/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" xmlns:ve="http://www.vmware.com/schema/ovfenv" oe:id="" ve:vCenterId="">
  <PlatformSection>
    <Kind>VMware ESXi</Kind>
    <Version>7.0.0</Version>
    <Vendor>VMware, Inc.</Vendor>
    <Locale>en</Locale>
  </PlatformSection>
  <PropertySection>
    <Property oe:key="test" oe:value="test123"/>
    <Property oe:key="testing" oe:value="testing123"/>
  </PropertySection>
  <ve:EthernetAdapterSection>
    <ve:Adapter ve:mac="" ve:network="" ve:unitNumber="7"/>
  </ve:EthernetAdapterSection>
</Environment>

I want to parse it using XMLLint and fetch all  "oe:key" and "oe:value"
I tried following commands:

*

*xmllint --xpath "string(//PlatformSection)" file1.xml

*xmllint --xpath "string(//Environment)" file1.xml
But both are returning blank. Similarly, I tried for Property and PropertySection and getting a blank response.

A: The input XML contains namespaces. All elements are bound to the following namespace: xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
Please try the following XPath:
/oe:Environment/oe:PlatformSection

Or
/oe:Environment/oe:PropertySection/oe:Property/@oe:key

Or try namespace wildcard approach
/*[local-name()='Environment']/*[local-name()='PlatformSection']

To get first oe:key attribute
/*[local-name()='Environment']/*[local-name()='PropertySection']/*[local-name()='Property'][1]/@oe:key

To get all attributes
/*[local-name()='Environment']/*[local-name()='PropertySection']/*[local-name()='Property'][1]/@*

One more approach is outlined here: xmllint for XML Namspace

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to detect smooth curves in matlab I am trying to detect a bent conveyor in an image. I used the following code using Hough transform to detect its edges
%# load image, and process it
I = imread('ggp\2.jpg');
g = rgb2gray(I);
bw = edge(g,'Canny');

[H,T,R] = hough(bw);

P  = houghpeaks(H,500,'threshold',ceil(0.4*max(H(:))));

% I apply houghlines on the grayscale picture, otherwise it doesn't detect
% the straight lines shown in the picture
lines = houghlines(g,T,R,P,'FillGap',5,'MinLength',50);
figure, imshow(g), hold on

for k = 1:length(lines)

    xy = [lines(k).point1; lines(k).point2];

    deltaY = xy(2,2) - xy(1,2);
    deltaX = xy(2,1) - xy(1,1);
    angle = atan2(deltaY, deltaX) * 180 / pi;
    if (angle == 0)

        plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');

        % Plot beginnings and ends of lines
        plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
        plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
    end
end

As it is shown, two straight lines successfully detect top and bottom edges of the conveyor but I don't know how to detect if it is bent or not (in the picture it is bent) and how to calculate the degree of that.
The curve approximately is drawn manually in the picture below (red color):

I found no code or function for Hough transform in matlab to detect such smooth curves (e.g., 2nd degree polynomials: y= a*x^2). Any other solution is also welcome.
It's the original image:

A: Looking at your straight lines detecting the conveyor belt, I assume you can focus your processing around the region of interest (rows 750 to 950 in the image).
Proceeding from that point:
oimg = imread('http://i.stack.imgur.com/xfXUS.jpg');  %// read the image
gimg = im2double( rgb2gray( oimg( 751:950, :, : ) ) );  %// convert to gray, only the relevant part
fimg = imfilter(gimg, [ones(7,50);zeros(1,50);-ones(7,50)] );  %// find horizontal edge

Select only strong horizontal edge pixels around the center of the region
[row, col] = find(abs(fimg)>50);
sel = row>50 & row < 150 & col > 750 & col < 3250;
row=row(sel);
col=col(sel);

Fit a 2nd degree polynom and a line to these edge points
[P, S, mu] = polyfit(col,row,2);
[L, lS, lmu] = polyfit(col, row, 1);

Plot the estimated curves
xx=1:4000;
figure;imshow(oimg,'border','tight');
hold on;
plot(xx,polyval(P,xx,[],mu)+750,'LineWidth',1.5,'Color','r');
plot(xx,polyval(L,xx,[],lmu)+750,':g', 'LineWidth', 1.5);

The result is

You can visually appreciate how the 2nd degree fit P fits better the boundary of the conveyor belt. Looking at the first coefficient
>> P(1)
ans =
1.4574

You see that the coefficient of x^2 of the curve is not negligible making the curve distinctly not a straight line.


text:
Q: Writing raw bytes to iostream I was working on my custom buffer and stream recently and got stuck at the fact that I can't call my stream's behaviour from a pointer to iostream.
template <int N>
std::iostream& myStream::operator<<(char (&rhs) [N])
{
    write(rhs, N);
    return *this;
}

myStream* pS = new myStream();
std::iostream& s = *pS;
char buf[5] = "ABCD";
s << buf;

I've overridden operator<< in my class but, as I imagine the iostream's operator<< should be virtual in order for this to work, am I right? Is there a way to get past this?
EDIT2:
code to test std::ostream::operator<<, ibuf is a mutable vector, overflow method, as listed above.
int ByteBuffer::overflow(int c) {
    std::vector<char>* buf = ibuf__;
    buf->resize(buf->capacity() * 2.5);
    std::ptrdiff_t putDiff = pptr() - pbase();
    setp(buf->data(), buf->data() + putDiff, buf->data() + buf->capacity());
    if (c != EOF)
        return sputc(c);
    return -1;
}

mutable std::vector<char>* ibuf__;

int main(int argc, char** argv) {
    ByteBuffer bb;
    iostream s(&bb);

    char buf[4] = { 'A', 'B', 'C', 'D' };
    s << buf;
    s << buf << (char)0;
    return 0;
}

As a result I can see that ibuf has "ABCD!@#$ABCD!@#$" inside the buffer, where !@#$ stands for a random sequence of characters (but after both ABCD's it's the same sequence). That's why I assume, it seeks '\0'.


text:
Q: Analytic continuation in the Hardy class of analytic functions arcoss the boundary I have the following question, which I need help addressing.
If $U\subset \mathbb{C}$ and $D\subset\mathbb{C}$, with $\partial U\cap\partial D=\Gamma\neq\emptyset$ of positive measure, are open connected domains and $G:U\to\mathbb{C}$, $F:D\to\mathbb{C}$ such that

*

*$G$ is holomorphic on $U$,

*$F$ is holomorphic on $D$,

*$G$ has non-tangential boundary values $\tilde{G}$ a.e. on $\partial U$ with $\tilde{G}\in L^p(\partial U)$ for some $p>0$,

*$F$ has non-tangential boundary values $\tilde{F}$ a.e. on $\Gamma$ with $\tilde{F}\in L^p(\Gamma)$,

*$\tilde{F}=\tilde{G}$ a.e. on $\Gamma$,

*F is the analytic extension of $G$ across $\Gamma$, which means that eventually, $G$ is holomorphic on an open neighborhood of $\Gamma$ and that the analytic extension coincides with $F$,

*$F\in H^p(D)$, where $H^p(D)$ is the Smirnov Class of analytic functions on $D$.

Are these conditions enough for us to have $G\in H^p(U)$?


text:
Q: How to find the initial creator of an instance object in JavaScript? Let's say I have the following code:
var Foo = (function () {

    //constructor
    var Foo = function (callbackFunction) {
        this.callbackFunction = callbackFunction;
    };

    //method
    Foo.prototype = {
        run: function () {
            if (typeof(this.callbackFunction) === 'function') {
                this.callbackFunction.call(???); //??? should be the object that created this Foo instance.
            }
        }
    };
    return Foo;
})();

this is saved in foo.js
I also have the following code:
var Bar = (function () {

    //constructor
    var Bar = function (v1, v2) {
        this.v1 = v1;
        this.v2 = v2;
    };

    Bar.prototype.callback = function() {
        //'this' should be the instance of Bar
        console.log('value of v1 is ' + this.v1 + ' value of v2 is ' + this.v2);
    }

    Bar.prototype.callFoo = function() {
        this.foo = new Foo(this.callback);
        this.foo.run();
    }

    return Bar;
})();

var bar1 = new Bar('apple', 'orange');
bar1.callFoo();
var bar2 = new Bar('grape', 'banana');
bar2.callFoo();

again, this is saved inside bar.js
inside Foo, I have this line: this.callbackFunction.call(???);
So, in order to make this work, I have to pass the object that created the instance of Foo to the call function, but how?

A: My recommendation is to use the function.bind() method.
Mozilla Developer Network:

The bind() method creates a new function that, when called, has its
  this keyword set to the provided value, with a given sequence of
  arguments preceding any provided when the new function is called.

It might be difficult to find a way to pass Bar into Foo.callbackFunction, but if Bar passes in this.callbackFunction.bind(this), then Foo can just call this.callbackFunction() without passing arguments (or using call)
There are also some JavaScript libraries that let you do this in older browsers, since bind() is a relatively new feature. For instance, in Dojo it's called hitch().


text:
Q: Changing fields updates livewire @entangle field I have a component that is entangling a livewire property.
<div x-data="{show: @entangle($attributes->wire('model'))}>
    <form>
        <input type="checkbox" wire:model.defer="story.show_name" name="show_name" />
    </form>
</div>

I have a form within this component. If I update any field within the form it will send an update to the server bug it also modifies the wire:model. An example would be a checkbox. If I uncheck it then the component hides.
Example:
[
  {
    "type": "syncInput",
    "payload": {
      "name": "story.show_name",
      "value": false
    }
  },
  {
    "type": "syncInput",
    "payload": {
      "name": "show",
      "value": false
    }
  }
]

Any idea why this would suddenly be capturing all input/change events?

A: The problem was due to me adding all attributes to the component like so {{$attributes}}. This would add wire:model="show" to the element. Since my component wasn't an input field and just a div it would then accept all input events.
I replaced {{$attributes}} with {{$attributes->except('wire:model')}} to fix the problem.


text:
Q: are there simple, open source learning-friendly web apps? I was wondering if I could learn ASP.net or other web programming frameworks by studying existing functional open source apps of the simpler kind. As in, of not quite MediaWiki complexity and so forth. Perhaps something like "simple forum" or "simple web store". Something that is non-trivial and demonstrating useful functionality, but not overly complex and afflicted with hard to understand feature bloat.
So, could people suggest some apps of this kind for study? Does anybody know let's say of some straigtforward forum app in ASP.net that would be a good learning tool for an experienced programmer with minimal web app exposure? Or likewise of good open source apps for study of PHP, JavaEE and/or other popular web frameworks?

A: FOR RUBY : Apart from Ruby On Rails, have a look at
Ramaze - Zen and the Art of Programming  (The name comes from Ruby Amaze..)
Ramaze home page at Ramaze Home
FOR ASP.NET
BlogEngine.net  is a good code base for learning.
Similarly, for beginners you can refer to some of the projects from
ASP.NET Community projects, some of them are pretty good.  This do have reference to forum apps as well.
Stephen Walther has a good post on creating a Forum application in ASP.NET MVC which you can find here
Forum Application Development

A: There are many web application frameworks in most programming languages:

*

*CakePHP

*Catalyst

*Django

*Rails
All are good in getting things done fast. Most of them have screencasts that walk you through the code to a full-fledged web application. I think you should check those screencasts out.

A: For the Ruby on Rails framework, this site lists some open source apps:
http://www.opensourcerails.com

A: Different frameworks are wildly different. One application will not help you in learning another framework, so you would probably need to decide the framework first. And usually, the best introduction for a framework is it's tutorial, as they tend to take up the concepts in a logical order, while just reading code will either be hard to understand or be prone to misunderstandings that give you the wrong idea that you later will have to "unlearn".
Some frameworks I know of that are really easy to get started with are RubyOnRails, Django and Grok.


text:
Q: After + verb+ing or after + having + past participle? What are the differences between the two following sentences?

*

*She recovered well after stopping the pills.

*She recovered well after having stopped the pills?


text:
Q: I want to autofit Excel column width using the openpyxl module, but some data is formulaic. How do I get the real value through Python? I'm creating a PY script to pull data from my database and generate an Excel spreadsheet. The PY script uses a bunch of different modules, but the modules in question are pandas and openpyxl. I would like to be able to autofit the column width for all of the columns in a similar fashion to how it is done in Excel (based on content). The problem is that some of the data uses formulas to answer some common data analysis questions for the data, like "How many unique keywords are there?", and to my knowledge openpyxl really doesn't like formulas.
I've looked through a lot of Stack Overflow and what I think is the closest to what I would like is something like this: How to access the real value of a cell using the openpyxl module for python. However, none of the options (including the one above) I've tried have worked.
The following code is one of the methods I have tried:
writer = pandas.ExcelWriter(file_name, engine = "openpyxl")
writer.book = openpyxl.load_workbook(file_name, data_only = True)
writer.sheets = dict((ws.title, ws) for ws in writer.book.worksheets)
lastRow = worksheet.max_row

worksheet['L1'] = f"=\"Count of Unique Keywords = \"&sum(--(frequency(match(A2:A{lastRow},A2:A{lastRow},0),row(A2:A{lastRow})-row(A2)+1)>0))"

print (worksheet['L1'].value)

With the above code, what I'm looking to have returned from the print is: Count of Unique Keywords = 123
But instead, I am getting the Excel function:
="Count of Unique Keywords = "&sum(--(frequency(match(A2:A100,A2:A100, 0),row(A2:A100)-row(A2)+1)>0))
Sorry if this has been answered already/if the format of this question isn't perfect. This is the first question I've asked on Stack Overflow.

A: Have you tried..
worksheet['L1'] = f"=\"CONCATENATE("Count of Unique Keywords = ", SUM(--(FREQUENCY(MATCH(A2:A100,A2:A100, 0),ROW(A2:A100)-ROW(A2)+1)>0)))"

This will produce a single excel cell with "Count of Unique Keywords=" + the output from the formula assuming your function and the supporting data are working properly.


text:
Q: Updating line between divs in javascript I'm trying to make a web page, where people can click on two objects and it creates a line between those two. But I want to go further on and be able to connect the last one with another one. This is the code I have so far.
<!doctype html>

<meta charset="utf-8">
<title>Untitled Document</title>

  Draw line

But it stops with the first 2 divs. How can I update the div. Say I want div1 to be the previous div2 and div2 to be where i click.
Thanks in advance and I apologize for the stupidity of the question.
Best Regards.

A: You will need to cache the last element clicked.
See this fiddle: http://jsfiddle.net/RY6dM/
Based on your code and not doing any major changes:
$('img').click(function(){
    var $elem1 = $(this).parent();  // cache the span
    var $elem2 = $('span.last');    // cache the span with class last
    $(this).toggleClass('selected');
    if ($elem2.length > 0) {        // for the first time there is no cached element
         connect($elem1[0], $elem2[0], "#0F0", 5);
    } else {
        $elem1.addClass('last');     // for subsequent clicks, cache last element
    }
    $('span').removeClass('last');    // remove class last from all spans
    $elem1.addClass('last');          // add class last to current element
});

Also, instead of:
document.body.innerHTML += htmlLine;

you need to do a :
$('body').append($(htmlLine));


text:
Q: google-maps-api-3 - Geolocate my position and save it into a MySQL database I have been developing the practice of URL: https://developers.google.com/maps/articles/phpsqlinfo_v3 and it works, but in another example I need that the same window HTML form appears when i click the marker that shows on the  map when i use the code to geolocate my position and to save that information into a MySQL database. I'm using the code below but the HTML form window does´nt appear to save the geolocation data.
This is the code used in the webpage: phpsqlinfo_add.html (similar name of the URL Sample: https://developers.google.com/maps/articles/phpsqlinfo_v3) The other complementary webpages: phpsqlinfo_addrow.php and phpsqlinfo_dbinfo.php are similar to the example.
CODE OF: phpsqlinfo_add.html
 <!DOCTYPE html >

 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
 <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
 <title>:: DEMO ::</title>

A: The code adding the onclick event listeners & creating the infowindow was never being activated, plus you are referencing the map_canvas div instead of your map. Try this (see // * my comments * for changes):


text:
Q: how to host a Tcp server made in python how do I host a Tcp server for free? I have already tried YouTube but nothing seems to work. all the code  in the server is working but it doesn't seem to was to run online.

A: Is your server running on a network IP address, or on localhost? This sounds like an issue I was having when trying to connect my Raspberry Pi to a server on another computer using websockets. The issue I was having was that because the server was running localhost, no one outside that particular computer could see it, even though all the relevant ports were open. I had to change to use the IP address on my internal network.
Also, you'll want to make sure you have CORS support installed. Many servers block outside connections by default for security reasons, because of cross-origin script attacks. And naturally, make sure the port is open.


text:
Q: Bundler install permissions issue I have cloned prawn and I am using a local version in a rails app. The gemfile contains the line:
gem 'prawn', :path => '/home/username/prawn'

This works fine if I am logged in as username, and run bundle install as that user. The problem is, I want to have a second user usertwo and install the forked version of prawn from the directory above.
I am using the exact same Gemfile, but when running bundle install I get:
Errno::EACCES: Permission denied @ rb_sysopen - prawn-1.1.0.gem

usertwo has read access to the prawn directory, so I can't see why it would not be possible to use the local gem. Can anyone help get this working?

A: This is actually down to the behaviour of bundler. When installing a gem, it creates the .gem file in the directory where the gem files are stored.
I am looking at the source code to see if a small patch might suffice to allow me to use local gems where I don't have write permission, will update if I am successful.


text:
Q: On click of the button shift the sidebar to inside from screen I have some content on left and the sidebar on the right. On click of the cross button of the sidebar I want to translate away the sidebar to the right until it's off the screen

$(".open-file-sidenav").click(function(){
    $(".files-sidenav-wrap").addClass("file-sidenav-slidein");
    $(".files-sidenav-wrap").removeClass("file-sidenav-slideout");
    $(".feed-post").addClass("content-on-files-sidenav-open");
    $(".feed-post").removeClass("content-on-files-sidenav-closed");
    $(".files-sidenav-wrap").css("display", "block");
    // .content-on-files-sidenav-open
});
$(".close-files-sidebar-btn").click(function(){
    $(".files-sidenav-wrap").removeClass("file-sidenav-slidein");
    $(".files-sidenav-wrap").addClass("file-sidenav-slideout");
    $(".feed-post").removeClass("content-on-files-sidenav-open");
    $(".feed-post").addClass("content-on-files-sidenav-closed");
    $(".files-sidenav-wrap").css("display", "none");
});
.content-on-files-sidenav-open {
  padding-right: 0px;
  max-height: calc(100% - 0px);
  transform: translateY(0px);
}

.content-on-files-sidenav-closed {
  padding-right:0px;
  transform: translateY(0px);
}

.files-sidenav-wrap {
  width: 250px;
}

.file-sidenav-slideout {
  height: 100%;
  margin-top: 0px;
  max-height: calc(100% - 0px);
  transform: translateX(0px);
  width: 250px;
}

.main-content {
  display: flex;

some text

Attachments

        <button type="button" class="close close-files-sidebar-btn">×</button>

 this is the code i have added. this is the code i have added

A: Add the number of pixels you want the element to move in the translateX() function
OR
If you want the element to slide the entire width of the device you can use:
translate(100vw)
Before
.file-sidenav-slideout {
    height: 100%;
    margin-top: 0px;
    max-height: calc(100% - 0px);
    transform: translateX(0px);
    width: 250px;
}

After
.file-sidenav-slideout {
    height: 100%;
    margin-top: 0px;
    max-height: calc(100% - 0px);
    transform: translateX(100vw);
    width: 250px;
}

To get a smooth transition you can add this line to your files-sidenav-wrap class:
transition: all ease-in-out .4s;

A:

            $(document).ready(function() {
              $(".open-file-sidenav").click(function(){

                $(".files-sidenav-wrap").addClass("file-sidenav-slidein");
                $(".files-sidenav-wrap").removeClass("file-sidenav-slideout");
                $(".feed-post").addClass("content-on-files-sidenav-open");
                // .content-on-files-sidenav-open

            });
            $(".close-files-sidebar-btn").click(function(){

                $(".files-sidenav-wrap").removeClass("file-sidenav-slidein");
                $(".files-sidenav-wrap").addClass("file-sidenav-slideout");
                $(".feed-post").addClass("content-on-files-sidenav-closed");
            });
            });

.content-on-files-sidenav-open{
        padding-right: 0px;
        max-height: calc(100% - 0px);
        transform: translateY(0px);
      }
      .content-on-files-sidenav-closed{
        padding-right: 250px;
        transform: translateY(0px);
      }
      .files-sidenav-wrap{
        width:250px;
      }
      .file-sidenav-slideout{
        height: 100%;
        margin-top: 0px;
        max-height: calc(100% - 0px);
        transform: translateX(100px);
        width: 250px;
      }
      .main-content{
      display:flex;
     }

some text

Attachments

                <button type="button" class="close-files-sidebar-btn close" >×</button>

first of all, you forget to put your jquery code inside document.ready and your transform 0 to 100 or any other number as you want.


text:
Q: Problems ordering my collection with LINQ I have the following:
var cities = _cityRepository.GetPk(partitionKey);
var sortedCities = cities.OrderBy(item => item.RowKey.Substring(0, 4))
                         .ThenBy(item => item.ShortTitle);
return sortedCities;

Where cities is: ICollection<City>
This is giving me an error
Cannot implicitly convert type 'System.Linq.IOrderedEnumerable<Storage.Models.City>' to 'System.Collections.Generic.ICollection<Storage.Models.City>'. An explicit conversion exists (are you missing a cast?)

Can someone help me out with this. I thought I can just run LINQ to reorder.

A: add .ToList() at the end as below
var sortedCities = cities.OrderBy(item => item.RowKey.Substring(0, 4))
                         .ThenBy(item => item.ShortTitle).ToList();

probably your method has to return IOrderedEnumerable

A: "Can't cast to specified type", call .ToList:
var sortedCities = cities.OrderBy(item => item.RowKey.Substring(0, 4))
                                  .ThenBy(item => item.ShortTitle).ToList();

A: Your method seems to expect a return value of type ICollection<Storage.Models.City> but you are returning an IOrderedEnumerable<Storage.Models.City> which is more generally a IEnumerable<Storage.Models.City>.
You can either change the return type of your method or convert your return value into something that is an ICollection such as a List with ToList().


text:
Q: Error pulling docker image from GCR: "You don't have the needed permissions to perform this operation, and you may have invalid credentials." I am SSH'd into a GCE instance in Project A whose service account has Storage Admin access in Project B, where Image Foo is located. When I run docker build . from the command line of my GCE instance, I get the above error when docker tries to pull Image Foo from Project B. I have configured docker according to the instructions in the link, and authenticated using gcloud.

A: I suspect it's one or two of two things:
First, check which account you're running under on the VM (gcloud auth list). It's probably the VM's service account not your user account. This is the account that needs to be IAM'd to the bucket;
Second, ensure you've configured docker to access the account's credentials for GCR (if possible: gcloud auth configure-docker).
Then, it should work.
I repro'd your error and applied these changes and it works (link)


text:
Q: list of ints to array in c# I have a list of ints called MyList. In javascript, when we call toString on an array of numbers, it converts it into a string with each number separated with commas; I'm looking to do the same with in C#.
I tried calling .ToString() to the list but it's returning the type of the list. I'm thinking of a loop that iterates over the list and add each element to a stringbuilder, along with the comma, and then .ToString() the stringbuilder.
Is that the best way to do it?
Thanks.

A: use string.Join:
string result = string.Join(",", MyList);

A: You can use the String.Join method to "implode" the array with a separator.
e.g.:
String.Join(",", MyList);

A: try use this code :
 List<int> MyList = new List<int>();
            MyList.Add(1);
            MyList.Add(2);
            MyList.Add(3);
            MyList.Add(4);
            MyList.Add(5);
            MyList.Add(6);

            var m = string.Join(",", MyList);

            MessageBox.Show(m.ToString());


text:
Q: Get source from a  element with Jquery I'm trying to get the source of a tr element using JQuery.
For this I'm using the selector below :
$('#mygrid > table tr')

On console I can see this selector returns me this :

10/07/2018
13:09

The return is actually an object, not a string :
typeof $('#grid-historicos > table tr')
"object"

So I can't use the method .html()
So what is the right way to get the HTML source of the  element? I need only this part as a string :

A: Working fiddle.
You need to select the tr line you want to target using the index [0] in my example, then select the outerHTML and split the result then finally get the first line  :

console.log($('#mygrid > table tr')[0].outerHTML.split('\n')[0]);

      10/07/2018
      13:09
      94

      Eve
      Jackson
      94


text:
Q: "Is that" vs. "are those" in questions regarding plurality I think it's clear that the following two sentences are grammatical:

Is that a cup I see?
Are those cups I see?

However, what if you seek to inquire as to how many cups you can see?

Is that one cup or two cups I see?
Are those one cup or two cups I see?

Which of the above two sentences is correct?

A: I think your last example is awkward, although I'd hesitate to say it's wrong.
I agree it's necessary to ask what "that" is referring to, but this is not an easy question to answer. It could refer to a group of things which are seen collectively as one group, or a scene/ensemble as JavaLatte has said, but there might be other possibilities. I've had a look online but can't find much except a rather obscure entry in the OED.

c. Used with a plural n. or numeral, instead of those: now only with
  plurals treated as singulars (e.g. means, pains) or taken in a
  collective sense.

Anyway, I don't have a grammar jargon answer to this, and I suspect it's a colloquial construction, and not formal.  I should imagine in a formal piece, the writer would just avoid the problem and use different wording. However, the construction works regardless of the numbers involved (or the grammar).
Examples:
Is that one cup or two cups I see?
Is that two cups or four?
That's four cups, not two!  (this usage is definitely colloquial)
Is that four zebras or five?
Is that two moons around Saturn I see? (if this is OK for Reuters, I'd say it's good enough for anyone).

A: For the first pair of questions, we know how many things we are looking at, and are simply querying what the individual items are. For this reason, the question can, and must, reflect the number.
For the second pair of questions, we know that they are cups but not how many. The way we deal with this, when we don't know how many items, is to talk about it as the whole scene or ensemble, which is one item: this works regardless of whether there is one cup or two cups.

Is that one cup or two cups I see?

In this sentence, that is the scene or ensemble.

A: "That which I can see there is two cups."
What's represented by "that" is "what you see", not the number of objects which "what you see" contains. So, "that" is either singular or uncountable, not sure which, but it's certainly not plural. I'm thinking uncountable because it's like saying "that stuff..." but skipping the word "stuff".
"Those two which I can see there are cups."
I'm sure that by now you can see how the position of "two" changes what you're talking about from the singular perception of what you see to the (potentially) plural number of objects perceived.
Let's keep going by re-introducing the ambiguity of how many cups there are.
"That which I can see there is one or two cups." Correct.
"Those one or two which I can see there are cups." Also correct, if awkward.
So, your second example, of "Are those one cup or two cups I see?" is not correct. Your first example which says "Is that..." is correct.


text:
Q: Why could it be that my function is not getting called? I have one file like this:
//function accessLinkClick(e) {
//    e.preventDefault();
//    $('#registerLink', '#loginLink')
//        .unbind('click', accessLinkClick);
//    dialog(this);
//}

function accessLinkClick(e) {
    alert("hi")
}

and another:
$(document).ready(function () {
$('#loginLink','#registerLink')
.bind('click', accessLinkClick);
});

My HTML looks like this:
Login

I changed the name of the function in the first file, ran my code and got an error saying the function did not exist. So this proved to me that the accessLinkClick function was known. I then changed the function name back to accessLinkClick.
I step through the code and I see it goes to the bind event so it looks like the function is being bound.
However when I run my code and click on loginLink then nothing happens.
Am I doing something wrong here? Should I take away the parameter for the function for it to work?

A: The problem is your selector:
$('#loginLink','#registerLink')

You need one string instead of two:
$('#loginLink, #registerLink')

The reason for this is the 2nd argument to the jQuery function is the context. It looks for an element matching the 1st argument #loginLink that is a descendant of the 2nd argument.


text:
Q: Debug doesn't hit breakpoints in Visual Studio 2015 I have two solutions which I am running in Visual Studio 2015 , when I am on debug mode in the first one it hits the break point correctly. But with the second one it doesn't do so. I have cleaned the solution , restarted VS checked for another answers in Google and StackOverflow but none of them seems to be working. Do you know what could be the reason for not hitting the break points?

A: There could be many scenarios like codebehind page defined wrong in aspx page by mistake. If this is not the case close visual studio. There you may see a .suo file for the solution where it doesn't hit breakpoint. Delete that file. Then open vs and open that solution file again.
Let know if this helps


text:
Q: Megaware Raid 10 I have 22 disks and would like to create a Raid 10. Unfortunately my raid controller (MegaRAID SAS 9260-8i) is only capable to handle 8 arrays within a RAID 10. Because of that I could only use 16 disks in a 2 disks per array configuration. I've figured out that it would be possible to use 2 arrays with 10 disks each:
MegaCli -CfgSpanAdd -r10 -Array0[20:2,20:3,20:4,20:5,20:6,20:7,20:8,20:9,20:10,20:11] -Array1[28:1,28:2,28:3,28:4,28:5,28:6,28:7,28:8,28:9,28:10,28:11,28:12] Direct WB -a0

After reading through the manual for hours I am not sure anymore if this increases the risk of data lost. Could you comment on this? Is there any RAID10 configuration or a similar RAID level that would allow me to use all 22 disks?

A: Err, I think you're creating them wrong. The controller can handle up to 128 drives.
You should be creating one big RAID10, not doing individual mirrors.
Try using something like:
megacli -CfgLdAdd -r1 '['$(seq -f '?:%g' -s, 0 21)']' WB ADRA NoCachedBadBBU -a0


text:
Q: Implement random search algorithm in java I'm tryin to implement a simple "random search algorithm" in Java
here's a piece of the code:
//execute the algorithm
    double bestSolution; //INITIAL SOLUTION!
    Vector bestVector=null;

    for (int iter=0; iter<maxIterations; iter++) {
        //generate random vector-solution
        Vector v = Vector.generateRandomVector(problemSize, minOfSearchSpace, maxOfSearchSpace);
        double currentObjValue = objectiveFunctionValue(v);
        // if a better solution is found
        if (currentObjValue < bestSolution); {
            bestVector = v;
            bestSolution = currentObjValue;
        }
        System.out.println("Iteration: "+(iter+1)+" Best solution: "+bestSolution);
    } // end for

    System.out.println("\n\nBest solution: "+bestVector.toString()+" Objective Value: "+bestSolution);

my problem is: somehow i have to initialize the initial solution "double bestSolution".
what initial value should i give? note that for certain objective function, values such as "0" while make the convergence harder.

A: It seems natural to me to use
double bestSolution = Double.MAX_VALUE

since presumably your first guess will be the best so far, no matter what it is.
or maybe even
double bestSolution = Double.POSITIVE_INFINITY

A: Check if you're at the first iteration (iter == 0), and initialize the bestSolution with the computed solution if it's the first iteration, else compare it with the previous bestSolution.


text:
Q: CSS of WP blog part of my website does not work well in IE11 i would really appreciate if some could tell me what the problem is... My website http://webdesign.igorlaszlo.com works well in IE9, also its blog part http://webdesign.igorlaszlo.com/blog/ which is built by wp twentyeleven child theme.
The styling in IE11 my wp blog does not work well. Why ?
The html5 doctype of both parts :
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js ie ie6 lte8 lte7"><![endif]-->
<!--[if IE 7]><html class="no-js ie ie7 lte8 lte7"><![endif]-->
<!--[if IE 8]><html class="no-js ie ie8 lte8"><![endif]-->
<!--[if !IE]><!-->
    <html lang="fr-FR" style="" class=" js no-touch history">
<!--<![endif]-->

My second question is about those classes which are indicated in it : no-js, ie6, ie7, etc. Where do they come from ? I copied these codes from other websites in the beginning of the use of html5 because i saw them in many html pages... If i understood well from the web, it is something from Modernizr ? It includes the css which contain those classes ?
And what is Boilerplate ? I did not understand what is what in the history...

A: I found the problem and i publish here, maybe someone will have the same problem in IE versions...
In the <head> i had invalid meta tags which blocked several scripts and css3 styles in IE versions (except IE9), for example :
<meta content='fr-FR' http-equiv='Content-Language'/>
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>

You can check it iby W3.org validator : http://validator.w3.org/
Good chance !


text:
Q: How to reduce the number of the passes in Bellman-Ford algorithm to $n/2$? I have the following problem.

Given a directed graph $G$ and a node $S$. How can I devise a streaming algorithm to verify whether $S$ node is a mother vertex? (A Mother Vertex is a vertex through which we can reach all the other vertices of the Graph.)

The edges $(u,v)$ are being streamed.
I first solved this problem in Bellman-Ford algorithm.

*

*Let the node S be the start point, the weight of every edges in the graph $G$ be $1$ and every vertex be $-\infty$.

*Do relaxation at every edge in $n-1$ times aņd meanwhile update the number of each vertex. ($n$ is the number of vertices.)

*Check whether there is a number of a vertex is $-\infty$. If yes, we can say node $S$ isn't a mother vertex; otherwise.

This approach needs $n-1$ passes. ($n$ is the number of vertices.) But my teacher told me that it is possible to solve this problem in $n/2$ passes.
How to reduce the number of passes to $n/2$ in this problem? Can someone help me with this?
Thanks in advance!


text:
Q: Trouble checking out SVN repo - reason unknown I just got access to a website that uses SVN for version control, which is new to me.
The webroot is the traditional /var/www/vhosts/www.example.com/httpdocs.  When I'm inside that directory, I can run simple SVN commands like status and info.  When I try to checkout a copy of the repo on my local machine I run into trouble:
It keeps telling me it can't find the repository.
me@desktop-123 /c/wamp/www/tempSite
$ svn co svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com .
The authenticity of host '111.111.111.1 (111.111.111.1)' can't be established.
RSA key fingerprint is 1d:e2:8f:5e:94:1b:94:0b:92:57:c0:ca:37:36:fb:4c.
Are you sure you want to continue connecting (yes/no)? yes
username@111.111.111.1's password:
username@111.111.111.1's password:
svn: No repository found in 'svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com'

me@desktop-123 /c/wamp/www/tempSite
$ svn co svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com/httpdocs .
username@111.111.111.1's password:
svn: No repository found in 'svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com/httpdocs'

me@desktop-123 /c/wamp/www/tempSite
$ svn co svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com/httpdocs/.svn .
username@111.111.111.1's password:
svn: No repository found in 'svn+ssh://username@111.111.111.1/var/www/vhosts/www.example.com/httpdocs/.svn'

There is an empty directory /var/www/vhosts/www.example.com/trunk, but it has not been touched for many months, whereas the child .svn directories have been updated within the last week.  I don't think this is relevant, but since I'm new to this, it's confusing me.
When I run svn info I get this:
$ svn info
Path: .
URL: https://svn.example2.com/client.account/trunk
Repository Root: https://svn.example2.com/client.account
Repository UUID: 9c0d3acc-3531-50de-5176-468ba01a45ce
Revision: 1273
Node Kind: directory
Schedule: normal
Last Changed Author: mhollis
Last Changed Rev: 1273
Last Changed Date: 2014-03-20 11:14:49 -0700 (Thu, 20 Mar 2014)

Maybe I'm just too used to git, but I feel like I should be able to checkout the repo at /var/www/vhosts/www.example.com/httpdocs, no?
Is this because I'm trying to checkout someone else's repo?  Do I need to try to checkout from https://svn.example2.com/client.account?

A: *

*It's not Repository, but Working Copy of URL: https://svn.example2.com/client.account/trunk

*If it was repository, it will be not usable as "live" site

A:
The webroot is the traditional /var/www/vhosts/www.example.com/httpdocs

That's your problem! You're not understanding how Subversion is setup!
I was puzzled by that Subversion path you were giving: /var/www/vhosts/www.example.com/. It looked like it contained the entire path to the repo from the root of the server. Subversion uses a virtual root for the server (depending upon how the server is running). You have no idea by looking at the URL where on the server the Subversion repo is actually located. Much like httpd hides the actual Webroot from you.
In fact, if you use Apache httpd as your server, you'll see something like this in the http.conf file:
<Location /svn>
    DAV svn
    SVNPath /opt/subversion/repo
    ....
</Location>

This is setting up /svn as the document root of your Subversion repository. The actual repo is located somewhere else on the system, and maybe not even under the rest of the Apache setup or docroot. Let's say this is a Apache httpd running on svn.vegicorp.com. In this case, the actual Subversion repository directory is under /opt/subversion/repo. However, I use the URL of http://svn.vegicorp.com/svn as my Subversion repository root.
Taking a look at the other working directory should have clued you in. The URL you want to use isn't svn+ssh://. Subversion sites rarely use this protocol because it's so damn difficult to setup. Most use http:// or https:// because they can take advantage of Apache's ability to connect to the Active Directory/LDAP server for security. Others will use svn:// for speed.

When I'm inside that [httpd webroot] directory, I can run simple SVN commands like status and info

That's because that webroot is actually a Subversion working directory. You create the entire webpage in Subversion, then do a svn co in the httpd webroot directory and you have your website.
This way, someone can work on the webpage remotely, use version control, etc. to get everything setup. Then, they can use svn update to update the webfoot to the HEAD of the branch or root.
Go into the webfoot, and do a evn info. This will give you the URL of that checkout. Then, you can checkout the webpage locally to your system by doing svn checkout and whatever that URL is.
For example:
$ svn co https://svn.example2.com/client.account/trunk webroot-trunk
This will create on your local system a directory called webroot-trunk with the complete checkout of your webpage including the entire directory structure.
You can now modify the webpages, and when finished, do a svn commit to save the changes. When you're done, you can log onto the web server, do a svn update and bring in your changes into the server.


text:
Q: Chroot doesn't work in PHP5-FPM + nginx I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:
chroot = /home/user/www/public_html
chdir = /

In the server section of my: /etc/nginx/sites-available/default:
root /home/user/www/public_html/site.com;
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param  DOCUMENT_ROOT    /site.com;
    fastcgi_param  SCRIPT_FILENAME  /site.com$fastcgi_script_name;
    fastcgi_param  PATH_TRANSLATED  /site.com$fastcgi_script_name;
}

nginx (or fpm I think) tells me: "File not found". Ok I do following:
root /home/user/www/public_html/site.com;
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param  DOCUMENT_ROOT    /home/user/www/public_html/site.com;
    fastcgi_param  SCRIPT_FILENAME  /home/user/www/public_html/site.com$fastcgi_script_name;
    fastcgi_param  PATH_TRANSLATED  /home/user/www/public_html/site.com$fastcgi_script_name;
}

And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:
# ps aux | grep php
root      4696  0.0  1.3 221452 13768 ?        Ss   16:52   0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)

What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :)
Do I need to do something else to get chroot working?
Also I have:
# cat /var/log/nginx/site.com-errors.com.log
2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"

Ubuntu 14.04:
# php5-fpm -v
PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr  9 2014 17:11:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.

A: So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.

A: I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.


text:
Q: UIView Animation block changes take place instantly? I'm trying to Animate a UIImageView. Ive written the following code:
- (void)JumpAnimGoingDown {
NSLog(@"Started");
//Sets what happens in animation
self.character.frame = CGRectMake(self.view.frame.size.width / WidthDivision, (self.character.center.y - (self.view.frame.size.height / 18)) + self.view.frame.size.height, (self.view.frame.size.height * 4) / 45, self.view.frame.size.height / 9);

[UIView animateWithDuration:5.0f
                      delay:0
                    options:UIViewAnimationOptionCurveLinear

                 animations:^{

                     [self.view layoutIfNeeded];
                 }
                 completion:^(BOOL finished) {
                     // This block will execute when the animations finish

                     NSLog(@"Ended");

                     [self.view layoutIfNeeded];
                 }
 ];

}
But when I call this Method in code the changes take place instantly:
http://gyazo.com/b34fd7fa84ea25ace5cd656b4068e6aa
This also happens with any other code I've tried to put in this animation block. Honestly I have no idea why this is happening or how to fix this so any help is greatly appreciated!
For those wondering i have tried changing the
 [UIView animateWithDuration:5.0f

to
[UIImageView animateWithDuration:5.0f

and as this made no difference and in previous code I have written it has worked as shown then I don't think this is an issue.
Thanks

A: Any changes you want animating should be within the animations block.
- (void)JumpAnimGoingDown
{
    NSLog(@"Started");

    [UIView animateWithDuration:5.0f
                          delay:0
                        options:UIViewAnimationOptionCurveLinear

                     animations:^{
                         //Sets what happens in animation
                         self.character.frame = CGRectMake(self.view.frame.size.width / WidthDivision, (self.character.center.y - (self.view.frame.size.height / 18)) + self.view.frame.size.height, (self.view.frame.size.height * 4) / 45, self.view.frame.size.height / 9);
                     }
                     completion:^(BOOL finished) {
                         // This block will execute when the animations finish

                         NSLog(@"Ended");

                         [self.view layoutIfNeeded];
                     }
     ];
}


text:
Q: How Schema.getGlobaldescribes().get(sObjectAPIName) works, what is the path system takes? In dynamic APEX, as mentioned by SF that describe calls are heavy. So when we do the following

*

*Schema.getGlobaldescribes() - it picks org's all objects.

*Schema.getGlobaldescribes().get(SObjectAPIName) - does it pick only specific SObject mentioned in get() or start from left to right of the dot i.e. 1st will pick all the org's sObjects and then specific object.

Reason- I have a specific number of objects say 2, child and parent. Want to show the label of the fields on the basis of the user's input in a box having comma-separated API name of the fields. There is a need to show the label of the fields the user entered earlier.
e.g. Field : Account.Name,Title,FirstName, LastName (all contact fields)
Label of the input boxes should be
Account Name = (value by user)
Title = (value by user)
The answer will allow me to decide to do describe calls ones and play with them (but will be heaviest) or play with dot notation to reduce the burden on processing time.


text:
Q: How do I perform a find query in Mongoose? i have a collection of Ebooks data in mongodb like
{
    "_id" : ObjectId("58b56fe19585b10cd42981d8"),
    "cover_path" : "D:\\Ebooks\\uploads\\ebooks\\cover\\1488285665748-img1-700x400.jpg",
    "path" : "D:\\Ebooks\\uploads\\ebooks\\pdf\\1488285665257-Webservices Natraz.pdf",
    "description" : "ebook",
    "title" : "book name",
    "tag" : [
        "Hindi",
        "Other"
    ],
    "__v" : NumberInt(0)
}

Now i want to search something if keyword is little bit match from "title:" then show all related books object.
My Mongoose schema is :-
var mongoose     = require('mongoose');
var Schema       = mongoose.Schema;

var EbookSchema   = new Schema({
    title: {type:String},
    description: {type:String},
    path: {type:String,required:true},
    cover_path: {type:String,required:true},
    tag: [{ type: String }]

});
module.exports = mongoose.model('Ebook', EbookSchema);

I try :-
app.get('/ebook?search=',function(req,res){
var search_key = req.param('search');
    Ebook.find(title:'search',function(err, ebooks) {
            if (err)
                res.send(err);

            res.json(ebooks);
        });
    });

but i found null how can i do ? i only want when i search a little-bit keyword i found all related object .

A: Try wrapping your query in curlies, Mongoose expects an object as the query.
app.get('/ebook?search=',function(req,res){
var search_key = req.param('search');
    Ebook.find({title: search_key})
       .then(ebooks => res.json(ebooks))
       .catch(err => res.status(404).json({ success: false }));
    });


text:
Q: unix split skip first n of lines I have a rather large file I need to split.  However, I don't need the first 1000 lines.  I would like to start the split at line 1001 and then continue to split the file by 1000.  I know how to split by 1000, that is no problem.
CODE:
split --lines=1000 *.txt

However, I want to skip the first 1000 lines.  Is there any way to do this?

A: Use tail -n +1001 to get lines starting from 1001st line:
cat *.txt | tail -n +1001 | split --lines=1000

A: @JDE876 : We can even get the desired output using perl one liner
perl -ne "print if $. > 1000" file


text:
Q: Repairing A Corrupt .MOV Is there a way to repair a corrupt .MOV file?

*

*I am using Ubuntu 16.04.

*The only solution I found in 30 minutes of searching was to install the restricted extras package.  This didn't provide a resolution.

*I am able to open other .MOV files on my computer.

This is a 17 minute video which originated on a digital video camera.  I expect something went wrong between the video camera USB "CUT" and "PASTE".  I say this because if the microSD card has an issue the video stops recording and effectively goes into a "fail safe" mode to what has been recorded isn't lost.
I am unable to undo the CUT / PASTE and try again.
UPDATE
I know what the root cause is now: When I filmed I didn't wait for the video camera to save the video to the memory card before I powered off the camera.  This corrupted the video.  This is a learning experience.

A: Method 1:
I believe Untrunc is the perfect tool to fix your broken video file.
The Untrunc package can

restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you
  have a similar not broken video.

You can install the package following the Readme in the repository, either compile it yourself or use the Docker container method.
Then, you can use the command
./untrunc /path/to/working-video.m4v /path/to/broken-video.m4v

to fix your broken video.

Then it should churn away and hopefully produce a playable file called broken-video_fixed.m4v.

Method 2:
The online server Restore.Media has a very similar capability.  You upload the broken video and another working video taken by the same device.
The website can generate a low resolution repaired video for preview without charge.  But you need to pay if you want to download the full repaired video.

A: Try this:
Launch "VLC media player".
Go to "Media"
Select "Convert or Save"
Add "corrupt .mov file" to be fixed.
Press "Convert or Save"
Provide the file name for the destination file
Select the desired Codec from the profile list.
Press "Edit Selected Profile" button to check a specified profile settings
You can also select to add a new profile or delete any existing profile
Press "Start"

Or
Create a copy of the "corrupt .mov file"
Rename the copy of .mov file to .avi file
Launch the "VLC media player"
Select "Preferences"
Press "Input or Codecs"
Select "Always Fix next to Repair avi files"
Press "Save"


text:
Q: What is the `_container` property of Django's http.response? I can't find one good source that actually tries to explain it. The top 5 search results are just different links to source code. Right now, I'm trying to read a PDF that is being returned from a GET request, and I want to know why it's in response._container, when response is type HttpResponse. Is this PDF even what I'm looking for? Why is it the second element in the _container list?

A: Firts point, this is not a "property" but an "attribute" - in Python, "property" is a builtin type implementing generic computed attribute support, and HttpResponse._container is actually used as implementation support for the HttpResponse.content property.
So this an implementation detail (as you can tell by the single leading underscore), and hence not documented indeed (a package or framework's documentation only concerns the API, not the implementation). IOW, the best documentation here is the source code. FWIW, the source code is always the ultimate documentation, even if not always the most user-friendly ;-)
Hopefully, this part is quite easy to understand (code from the current master branch, but this part is quite stable):
https://github.com/django/django/blob/master/django/http/response.py#L308
class HttpResponse(HttpResponseBase):

    # ....

    @property
    def content(self):
        return b''.join(self._container)

    @content.setter
    def content(self, value):
        # Consume iterators upon assignment to allow repeated iteration.
        if hasattr(value, '__iter__') and not isinstance(value, (bytes, str)):
            content = b''.join(self.make_bytes(chunk) for chunk in value)
            if hasattr(value, 'close'):
                try:
                    value.close()
                except Exception:
                    pass
        else:
            content = self.make_bytes(value)
        # Create a list of properly encoded bytestrings to support write().
        self._container = [content]

    def __iter__(self):
        return iter(self._container)

    def write(self, content):
        self._container.append(self.make_bytes(content))

    # ...

    def writelines(self, lines):
        for line in lines:
            self.write(line)

As you can see, the response's content is exposed as the (read/write) content property, but is actually stored in the _container attribute. This is used to 1/ make sure the content is stored in the expected format, 2/ allow support for the response.write() and iter(response) operations.
Two points bout the use of a list here:
1/ using a list to dynamically build strings is a pretty common Python idiom - adding to a list and joining it in the end is usually faster than concatenating strings
2/ this also allow to make the HttpResponse object a "file-like" object - HttpResponse has similar close, write, writelines, flush, tell and __iter__ operations.

Why is it the second element in the _container list?

Probably because it's been written as the second element.


text:
Q: jQuery.Ajax makes the wrong request with array data I have the following array:
var idParam = ["1","2","3"];

I want to send this data as request using jQuery.ajax, what I'm doing:
        $.ajax({
        type: "GET",
        url: "Services/GetInfo.ashx",
        data: { "id": idParam },
        contentType: "application/text",
        dataType: "json",
        success: function(result)
        {
...
        },
        error: function(XMLHttpRequest, textStatus, errorThrown)
        {
            ...
        }
});

But as result I have the following ugly string: ?id[]=1&id[]=2&id[]=4 (actually it's much uglier: id%5B%5D=1&id%5B%5D=2&id%5B%5D=4).
What to do to get the normal string like: id=1&id=2&id=4 ??
Thanks

A: I'm assuming this is with jQuery 1.4 - You need to use the traditional: true parameter for $.ajax()
Or you can set it globally: (from $.param() docs)

As of jQuery 1.4, the $.param() method serializes deep objects recursively to accommodate modern scripting languages and frameworks such as PHP and Ruby on Rails. You can disable this functionality globally by setting jQuery.ajaxSettings.traditional = true;.


text:
Q: Does a voice text get deleted? I sent a voice text to a friend, but didn't save it on my thread. And it was automatically deleted after the default 2 minutes.
Does the voice text stay on the recipients messaging thread until they have a chance to hear it, and then decide weather or not to keep it?
Basically, do remote deletes on their thread happen once it's been deleted on my thread?

A: There is a setting under Settings -> Messages -> Audio Messages section. There is an "Expire" option, where you can select 'after 2 minutes' or 'never'. That is why it disappeared from your message thread.
Your friend will have it in their message thread until they listen to it, and then the phone will either remove it after 2 minutes or keep it, depending on what their setting is.
So to be clear: what you see in your message thread isn't in any way linked to what your friend sees in theirs. If your message gets delivered to two Macs, three iPads and one iPhone, this concept applies to pictures as well. Each device that has the message handles deletions independently of the others.


text:
Q: mysql jdbc connectivity error in eclipse juno plugin project I am using mysql-connector-java-5.1.18-bin.jar for database connectivity from a view.
The JDBC connectivity code has been used in 3 JSP-struts2 projects in eclipse Helios and works fine there.
Here it is throwing
***No suitable driver found for jdbc:mysql://localhost:3306/studentinfo***.

***!ENTRY org.eclipse.ui 4 0 2012-08-10 14:45:22.635
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
at org.iiitb.studentinfo.CaptureDetails.LoadToDatabase(CaptureDetails.java:50)*** and stack trace goes on.

Any clue why it is happening?

A: You have to include mysql-connector-java-5.1.18-bin.jar file into Build Path or copy it to WEB-INF/lib folder.


text:
Q: Get card boxes in the middle via bootstrap I have a problem. I have to cards (please see the picture )
As you can see, the two card boxes are not in the middle. I tried something, please see the code below. I hope you can help me out! Thank you in advance!

Card title

Some quick example text to build on the card title and make up the bulk of the card's content.

                          Go somewhere

Card title

Some quick example text to build on the card title and make up the bulk of the card's content.

                          Go somewhere

A: Just add a justify-content: center; to the parent element (that .row .padding) of the elements you want to center (the cards, in this case).

.center {
  justify-content: center;
}

Card title

Some quick example text to build on the card title and make up the bulk of the card's content.

            Go somewhere

Card title

Some quick example text to build on the card title and make up the bulk of the card's content.

            Go somewhere

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">


text:
Q: How can I replace my txt file with an array? I made a array out of a txt file and now i want to replace the array in this txt file (replace like in update).
becouse i edited the array, and now i want to replace the txt file again , i hope its possible and i hope its possible with breaklines.
string[] linesa = File.ReadLines("file1.txt").ToArray();

this is the line where i make a array of my txt.
number = Array.IndexOf(linesa, commonElement);
number = number + 1;
email  = linesa[number];
linesa[number] = "";
number = number - 1;
linesa[number] = "";

this is the edit i made and now i want to put it back in the txt file this is where i have alot of problems with.

A: Just use WriteAllLines method. It will replace the contents of the file if the file exists.
File.WriteAllLines("file1.txt", linesa);


text:
Q: How to populate statistics by Json data with dynamic keyword? I have a json which I have parsed from a remote server. Here is the Json format.
{
  "Jan 01, 2020": [
    {
      "name": "test1",
      "value": "25/25"
    },
    {
      "name": "test2",
      "value": "25/25"
    },
    {
      "name": "test3",
      "value": "1/25"
    }
  ],
  "Jan 02, 2020": [
    {
      "name": "test1",
      "value": "25/25"
    },
    {
      "name": "test2",
      "value": "4/25"
    },
    {
      "name": "test3",
      "value": "1/25"
    }
  ],
  "Jan 03, 2020": [
    {
      "name": "test1",
      "value": "2/25"
    },
    {
      "name": "test2",
      "value": "25/25"
    },
    {
      "name": "test3",
      "value": "1/25"
    }
  ]
}

As the Json has dynamic keyword I have used Map<String,Set<Statistic>> to parse the data.But unable to populate the statistics as the picture given below.
Statistic class have two properties name and value.

A:  private TableLayout mTableLayout;
  mTableLayout = (TableLayout) findViewById( R.id.tableInvoices );
        mTableLayout.setStretchAllColumns( true );
public void loadData(){

        gross = sharedPreferences.getFloat( "Gross", 0 );
        float weight = sharedPreferences.getFloat( "weight", 0 );

        c = Calendar.getInstance();`enter code here`
        SimpleDateFormat sdf = new SimpleDateFormat( "dd/MM/yy" );
        String strDate = sdf.format( c.getTime() );
        SimpleDateFormat sd1f = new SimpleDateFormat( "hh:mm" );
        String strtime = sd1f.format( c.getTime() );
        info = new Model_Info( weight, strDate, strtime );
        detail.add( 0,info );
int rows = detail.size();
        //Model_Info info = null;
        mTableLayout.removeAllViews();
        for (int i = 0; i <rows; i++) {
            info = detail.get( i );
            if (info.weight == 0.000){
                Toast.makeText( context, "Invalid weight", Toast.LENGTH_SHORT ).show();

            } else {

                // data columns
                tv = new TextView( this );
                tv.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.MATCH_PARENT ) );

                tv.setGravity( Gravity.LEFT );

                tv.setPadding( 5, 0, 0, 0 );
                tv.setBackgroundResource( R.drawable.table_border );
                tv.setText( String.valueOf( i+1 ) );
               tv.setTextSize( TypedValue.COMPLEX_UNIT_PX,textSize );
                tv.setTextColor( Color.parseColor( "#000000" ) );
                tv2 = new TextView( this );
                tv2.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.MATCH_PARENT ) );
                tv2.setGravity( Gravity.LEFT );

                tv2.setPadding( 5, 0, 0, 0 );

                tv2.setBackgroundResource( R.drawable.table_border );
                tv2.setTextColor( Color.parseColor( "#000000" ) );
                tv2.setText( df.format( info.weight ) );
                 tv2.setTextSize( TypedValue.COMPLEX_UNIT_PX, textSize );

                tv3 = new TextView( this );
                tv3.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.MATCH_PARENT ) );

                tv3.setGravity( Gravity.LEFT );
                tv3.setPadding( 5, 0, 0, 0 );

                tv3.setBackgroundColor( Color.parseColor( "#ffffff" ) );
                tv3.setBackgroundResource( R.drawable.table_border );
                tv3.setTextColor( Color.parseColor( "#000000" ) );
                tv3.setText( info.date + " " + info.time );
                tr_total.setText( String.valueOf( df.format( Total_Weight() ) ) );
             tv3.setTextSize( TypedValue.COMPLEX_UNIT_PX, textSize );

                // add table row
                final TableRow tr = new TableRow( this );
                tr.setId( rows + 1 );
                TableLayout.LayoutParams trParams = new TableLayout.LayoutParams( TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT );
                trParams.setMargins( 0, 0, 0, 0 );
                tr.setPadding( 0, 0, 0, 0 );
                tr.setLayoutParams( trParams );
                tr.addView( tv );
                tr.addView( tv2 );
                tr.addView( tv3 );
                final View vline = new View( this );
                vline.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT, 0 ) );
                mTableLayout.addView( vline );
                mTableLayout.addView( tr, trParams ); } }}

Use this format for insert the data from json to tablelayout.And your table will look like the image i have attached..


text:
Q: Why can't I store the return value of a shell function by variable assignment? function double {
    read -p "Enter the value: " value
    return $(($value * 2))
}

result=$(double)

echo "The new result is $result."

When I run this piece of code the echo command doesn't print the computed value, but when I changed result=$(double) to double; result=$? it worked. Why can't I just assign the return value directly?


text:
Q: Create LLVM bytecode from C++ classes I'm writing a compiler for a special purpose language in LLVM. I want to add bindings for a library that is already written in C++. My idea is to compile the library to LLVM bytecode (using clang -emit-llvm -S abc.c) and link it during compilation. This works well for code like
// lib.c
int f() {
    return 123;
}

But parts of the library are written like
// A.cc
class A {
    public:
        int f() { return 123; }
};

Which results in empty bytecode files. I know that I can fix this by separating the implementation:
// A.cc
class A {
    public:
        int f();
};

int A::f() {
    return 123;
}

But that would be a lot of tedious work. Is there any way to create useful bytecode from my library sources as they are? Or any other way to make the library available in my compiler?

A: You could see whether clang honours external linkage for explicit template instantiations. This might apply to non-templates, but otherwise you could 'force it' to work for templates.
Simple synopsis:
lib1.h
template <typename T=int>
struct ATemplate { T f() { return 123; } };

add a file lib1_instantiate.cpp
#include "lib1.h"
template struct ATemplate<int>;
template struct ATemplate<unsigned int>;
template struct ATemplate<long>; // etc.

This should instantiate the named templates with external linkage.
If you're stuck with a non-template class, and the trick above doesn't work for that, you might wrap it like so:
instantiate.cpp:
namespace hidden_details
{
    template <class libtype> struct instantiator : public libtype
    // derives... just do something that requires a complete type (not a forward!)
    { };
}

template struct hidden_details::instantiator<A>;

If you're out of luck you'll have to 'use' the inline members for them to get external linkage. A common trick is to use the address of these members (you won't need to implement delegating stuff):
instantiate.cpp:
static void force_use_A()
{
    void* unused = (void*) &A::f;
}

However

*

*the conversion to (void*) invokes undefined behaviour (you can't compile that with -pedantic -Werror on gcc)

*for overloads you'll have to specify ugly casts to disambiguate them

HTH

A: An alternative which works if one only wants to use a few library functions: Create a wrapper for everything that you use.
// wrapper.cc
A* A_create() {
    return new A();
}

// and so on

This way you don't have to modify your library, but it's definitely some extra typing.


text:
Q: How do different character encodings change how php does character comparison? The question is how does php handle different character encodings for character comparisons? I was told 2 things:
You can set the character encoding for php in some .ini file, and
php reads all characters as ascii (another stackoverflow post)
So which is it?
The question stems from the idea of if I have a svg font file and wanted to parse it to do character comparisons from the font with some input (a text file), do I need to be concerned about character encodings or can I do direct character comparisons?

A: Strings in PHP are implemented as arrays of bytes with an integer indicating the length of the buffer. They contain no information about how those bytes translate to characters, if at all (you can even have NUL bytes inside a PHP "string").
So whether a string literal 'á' in your script is represented by \xE1 (ISO-8859-1), \xC3\xA1 (UTF-8, C form) or \x61\xCC\x81 (UTF-8, D form) depends only on how it is encoded in the script file.
That said, PHP also has a zend.multibyte ini setting, which enables parsing source files written in arbitrary encodings (either explicitly declared with declare(encoding="...") directive, or detected), in which case string literals might be internally transliterated to PHP's mbstring.internal_encoding. That still doesn't change the internal representation of strings your script reads from external files, unless you expliclitly call mb_convert_encoding() on those.


text:
Q: Raspberry pi cluster: control_cb (pmiserv_cb.c:200): assert (!closed) failed I have 2 PIs with ip 192.168.0.2 and 192.168.0.3. I can password-less ssh to each pi. (I used to have 3001 for ssh port, but now I change it back to 22)
I follow tinkernut's pi cluster tutorial: https://www.tinkernut.com/2014/05/make-cluster-computer-part-2/
I stuck in this part of tutorial: "mpiexec -f machinefile -n 4 hostname"
My command is simply "mpiexec -f machinefile -n 2 hostname"
After running my simple command, the output is:
pi01 (works!)
when it tries to reach pi02, the errors are
host: 192.168.0.2
host: 192.168.0.3

==================================================================================================
mpiexec options:
----------------
  Base path: /home/rpimpi/mpi-install/bin/
  Launcher: (null)
  Debug level: 1
  Enable X: -1

  Global environment:
  -------------------
    MAIL=/var/mail/pi
    USER=pi
    SHLVL=1
    HOME=/home/pi
    OLDPWD=/home/pi/misc
    HUSHLOGIN=FALSE
    L1=tty1
    LOGNAME=pi
    _=./test.sh
    TERM=linux
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/rpimpi/mpi-install/bin
    LANG=en_GB.UTF-8
    LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
    SHELL=/bin/bash
    PWD=/home/pi/misc/test

  Hydra internal environment:
  ---------------------------
    GFORTRAN_UNBUFFERED_PRECONNECTED=y

    Proxy information:
    *********************
      [1] proxy: 192.168.0.2 (1 cores)
      Exec list: hostname (1 processes);

      [2] proxy: 192.168.0.3 (1 cores)
      Exec list: hostname (1 processes);

==================================================================================================

[mpiexec@pi01] Timeout set to -1 (-1 means infinite)
[mpiexec@pi01] Got a control port string of 192.168.0.2:39681

Proxy launch args: /home/rpimpi/mpi-install/bin/hydra_pmi_proxy --control-port 192.168.0.2:39681 --debug --rmk user --launcher ssh --demux poll --pgid 0 --retries 10 --usize -2 --proxy-id

Arguments being passed to proxy 0:
--version 3.1.4 --iface-ip-env-name MPIR_CVAR_CH3_INTERFACE_HOSTNAME --hostname 192.168.0.2 --global-core-map 0,1,2 --pmi-id-map 0,0 --global-process-count 2 --auto-cleanup 1 --pmi-kvsname kvs_2638_0 --pmi-process-mapping (vector,(0,2,1)) --ckpoint-num -1 --global-inherited-env 15 'MAIL=/var/mail/pi' 'USER=pi' 'SHLVL=1' 'HOME=/home/pi' 'OLDPWD=/home/pi/misc' 'HUSHLOGIN=FALSE' 'L1=tty1' 'LOGNAME=pi' '_=./test.sh' 'TERM=linux' 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/rpimpi/mpi-install/bin' 'LANG=en_GB.UTF-8' 'LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:' 'SHELL=/bin/bash' 'PWD=/home/pi/misc/test' --global-user-env 0 --global-system-env 1 'GFORTRAN_UNBUFFERED_PRECONNECTED=y' --proxy-core-count 1 --exec --exec-appnum 0 --exec-proc-count 1 --exec-local-env 0 --exec-wdir /home/pi/misc/test --exec-args 1 hostname

Arguments being passed to proxy 1:
--version 3.1.4 --iface-ip-env-name MPIR_CVAR_CH3_INTERFACE_HOSTNAME --hostname 192.168.0.3 --global-core-map 0,1,2 --pmi-id-map 0,1 --global-process-count 2 --auto-cleanup 1 --pmi-kvsname kvs_2638_0 --pmi-process-mapping (vector,(0,2,1)) --ckpoint-num -1 --global-inherited-env 15 'MAIL=/var/mail/pi' 'USER=pi' 'SHLVL=1' 'HOME=/home/pi' 'OLDPWD=/home/pi/misc' 'HUSHLOGIN=FALSE' 'L1=tty1' 'LOGNAME=pi' '_=./test.sh' 'TERM=linux' 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/rpimpi/mpi-install/bin' 'LANG=en_GB.UTF-8' 'LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:' 'SHELL=/bin/bash' 'PWD=/home/pi/misc/test' --global-user-env 0 --global-system-env 1 'GFORTRAN_UNBUFFERED_PRECONNECTED=y' --proxy-core-count 1 --exec --exec-appnum 0 --exec-proc-count 1 --exec-local-env 0 --exec-wdir /home/pi/misc/test --exec-args 1 hostname

[mpiexec@pi01] Launch arguments: /home/rpimpi/mpi-install/bin/hydra_pmi_proxy --control-port 192.168.0.2:39681 --debug --rmk user --launcher ssh --demux poll --pgid 0 --retries 10 --usize -2 --proxy-id 0
[mpiexec@pi01] Launch arguments: /usr/bin/ssh -x 192.168.0.3 "/home/rpimpi/mpi-install/bin/hydra_pmi_proxy" --control-port 192.168.0.2:39681 --debug --rmk user --launcher ssh --demux poll --pgid 0 --retries 10 --usize -2 --proxy-id 1
pi01
[mpiexec@pi01] control_cb (/home/pi/Downloads/mpich3/mpich-3.1.4/src/pm/hydra/pm/pmiserv/pmiserv_cb.c:200): assert (!closed) failed
[mpiexec@pi01] HYDT_dmxu_poll_wait_for_event (/home/pi/Downloads/mpich3/mpich-3.1.4/src/pm/hydra/tools/demux/demux_poll.c:76): callback returned error status
[mpiexec@pi01] HYD_pmci_wait_for_completion (/home/pi/Downloads/mpich3/mpich-3.1.4/src/pm/hydra/pm/pmiserv/pmiserv_pmci.c:198): error waiting for event
[mpiexec@pi01] main (/home/pi/Downloads/mpich3/mpich-3.1.4/src/pm/hydra/ui/mpich/mpiexec.c:344): process manager error waiting for completion

Research I done so far:
https://stackoverflow.com/questions/27419782/error-while-executing-mpi
mpiexec checkpointing error (RPi)
MPICH example cpi generates error when it runs on multiple fresh installed vps

A: I realized that I don't use switch to connect all PIs, instead of I use wifi dongle for each PI. I ssh to the PI1 itself, this forces to add to know_hosts under .ssh. I did this to PI2 as well. Now I am able exeucte this command: "mpiexec -f machinefile -n 2 hostname". It outputs "pi01" and "pi02". If it is still not working, I recommend you back up your .ssh and regenerate a new one.
http://kenpeter.github.io/raspberry/pi/2015/07/13/control-cb-assert-failed.html


text:
Q: Combining two lists of different object types and sorting the combined list I am trying to combine two lists of different objects for simplicity ill refer to them as List<A> and List<B> and in the end sort the combined list by their date value. I've seen most of the answers here but they dont show the whole picture on how to properly implement such use case.
I have created an inferface with a String getDate() method. So that my Class A and Class B both imeplement said interface.
 public interface CustomInterface {

    String getDate();

}

Then i have created a CustomComparator class:
    public class CustomComparator implements Comparator<CustomInterface> {

     @Override
     public int compare(CustomInterfacet1, CustomInterface t2) {
        return t1.getDate().compareTo(t2.getDate());
     }
    }

I also implemented a custom class which handles both the merge and sorting of the two given Lists.
We will call it Class Merge. With the method implemented below.
public List<Object> sortedAndMergedData(List<A> a, List<B> b) {

    List<Object> x= new ArrayList<>();
    x.addAll(a);
    x.addAll(b);
    Collections.sort(x, new CustomComprator());
    return x;

}

This is where the issue is, because im getting an error, "reason: no instance(s) of type variable(s) exist so that Object conforms to Interface" on  Collections.sort(x, new CustomComprator());

A: Change List<Object> to  List<CustomInterface> in
List<Object> x= new ArrayList<>();

provided that both your A and B classes implements CustomInterface
public List<CustomInterface> sortedAndMergedData(List<A> a, List<B> b) {

    List<CustomInterface> x= new ArrayList<>();
    x.addAll(a);
    x.addAll(b);
    Collections.sort(x, new CustomComprator());
    return x;

}


text:
Q: Router file in each page ionic 5 In ionic 5 when you create a new page, routing module file added in page folder.
The question is what is the purpose of this routing module although we have app-routing.module?
Thanks.


text:
Q: Android - Firebase Database Structure I am developing an android application where older kids can pick up younger kids and walk to school. With the application the authenticated (email and password) younger kid can choose between three adresses to get picked up. As of right now my realtime database looks like this:

Should I make a new node named "Adresses" and have a structure like this below?
  Adresses
    Sherman Street
     username: Jannie

Because I want to retrieve the name of the street and all the users that have chosen the adress in a listview

A: Your suggested method is good practice: you should try to flatten your data structure as much as possible.
I'd suggest using the user's ID for the membership of each address so it's easy to identify though. This way you can obtain a list of the members of "Sherman Street" from /addresses/Sherman Street and then match the keys listed within there to the users at /users/ with ease.
{
  "users": {
    "oXrJPVZsnMP3VKp9palSBfdnntk1": { ... },
    "xQDx3ntavhV3c02KFRPS8lxYfC62": { ... }
  },

  "addresses": {
    "Sherman Street": {
      "members": {
        "xQDx3ntavhV3c02KFRPS8lxYfC62": true
      }
    },
    "Wallaby Way": {
      "members": {
        "oXrJPVZsnMP3VKp9palSBfdnntk1": true
      }
    }
  }
}

You can also add backwards linking too by adding an address field to the user which matches the address name:
{
  "users": {
    "oXrJPVZsnMP3VKp9palSBfdnntk1": { ... },
    "xQDx3ntavhV3c02KFRPS8lxYfC62": {
      "username": "Jannie",
      "address": "Sherman Street"
    }
  },

  "addresses": {
    "Sherman Street": { ... }
  }
}

Using both together makes it easy to identify what users have selected which addresses, irrespective of which object you are currently handling within the app.
See the Firebase documentation on database structure for further details on structuring your data like this.