Assume that you have a program named "table-explorer.exe".
And you want to open all ".csv" and ".sas7bdat" files using this program by default in Windows.
First you need to create a file extension association with the program via these commands:
reg add HKCU\SOFTWARE\Classes\.csv /d "table-explorer" /f
reg add HKCU\SOFTWARE\Classes\.sas7bdat /d "table-explorer" /f
And then register the application:
reg add HKCU\SOFTWARE\Classes\table-explorer\shell\open\command /d "\"C:\Path\to\table-explorer.exe\"" /f
07 January, 2015
06 January, 2015
How to bind hotkeys in Java FX
It is possible to create global keyboard shortcuts using a code like this:
import static javafx.scene.input.KeyCombination.keyCombination;
...
private void initHotkeys() {
ObservableMap accelerators = stage.getScene().getAccelerators();
accelerators.put(keyCombination("Alt+S"), searchTextField::requestFocus);
accelerators.put(keyCombination("Alt+C"), columnsTextField::requestFocus);
accelerators.put(keyCombination("Alt+O"), openFileButton::fire);
accelerators.put(keyCombination("Alt+E"), exportButton::fire);
accelerators.put(keyCombination("Alt+T"), truncateButton::fire);
accelerators.put(keyCombination("Alt+H"), () -> filterChoiceBox.setValue(MATCH_HIGHLIGHT));
accelerators.put(keyCombination("Alt+F"), () -> filterChoiceBox.setValue(MATCH_FILTER));
accelerators.put(keyCombination("Alt+U"), () -> filterChoiceBox.setValue(MATCH_FILTER_UNIQUE));
accelerators.put(keyCombination("Alt+D"), () -> {
//todo some debug action
});
}
09 November, 2014
How much memory is allocated to the String object in Java
| Size in bytes | |
|---|---|
| String() object | |
| Object header | 16 |
| Hash field | 4 |
| Reference to char array | 4 |
| Char[] array | |
| Object header | 16 |
| Array length | 4 |
| Array size | N*2 |
String allocates in memory at least (24+20+N*2) bytes, where N - number of characters in the string.
If N=10 then string size = 64 bytes.
One million of these strings = 64 000 000 bytes. But also we need array or collection to store these strings.
This requires additional memory.
ArrayList<String>(1 000 000) ~= 4 000 000 bytes (4 bytes per reference to string object).
So, total size will be 68 000 000 bytes.
3,355,792 Initial 1,217,624 After GC 218,921,768 Created list of strings 76,489,936 After GC 68,000,000 Expected size in memoryBut if you have many similar strings, then using of String.intern() greatly reduces amount of allocated memory. Output:
3,355,792 Initial 1,217,792 After GC 106,750,232 Created list of strings 13,127,480 After GC 68,000,000 Expected size in memory10x less memory! 6.8 megabytes instead of 68
03 November, 2014
The best resolutions
List of multiple resolutions in the most popular proportions:
| Base width | 1/2 | 2/3 | 3/4 | 4/5 | 5/6 | 9/16 | 10/16 |
|---|---|---|---|---|---|---|---|
| 240 | 120 | 160 | 180 | 192 | 200 | 135 | 150 |
| 480 | 240 | 320 | 360 | 384 | 400 | 270 | 300 |
| 720 | 360 | 480 | 540 | 576 | 600 | 405 | 450 |
| 960 | 480 | 640 | 720 | 768 | 800 | 540 | 600 |
| 1200 | 600 | 800 | 900 | 960 | 1000 | 675 | 750 |
| 1440 | 720 | 960 | 1080 | 1152 | 1200 | 810 | 900 |
| 1680 | 840 | 1120 | 1260 | 1344 | 1400 | 945 | 1050 |
| 1920 | 960 | 1280 | 1440 | 1536 | 1600 | 1080 | 1200 |
| 2160 | 1080 | 1440 | 1620 | 1728 | 1800 | 1215 | 1350 |
| 2400 | 1200 | 1600 | 1800 | 1920 | 2000 | 1350 | 1500 |
| 2640 | 1320 | 1760 | 1980 | 2112 | 2200 | 1485 | 1650 |
| 2880 | 1440 | 1920 | 2160 | 2304 | 2400 | 1620 | 1800 |
| 3120 | 1560 | 2080 | 2340 | 2496 | 2600 | 1755 | 1950 |
| 3360 | 1680 | 2240 | 2520 | 2688 | 2800 | 1890 | 2100 |
| 3600 | 1800 | 2400 | 2700 | 2880 | 3000 | 2025 | 2250 |
| 3840 | 1920 | 2560 | 2880 | 3072 | 3200 | 2160 | 2400 |
01 November, 2014
Read SAS file in Java
Some companies (banks, medical and pharmaceutical companies) store their data in the SAS (.sas7bdat) format. This is old, legacy, but still actual format for tabular data. And this format is proprietary and fiddly.
But what if you have to work with the data from the sas-file? For me, solution is pretty simple - convert the data from the sas-file to some convenient and popular format. For example, to the MongoDB. And then access this data via nice query-like API.
In my new mini-project sas2mongo I show how to convert data from the sas-file into the MongoDB in Java.
But what if you have to work with the data from the sas-file? For me, solution is pretty simple - convert the data from the sas-file to some convenient and popular format. For example, to the MongoDB. And then access this data via nice query-like API.
In my new mini-project sas2mongo I show how to convert data from the sas-file into the MongoDB in Java.
Subscribe to:
Posts (Atom)