Skip to content

Instantly share code, notes, and snippets.

jcoester /
Last active February 17, 2024 20:39
Java: Retrieve current Windows Display Scale during runtime, e.g. 1.0 = 100%, 1.25 = 125%, 1.5 = 150%, 1.75 = 175%, 2.0 = 200%
import com.sun.jna.platform.win32.GDI32;
import com.sun.jna.platform.win32.WinDef;
import java.awt.Toolkit;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
jcoester /
Last active May 22, 2023 16:35
Java: Display Screen Resolution Aspect Ratio
* Returns the aspect ratio in "X:Y" format of given width and height
* e.g. getAspectRatio(1024, 768) > "4:3"
* e.g. getAspectRatio(1920, 1080) > "16:9"
* e.g. getAspectRatio(3440, 1440) > "21:9"
* <p>
* This function also works for 1366, 768 which is mathematically not 16:9, but marketed as such.
* @param width e.g. 1920
* @param height e.g. 1080
jcoester / iso3166_1_alpha2.json
Last active March 4, 2023 12:49
List of all 676 available ISO 3166-1 alpha-2 codes (Source:
["AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "CR", "CS", "CT", "CU", "CV", "CW", "CX", "CY", "CZ", "DA", "DB", "DC", "DD", "DE", "DF", "DG", "DH", "DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS", "DT", "DU", "DV", "DW", "DX", "DY", "DZ", "EA", "EB", "EC", "ED", "EE", "EF", "EG", "EH", "EI", "EJ", "EK", "EL", "EM", "EN", "EO", "EP", "EQ", "ER", "ES", "ET", "EU", "EV", "EW", "EX", "EY", "EZ", "FA", "FB", "FC", "FD", "FE", "FF", "FG", "FH", "FI", "FJ", "FK", "FL", "FM", "FN", "FO", "FP", "FQ", "FR", "FS", "FT", "FU", "FV", "FW", "FX", "FY", "FZ", "GA", "GB", "GC", "GD", "GE", "GF", "GG", "GH", "GI", "GJ", "GK", "GL", "GM", "GN", "GO
jcoester / itunes_country_codes.json
Last active October 19, 2023 15:49
All 184 available Apple iTunes Country Stores as of March 3rd 2023. Please use the two-letter codes. Additional information is just for user convenience.
{"alpha_2":"AE","alpha_3":"ARE","name":"United Arab Emirates"},
{"alpha_2":"AG","alpha_3":"ATG","name":"Antigua and Barbuda"},