FindTheClosest

public class FindTheClosest {

    private final Number target;
    private final Number[] numbers;

    public FindTheClosest(Number target, Number[] numbers) {
        this.target = target;
        this.numbers = numbers;
    }

    public Number execute() {
        Stream<Number> stream = Arrays.stream(numbers);
        Optional<Number> optional = stream.min(Comparator.comparing(number -> {
            double delta = target.doubleValue() - number.doubleValue();
            return delta == 0 ? Integer.MAX_VALUE : Math.abs(delta + 1F / Integer.MAX_VALUE);
        }));
        return optional.orElse(target);
    }
}

Autostart Kodi on Raspbian

This is the /etc/systemd/system/kodi.service unit file:

[Unit]
Description = Kodi Media Center

# if you don't need the MySQL DB backend, this should be sufficient
After = systemd-user-sessions.service network.target sound.target

# if you need the MySQL DB backend, use this block instead of the previous
# After = systemd-user-sessions.service network.target sound.target mysql.service
# Wants = mysql.service

[Service]
User = kodi
Group = kodi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = always
RestartSec = 15

[Install]
WantedBy = multi-user.target

To install, enable and run the service:

systemctl daemon-reload
systemctl enable kodi.service
systemctl start kodi.service

The kodi user was created witht the following commands:

adduser --disabled-password --gecos "User to run Kodi Media Center" kodi
adduser kodi audio
adduser kodi video
adduser kodi plugdev
adduser kodi input

JDownloader.org – Terminal User Interface

Terminal User Interface

Conceptual Ideas

The idea about the terminal implementation is that on any computer (Windows, Linux, Linux server edition, Unix,…) the application can be ran the old-skool way, using command line aka terminals. The ideas explained on this page are only conceptual ideas so far. Implentation hasn’t started yet on this topic and even if it was those conceptual ideas stay conceptual.

Running JD

Continue reading “JDownloader.org – Terminal User Interface”

Rekomendasi Printer

Hallo,

Sedikit rekomendasi untuk printer rumahan. Kemarin baru saja beli printer Canon MP 287, cukup bagus dan sudah dilengkapi dengan sistem tinta infus. Setelah itu browsing2 tentang kriteria printer yang baik. Canon sendiri dengan thermal head print teknologi + infus sudah lebih dari cukup untuk penggunaan rumahan.Thermal print head menggunakan elemen panas untuk memuaikan dan mengeluarkan tinta dari catridge. Setelah menggunakan untuk keperluan pribadi ternyata kurang. Mengapa saya bisa katakan kurang? Continue reading “Rekomendasi Printer”

TP LINK SG105e BRICKED!!!!!!

http://192.168.0.1/menu.cgi

TFTP : http://192.168.0.1/tftpug.cgi

TFTP Firmware Upgrade
TFTP Server IP Address : 192.168.0.146
Image File Name : final.bin

http : http://192.168.0.1/httpug.cgi

reboot : http://192.168.0.1/reboot.cgi

ya ampun… nangis2 gw 1 jam-an.. untung akhirnya bisa juga diakali.. Alhamdulillah.

Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

Continue reading “Mini tutorial for configuring client-side SSL certificates.”

iluwatar/java-design-patterns: Design patterns implemented in Java

Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. Design patterns can speed up the development process by providing tested, proven development paradigms. Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns.

Source: iluwatar/java-design-patterns: Design patterns implemented in Java