Skip to content

Instantly share code, notes, and snippets.

View iromu's full-sized avatar

Iván Rodríguez Murillo iromu

View GitHub Profile
#!/usr/bin/env bash
if ! [ -x "$(command -v wget)" ]; then
curl --fail --silent localhost:8080/actuator/health/liveness | grep UP || exit 1
else
wget --no-verbose --tries=1 -qO - localhost:8080/actuator/health/liveness | grep UP || exit 1
fi
#!/usr/bin/env bash
if ! [ -x "$(command -v wget)" ]; then
curl --fail --silent localhost:8080/actuator/health/liveness | grep UP || exit 1
else
wget --no-verbose --tries=1 --spider localhost:8080/actuator/health/liveness | grep UP || exit 1
fi
import org.jetbrains.annotations.Nullable;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
public class PackagePrintStream extends PrintStream {
# reinstalls ubuntu-desktop AND dependencies
sudo apt-cache depends ubuntu-desktop | awk -F ": " '{print $2}' | sed '/^$/d' | xargs sudo apt-get install --reinstall --install-recommends --yes
import java.sql.SQLException;
import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.mappings.DatabaseMapping;
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.tools.schemaframework.IndexDefinition;
/**
* @author Ivan Rodriguez Murillo
public class AnimalCustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor cd) throws Exception {
HistoryPolicy policy = new HistoryPolicy();
policy.addStartFieldName("START");
policy.addEndFieldName("END");
policy.addHistoryTableName("ANIMAL","ANIMAL_HISTORY");
policy.setShouldHandleWrites(true);
cd.setHistoryPolicy(policy);
@Entity
@Table(name = "ANIMAL_HISTORY")
public class AnimalHistory implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter
@Setter
private Long pk;
@Entity
@Table(name = "ANIMAL")
@Customizer(AnimalCustomizer.class)
public class Animal extends AbstractPersistable<Long> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Getter
@Setter
private Long id;
private Node createPage(int pageIndex) {
ProgressiveImageView iv = null;
try {
String s = files.get(pageIndex).toUri().toURL().toExternalForm();
String p = placeholders.get(pageIndex).toUri().toURL().toExternalForm();
iv = new ProgressiveImageView(s, p);
} catch (MalformedURLException e) {
e.printStackTrace();// TODO, I feel too lazy today
}
iv.setPreserveRatio(true);
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class ProgressiveImageView extends ImageView {
public ProgressiveImageView(final String image, String placeholder) {
final Image img = new Image(image, true);
img.progressProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue ov,