Skip to content

Instantly share code, notes, and snippets.

View alamenai's full-sized avatar
🏠
Working from home

Aldin Bug alamenai

🏠
Working from home
View GitHub Profile
@alamenai
alamenai / Receive mail.java
Last active August 1, 2017 02:34
Receive mail using java mail API
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package SimpleMail;
import com.sun.mail.pop3.POP3Store;
import java.io.IOException;
import java.util.Properties;
@alamenai
alamenai / RunCmd.java
Last active April 15, 2019 08:03
Run most of windows commands with java language.
/*
* Copyright 2017 M.Ala Eddine.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alamenai
alamenai / ReadImage.java
Created December 28, 2017 09:40
Read an image from database
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package readimage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@alamenai
alamenai / JFXDialog.java
Created January 4, 2018 11:06
simple code to show a dialog using JFXDialog of @jfoenix
private void showJDialog() {
JFXDialogLayout dialogContent = new JFXDialogLayout();
dialogContent.setHeading(new Text("Hello" == null ? "good" : "good" + "\n" + "Hello"));
dialogContent.setBody(new Text("Body"));
JFXButton close = new JFXButton("Close");
dialogContent.setActions(close);
JFXDialog dialog = new JFXDialog((StackPane) loginstage.getScene().getRoot(), dialogContent, JFXDialog.DialogTransition.CENTER);
close.setOnAction(new EventHandler<ActionEvent>() {
@alamenai
alamenai / JavaFXCSVTableView.java
Last active January 1, 2023 22:32
Java example read csv file and display the content in JavaFX TableView.
package javafxcsvtableview;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
@alamenai
alamenai / ChangeHTMLContent.java
Last active March 27, 2018 17:16
JavaFx example to make a changes in html file and reload it again in webview.
public void reloadContent()
{
//Using Jsoup library https://jsoup.org/cookbook/introduction/parsing-a-document
//Get html file
InputStream inputStream = Odata.class.getClass().getResourceAsStream("/web/html/template.html");
//Parse the content
org.jsoup.nodes.Document doc = Jsoup.parse(inputStream, "UTF-8", "");
//Get Element for make some changes
org.jsoup.nodes.Element content = doc.getElementById("name");
//Change the text of element
@alamenai
alamenai / Phones.json
Created March 23, 2018 22:27
Sample code to read JSON file in java
{
"countries": [
{
"code": "+7 840",
"name": "Abkhazia"
},
{
"code": "+93",
"name": "Afghanistan"
},
@alamenai
alamenai / RemoveNodeFromCustomTextField.java
Created April 23, 2018 19:47
A piece of code to remove a right/left node from CustomTextField in ControlFX
public static void removeErrorIcon(TextField textField) {
if (textField instanceof CustomTextField) {
CustomTextField customTextField = (CustomTextField) textField;
Platform.runLater(() -> {
((StackPane)customTextField.getRight().getParent()).getChildren().remove(customTextField.getRight());
});
}
}
@alamenai
alamenai / media.regex.js
Created September 15, 2020 16:37
Regular expression ( RegEx ) for images and videos
export const isVideo = url => (/\.(mp4|3gp|ogg|wmv|webm|flv|avi*|wav|vob*)$/i).test(url)
export const isImage = url => (/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i).test(url)
@alamenai
alamenai / medications.json
Created May 12, 2023 23:14
A list of medications
{
"medications": [
"Abilify",
"Abilify Maintena",
"Abiraterone",
"Acetaminophen",
"Acetylcysteine",
"Actemra",
"Actos",
"Acyclovir",