Character isEmoji and some others added to java 21

In java 21 we get new API for emojis like below isEmoji(int codePoint) isEmojiComponent(int codePoint) isEmojiModifier(int codePoint) isEmojiModifierBase(int codePoint) isEmojiPresentation(int codePoint) isExtendedPictographic(int codePoint) here is a working example public static void main(String[] args) { StringBuilder sb = new StringBuilder(); sb.appendCodePoint(0x1F600); // Grinning face sb.appendCodePoint(0x1F601); // Grinning face with big eyes sb.appendCodePoint(0x1F602); // Grinning face with tears sb.appendCodePoint(0x1F923); // Rolling on the floor laughing sb.appendCodePoint(0x1F970); // Smiling face with hearts sb.appendCodePoint(0x1F60D); // Smiling face with heart-eyes sb.appendCodePoint(0x1F929); // Star-struck sb.appendCodePoint(0x1F618); // Face blowing a kiss sb.appendCodePoint(0x1F617); // Kissing face sb.appendCodePoint(0x263A); // Smiling face System.out.println(sb); var codePoint = Character.codePointAt("😃", 0); var isEmoji = Character.isEmoji(codePoint); System.out.println("😃 is an emoji: " + isEmoji); int[] surrogates = { 0xD83D, 0xDC7D }; String alienEmojiString = new String(surrogates, 0, surrogates.length); System.out.println(alienEmojiString); } seeing these emojis in vscode ...

November 20, 2023 · 1 min · Özkan Pakdil

Using sqlite with h2 console

Sometimes we(developers/programmers) may need to see database tables in tree and run some select, insert quickly on the db, H2 console is the best tool in spring boot to reach database on dev environment. And I saw a question about “Using Flyway with SQLite database in spring boot”, I have been using liquibase around 5 years but I have not tried flyway before, learning opportunity. So I preapred an example with gradle spring boot, sqlite and h2 console and answered the question. ...

October 10, 2023 · 1 min · Özkan Pakdil

Java find how many character repeating in a string

How to find how many characters are repeating in a string. @Test void anotherQ() { // Q1 -- given a String like aaabbbcccaa need to return output like a3b3c3a2. String input = "aaabbbcccazzdddxx"; char[] arr = input.toCharArray(); for (int i = 0; i < arr.length; i++) { char c = arr[i]; int charCounter = 1; System.out.print(c); while (i + 1 < arr.length && c == arr[i + 1]) { charCounter++; i++; } System.out.print(charCounter); } System.out.println("\n" + transformString(input)); } public static String transformString(String input) { if (input == null || input.isEmpty()) { return input; } StringBuilder result = new StringBuilder(); int count = 1; char currentChar = input.charAt(0); for (int i = 1; i < input.length(); i++) { char c = input.charAt(i); if (c == currentChar) { count++; } else { result.append(currentChar).append(count); count = 1; currentChar = c; } } result.append(currentChar).append(count); return result.toString(); } The output is “a3b3c3a1z2d3x2” find the working code here for full working example. ...

October 7, 2023 · 1 min · Özkan Pakdil

Add `open with fleet` into context menu in linux mint

If you install the Fleet from JetBrains Toolbox you can use the config below. Add code below to ~/.local/share/nemo/actions/fleet.nemo_action [Nemo Action] Name=Open in Fleet Comment=Open in Fleet Exec=/home/USERHOME/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet "%F" Icon-Name=Fleet Selection=Any Extensions=dir; Do not forget to change the USERHOME to your user home path. Then in files go to folder you want to open with intellij then right click and choose open in intellij.

October 3, 2023 · 1 min · Özkan Pakdil

Postgresql group by day, week and month examples

at the end of any product there will be a reporting interfaces for counts. let say you build a advertisement site which gives people to publish their products on the site. they will want to see how many people visited their product in daily basis or weekly. I used to do this in mysql like this SELECT create_time as Date, count(id) as 'Count', FROM views_of_product group by date_format(create_time, '%d %m %Y') order by date_format(create_time, '%Y-%m-%d') desc limit 7 this will nicely show last seven days views. but I needed to do same thing in postgresql. and like other days its not easily to find. I should check other report codes from project but no I allways research on google :) anyway here is my code: ...

September 30, 2023 · 2 min · Özkan Pakdil