Шукати в цьому блозі

вівторок, 26 листопада 2019 р.

середа, 17 липня 2019 р.

Як встановити Netbeans 11 на Debian (Ubuntu, Linux Mint)

Встановили Java, скажемо версії 11.0.3, та отримуємо Netbeans потрібної 11-ї версії:
wget https://www-us.apache.org/dist/incubator/netbeans/incubating-netbeans/incubating-11.0/incubating-netbeans-11.0-bin.zip
розпакуємо отриманий архів:
unzip incubating-netbeans-11.0-bin.zip
перемістимо розпакований каталог netbeans в opt:
sudo mv netbeans /opt
потрібний для запуску файл тепер знаходиться тут /opt/netbeans/bin/netbeans.
Таким чином шлях /opt/netbeans/bin можна додати до PATH, наприклад у .bashrc:
export PATH=${PATH}:~/bin:/opt/netbeans/bin
Все, можна запускати netbeans з консолі, або ж посилання у меню чи створити іконку на робочому столі.

Модулі, що не запустилися в мене у новій версії:
 org.netbeans.libs.nashorn - No module providing the capability com.oracle.js.parser.implementation could be found.
 org.netbeans.modules.javascript2.doc - The module org.netbeans.libs.nashorn would also need to be installed.
 org.netbeans.modules.javascript2.model - The module org.netbeans.libs.nashorn would also need to be installed.
 org.netbeans.modules.javascript2.model - The module org.netbeans.modules.javascript2.doc would also need to be installed.
 org.netbeans.modules.javascript2.editor - The module org.netbeans.libs.nashorn would also need to be installed.
 org.netbeans.modules.javascript2.editor - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.editor - The module org.netbeans.modules.javascript2.doc would also need to be installed.
 org.netbeans.modules.javascript2.requirejs - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.javascript2.requirejs - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.nodejs - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.javascript2.nodejs - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript.nodejs - The module org.netbeans.modules.javascript2.nodejs would also need to be installed.
 org.netbeans.modules.html.angular - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.html.angular - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.prototypejs - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.extjs - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.javascript2.extjs - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.knockout - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.html.knockout - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.html.knockout - The module org.netbeans.modules.javascript2.knockout would also need to be installed.
 org.netbeans.modules.javascript2.jquery - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.javascript2.jquery - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.javascript2.extdoc - The module org.netbeans.modules.javascript2.doc would also need to be installed.
 org.netbeans.modules.javascript2.jsdoc - The module org.netbeans.modules.javascript2.doc would also need to be installed.
 org.netbeans.modules.javascript2.sdoc - The module org.netbeans.modules.javascript2.doc would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.prototypejs would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.nodejs would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.requirejs would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.knockout would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.jsdoc would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.extjs would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.jquery would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.extdoc would also need to be installed.
 org.netbeans.modules.javascript2.kit - The module org.netbeans.modules.javascript2.sdoc would also need to be installed.
 org.netbeans.modules.javascript2.source.query - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.web.client.kit - The module org.netbeans.modules.javascript.nodejs would also need to be installed.
 org.netbeans.modules.web.client.kit - The module org.netbeans.modules.javascript2.source.query would also need to be installed.
 org.netbeans.modules.web.kit - The module org.netbeans.modules.web.client.kit would also need to be installed.
 org.netbeans.modules.web.struts - The module org.netbeans.modules.web.kit would also need to be installed.
 org.netbeans.modules.spring.webmvc - The module org.netbeans.modules.web.kit would also need to be installed.
 org.netbeans.modules.websvc.kit - The module org.netbeans.modules.web.kit would also need to be installed.
 org.netbeans.modules.j2ee.kit - The module org.netbeans.modules.web.kit would also need to be installed.
 org.netbeans.modules.web.jsf.kit - The module org.netbeans.modules.web.kit would also need to be installed.
 org.netbeans.modules.web.primefaces - The module org.netbeans.modules.web.jsf.kit would also need to be installed.
 org.netbeans.modules.html.ojet - The module org.netbeans.modules.javascript2.editor would also need to be installed.
 org.netbeans.modules.html.ojet - The module org.netbeans.modules.html.knockout would also need to be installed.
 org.netbeans.modules.html.ojet - The module org.netbeans.modules.web.client.kit would also need to be installed.
 org.netbeans.modules.html.ojet - The module org.netbeans.modules.javascript2.model would also need to be installed.
 org.netbeans.modules.websvc.restkit - The module org.netbeans.modules.websvc.kit would also need to be installed.
але це певно вже зовсім інша історія…

SSH: Enables the sharing of multiple sessions over a single network connection.

Маленький нотаток щодо організації багатьох з'єднань (сесій) через один конект.
Ну всі ми часто-густо кудись ходимо по ssh і можливо навіть відкриваємо декілька з'єднань (звісно, якщо не є прихильниками screen). Так от, сам процес з'єднання можна значно прискорити. ;)
Редагуємо .ssh/config і десь на його початку описуємо загальні вимоги щодо з'єднань з використанням можливостей "sharing of multiple sessions":
host *
        ControlMaster auto
        ControlPath ~/.ssh/control/%r@%h:%p
        ControlPersist 10m
Що ми при цьому отримуємо? Значне прискорення підключення по ssh при повторному з'єднанні з віддаленим хостом!

Про опції:
  • ControlMaster - вмикає саму можливість "sharing of multiple sessions". Може приймати параметр auto, ask або autoask.
  • ControlPath - місце де буде створюватися сокет
  • ControlPersist - можна вказати який час будемо пам'ятати про попереднє з'єднання, якщо його було "розірвано". Може також приймати параметр no, тобто не пам'ятати й розривати одразу як останній клієнт покинув віддалене місце призначення. А можна вказати 0, тоді навпаки про з'єднання будемо пам'ятати доти доки не скажемо:
    ssh -O exit
Хочете дізнатися більше? man ssh_config ;)

понеділок, 15 липня 2019 р.

IPv6: як знайти свій DUID?

Можна спробувати уважно прочитати IPv6 configuration після чого намалювати маленький скриптик-однострочник:
$ sudo dmidecode | awk '$1~/^UUID:$/ { printf("0x0004%s\n", $2) }' | tr -d \- 
0x0004a016be68aa87df11b60f20cf301946f7
або так:
$ sudo cat /sys/devices/virtual/dmi/id/product_uuid | awk '{ printf("0x0004%s\n", $1) }' | tr -d \- 
0x0004a016be68aa87df11b60f20cf301946f7

вівторок, 2 липня 2019 р.

Debian, Oracle та Java - нескінченна історія

Не пройшло й 20 років як Oracle почали публікувати Java у вигляді deb-пакетів. Щоправда автоматичного оновлення alternatives як не було так й немає. Але й так добре :)

Але ж такі дрібниця як відсутність автоматичного налаштування alternatives нас не зупинять!

Для початку все ж раджу встановити наявний останній OpenJDK, для цього уважно читаємо інструкцію з Debian Wiki. Це само по собі дозволить мати налаштовані на OpenJDK посилання alternatives та man-и до них.

Далі робимо архів  поточних alternatives, так, про всяк випадок:
tar cJf /tmp/java-alternatives.tar.xz $( \
  ls -l /etc/alternatives/* | \
  awk '$11~/\/jvm\// && $11!~/\.1\.gz$/ { print $9 }' \
)
Ну, а потім будь-яким чином отримуємо список нових посилань та оновлюємо alternatives з OpenJDK на JDK, наприклад так:
ls -l /etc/alternatives/* |   awk '$11~/\/jvm\// && $11!~/\.1\.gz$/ { printf("test -f %s && ( sudo rm %s; sudo ln -s %s %s )\n", $11, $9, $11, $9) }' |   sed "s,/java-8-openjdk-amd64/,/jdk-11.0.3/,g;s,/jre/,/,g" > java-alternatives-new
chmod +x java-alternatives-new
./java-alternatives-new
У разі будь-яких негараздів завжди можемо відкатитися до версії alternatives яку зберегли в архів :)

Подивимося поточну версію java та javac:

$ java -version
java version "11.0.3" 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)
$ javac -version
javac 11.0.3
та перевіримо, що у нас наразі залишилося в alternatives, що вказує не на поточну версію:
ls -l /etc/alternatives/ | grep java | grep -v \.1\.gz
…трохи є :(

четвер, 4 жовтня 2018 р.

git - відновлення пошкодженого локального репозиторію

Отримав нещодавно, після "раптового" зникнення електроенергії, помилку
error: object file .git/objects/52/29e2cbdd8cd8d8bef72431eba74fd70455e734 is empty
error: object file .git/objects/52/29e2cbdd8cd8d8bef72431eba74fd70455e734 is empty
fatal: loose object 5229e2cbdd8cd8d8bef72431eba74fd70455e734 (stored in .git/objects/52/29e2cbdd8cd8d8bef72431eba74fd70455e734) is corrupt
Постала задача відновити репозиторій.
Виявилося, що зробити це відносно просто:
mv -v .git .git_old &&            # remove old git
git init &&                       # initialise new repo
git remote add origin "${url}" && # link to old repo
git fetch &&                      # get old history
git reset origin/master --mixed   # force update to old history
Також до уваги пропонується наступний скрипт (чесно взятий звідси):
#!/bin/bash

# Author: Zoey Llewellyn "Zobean" Hewll
#
# Usage: fix-git [REMOTE-URL]
#   Must be run from the root directory of the repository.
#   If a remote is not supplied, it will be read from .git/config
# 
# For when you have a corrupted local repo, but a trusted remote.
# This script replaces all your history with that of the remote.
# If there is a .git, it is backed up as .git_old, removing the last backup.
# This does not affect your working tree.
#
# This does not currently work with submodules!
# This will abort if a suspected submodule is found.
# You will have to delete them first
# and re-clone them after (with `git submodule update --init`)
#
# Error codes:
# 1: If a url is not supplied, and one cannot be read from .git/config
# 4: If the url cannot be reached
# 5: If a git submodule is detected


if [[ "$(find -name .git -not -path ./.git | wc -l)" -gt 0 ]] ;
then
    echo "It looks like this repo uses submodules" >&2
    echo "You will need to remove them before this script can safely execute" >&2
    echo "Then use \`git submodule update --init\` to re-clone them" >&2
    exit 5
fi

if [[ $# -ge 1 ]] ;
then
    url="$1"
else
    if ! url="$(git config --local --get remote.origin.url)" ;
    then
        echo "Unable to find remote 'origin': missing in '.git/config'" >&2
        exit 1
    fi
fi
url_base="$(echo "${url}" | sed -E 's;^([^/]*://)?([^/]*)(/.*)?$;\2;')"
echo "Attempting to access ${url_base} before continuing"
if ! wget -p "${url_base}" -O /dev/null -q --dns-timeout=5 --connect-timeout=5 ;
then
    echo "Unable to reach ${url_base}: Aborting before any damage is done" >&2
    exit 4
fi

echo
echo "This operation will replace the local repo with the remote at:"
echo "${url}"
echo
echo "This will completely rewrite history,"
echo "but will leave your working tree intact"
echo -n "Are you sure? (y/N): "

read confirm
if ! [ -t 0 ] ; # i'm open in a pipe
then
    # print the piped input
    echo "${confirm}"
fi
if echo "${confirm}"|grep -Eq "[Yy]+[EeSs]*" ; # it looks like a yes
then
    if [[ -e .git ]] ;
    then
        # remove old backup
        rm -vrf .git_old | tail -n 1 &&
        # backup .git iff it exists
        mv -v .git .git_old
    fi &&
    git init &&
    git remote add origin "${url}" &&
    git config --local --get remote.origin.url | sed 's/^/Added remote origin at /' &&
    git fetch &&
    git reset origin/master --mixed
else
    echo "Aborting without doing anything"
fi

пʼятниця, 21 вересня 2018 р.

Список великих таблиць у MySQL

Стала задача, з'ясувати таблиці та індекси займають більш за все місця. Одне з можливих рішень - запит до самої БД:
SELECT CONCAT(table_schema, '.', table_name),
       CONCAT(ROUND(table_rows / 1000000, 2), 'M')                                    rows,
       CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G')                    DATA,
       CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G')                   idx,
       CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
       ROUND(index_length / data_length, 2)                                           idxfrac
FROM   information_schema.TABLES
ORDER  BY data_length + index_length DESC
LIMIT  10;

Отримуємо вивід на кшталт наступного:
+---------------------------------------+---------+--------+-------+------------+---------+
| CONCAT(table_schema, '.', table_name) | rows    | DATA   | idx   | total_size | idxfrac |
+---------------------------------------+---------+--------+-------+------------+---------+
| zabbix.history_uint                   | 492.87M | 12.36G | 9.40G | 21.76G     |    0.76 |
| zabbix.trends_uint                    | 38.00M  | 1.55G  | 0.81G | 2.36G      |    0.52 |
| zabbix.events                         | 8.82M   | 0.84G  | 1.09G | 1.93G      |    1.30 |
| zabbix.history                        | 20.60M  | 0.89G  | 0.76G | 1.65G      |    0.85 |
| zabbix.event_recovery                 | 2.69M   | 0.35G  | 0.31G | 0.66G      |    0.89 |
| zabbix.problem                        | 1.40M   | 0.20G  | 0.26G | 0.46G      |    1.29 |
| zabbix.items                          | 0.11M   | 0.10G  | 0.03G | 0.12G      |    0.27 |
| zabbix.history_str                    | 0.97M   | 0.08G  | 0.04G | 0.11G      |    0.46 |
| zabbix.trends                         | 1.07M   | 0.04G  | 0.02G | 0.06G      |    0.53 |
| zabbix.triggers                       | 0.05M   | 0.03G  | 0.00G | 0.03G      |    0.16 |
+---------------------------------------+---------+--------+-------+------------+---------+
10 rows in set (8.62 sec)