Skip to content

Instantly share code, notes, and snippets.

// https://mvnrepository.com/artifact/li.flor/NativeJFileChooser
// implementation group: 'li.flor', name: 'NativeJFileChooser', version: '1.6.3'
JFileChooser fileChooser = new NativeJFileChooser("D:\\SafwahResult_bot\\resources");
// fileChooser.setFileFilter(new FileNameExtensionFilter("images", "*.jpg")); // select files
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // select Dir
fileChooser.showSaveDialog(null);
val randomInteger = (1..10).shuffled().first()
let rondomFloat = Math.random(); // 0 >= rondomFloat < 1
const value = 10
let rondomFloat2 = Math.random() * value // 0 >= rondomFloat2 < value
let rondomInteger = Math.floor(Math.random() * value); //
function getRandomInteger(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
@ahmedhosnypro
ahmedhosnypro / ArgumentTokenizer.java
Created July 5, 2022 02:39
Tokenizes the given String into String tokens
import java.util.LinkedList;
import java.util.List;
abstract class ArgumentTokenizer {
private static final int NO_TOKEN_STATE = 0;
private static final int NORMAL_TOKEN_STATE = 1;
private static final int SINGLE_QUOTE_STATE = 2;
private static final int DOUBLE_QUOTE_STATE = 3;
private ArgumentTokenizer() {
ReadWriteLock lock = new ReentrantReadWriteLock();
// write
lock.writeLock().lock();
gson.toJson(data, writer);
lock.writeLock().unlock();
// read
lock.readLock().lock();
var objectMap = readData();
@ahmedhosnypro
ahmedhosnypro / docker-compose.yml
Created March 16, 2023 13:34
PostgreSQL composer for intellij
services:
db:
container_name: postgres
image: postgres:14.1
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
PGDATA: /data/postgres
volumes:
- db:/data/postgres
#h2
spring.datasource.url=jdbc:h2:file:../recipes_db
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
@ahmedhosnypro
ahmedhosnypro / application.properties
Created June 23, 2023 18:11
SpringBoot Postgresql
#postgresql
#spring.datasource.url=jdbc:postgresql://localhost:5332/postgresql
#spring.datasource.username=postgresql
#spring.datasource.password=root
#spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
#spring.jpa.hibernate.ddl-auto=create-drop
#spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true
@ahmedhosnypro
ahmedhosnypro / CircularQueue.kt
Created July 15, 2023 04:12
Kotlin CircularQueue
@Suppress("UNCHECKED_CAST")
class CircularQueue<T>(
private val capacity: Int,
) {
private val elements: Array<T?> = arrayOfNulls<Any?>(capacity) as Array<T?>
private var front = 0
private var rear = 0
private var count = 0
@ahmedhosnypro
ahmedhosnypro / Compose_Button_Colors.kt
Created August 16, 2023 16:34
Change button colors in jetback compose
Button{
...
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.White,
contentColor = Color.Black
),
...
}