java.io.StreamCorruptedException: invalid stream header: 54657374

Clearly you aren’t sending the data with ObjectOutputStream: you are just writing the bytes. If you read with readObject() you must write with writeObject(). If you read with readUTF() you must write with writeUTF(). If you read with readXXX() you must write with writeXXX(), for most values of XXX

Print PDF directly from JavaScript

Based on comments below, it no longer works in modern browsersThis question demonstrates an approach that might be helpful to you: Silent print an embedded PDF It uses the <embed> tag to embed the PDF in the document: Then you call the .print() method on the element in Javascript when the PDF is loaded: You could place the embed in … Read more

What’s the difference between SoftReference and WeakReference in Java?

From Understanding Weak References, by Ethan Nicholas: Weak references A weak reference, simply put, is a reference that isn’t strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector’s ability to determine reachability for you, so you don’t have to do it yourself. You create a weak reference … Read more

JaxbRepresentation gives error “doesnt contain ObjectFactory.class or jaxb.index”

In my case I was able to resolve this by adding a file called “jaxb.index” in the same package folder as the JAXB annotated class. In that file list the simple, non-qualified names of the annotated classes. For example, my file /MyProject/src/main/java/com/example/services/types/jaxb.index is simply one line (since I have only one JAXB typed class): which … Read more

Ruby `send` vs `call` method

To begin with, send and call are two very different methods. In ruby, the concept of object orientation takes its roots from Smalltalk. Basically, when you call a method, you are sending that object a message. So, it makes sense that when you want to dynamically call a method on an object, the method you call is send. This method has existed in … Read more

ImportError: No module named model_selection

I guess you have the wrong version of scikit-learn, a similar situation was described here on GitHub. Previously (before v0.18), train_test_split was located in the cross_validation module: However, now it’s in the model_selection module: so you’ll need the newest version. To upgrade to at least version 0.18, do: (Or pip3, depending on your version of Python). If you’ve installed it in a different way, make sure … Read more