Skip to content

Instantly share code, notes, and snippets.

@Da9el00
Da9el00 / Data.java
Created November 19, 2023 20:02
Java sender receiver using multithreading
public class Data {
private String packet;
// True: receiver waits
// False: sender waits
private boolean transfer = true;
public synchronized String receive() {
while (transfer) {
try {
@Da9el00
Da9el00 / Main.kt
Created September 24, 2023 12:39
Kotlin - Making API Calls in Kotlin Without External Libraries
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URI
import java.net.URL
fun main() {
val apiUrl = "https://catfact.ninja/fact" //API endpoint
try {
@Da9el00
Da9el00 / Main.java
Created August 17, 2023 18:12
How to convert JSON to Java objects using Gson
import com.google.gson.Gson;
public class Main {
public static void main(String[] args) {
String json = """
{'name': 'Dani',
'age': 45,
'phone': 222333,
'city':'NewYork'}
@Da9el00
Da9el00 / SpringApiApplication.java
Created July 5, 2023 15:28
How to create an REST API in Spring boot using Java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringApiApplication {
public static void main(String[] args) {
SpringApplication.run(SpringApiApplication.class, args);
}
@Da9el00
Da9el00 / ModeButton.java
Last active June 26, 2023 07:40
JavaFX - Custom component - Multi-state Button
import javafx.beans.binding.Bindings;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
@Da9el00
Da9el00 / LineApplication.java
Created June 18, 2023 08:43
JavaFX - Movable Line
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class LineApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
@Da9el00
Da9el00 / Flipper.java
Last active July 24, 2024 03:13
JavaFX Custom Component
import javafx.animation.FillTransition;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
import java.io.IOException;
@Da9el00
Da9el00 / Dockerfile_mysql
Created March 15, 2023 23:09
python and MySQL
# NOTE name need to be Dockerfile
FROM mysql:latest
COPY ./databse_students.sql /docker-entrypoint-initdb.d/
@Da9el00
Da9el00 / Controller.java
Created February 25, 2023 11:21
Morse to text and text to morse - JavaFX
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.input.KeyEvent;
public class Controller {
@FXML
private TextArea textInput;
@Da9el00
Da9el00 / Calendar.fxml
Last active September 28, 2024 19:58
JavaFX Calendar View
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>