libjansi.jnilib cannot be opened because the developer cannot be verified – macOS 10.15

If you can see this error: “libjansi.jnilib” cannot be opened because the developer cannot be verified – while working on macOS 10.15 (screen shoot looks like this)

it means you probably have issues with libjansi coming from Apache Maven.

Make sure to upgrade to version apache-maven-3.6.2.


macOS 10.15 – directory size in CLI

There is this interesting article about using NCurses Disk Usage in Arch Linux – you can find here: Cleaning root partition on Linux. I definitely prefer to stick to macOS, so I have decided to get it running from iTerm2. It’s really simple. All you have to do is to (as with other samples you can find on my blog) build it from sources.

> mkdir -p ~/opt/src
> cd ~/opt/src
> curl -O https://dev.yorhel.nl/download/ncdu-1.14.1.tar.gz
> tar zxf ncdu-1.14.1.tar.gz
> cd ncdu-1.14.1
> ./configure
> make

that’s it. Now you can benefit from it by calling: $HOME/opt/src/ncdu-1.14.1/ncdu – you can move this file to your ~/bin if you like. It’s up to you.

ncdu 1.14.1 ~ Use the arrow keys to navigate, press ? for help
--- /Users/some_user/opt/src/ncdu-1.14.1 ---------------------------
    1.0 MiB [##########] /src
  196.0 KiB [#         ]  configure
   88.0 KiB [          ]  ncdu
   52.0 KiB [          ]  aclocal.m4
   36.0 KiB [          ]  config.status
   36.0 KiB [          ]  Makefile.in
   32.0 KiB [          ]  Makefile
   32.0 KiB [          ] /deps
   24.0 KiB [          ]  config.log
   24.0 KiB [          ]  depcomp
   20.0 KiB [          ]  ncdu.1
   16.0 KiB [          ]  install-sh
   16.0 KiB [          ] /doc
    8.0 KiB [          ]  compile
    8.0 KiB [          ]  missing
    8.0 KiB [          ]  ChangeLog
    4.0 KiB [          ]  config.h
    4.0 KiB [          ]  config.h.in
    4.0 KiB [          ]  configure.ac
    4.0 KiB [          ]  README
    4.0 KiB [          ]  COPYING
    4.0 KiB [          ]  Makefile.am
    4.0 KiB [          ]  stamp-h1
 Total disk usage:   1.6 MiB  Apparent size:   1.4 MiB  Items: 85

macOS Catalina and VirtualBox issues

I had this strange issue with VirtualBox. There was this crash

Process:               VirtualBoxVM
Path:                  /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/VirtualBoxVM
...
...
...
Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000007fc0a5286d0
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler

...
...
...
Thread 0:: Dispatch queue: com.apple.main-thread
0   org.qt-project.QtGuiVBox         0x000000010fd06b25 0x10f93e000 + 3967781
...
...

solution that worked for me follows

VBoxManage setextradata global GUI/HidLedsSync 0

source: https://forums.virtualbox.org/viewtopic.php?f=8&t=95041


macOS Mojave – make sure your system is safe
updated for ClamAV release 0.101.4

If you want to make sure that your macOS High Sierra is clean (when it comes to malicious software) you can use free tool (free as in beer and free as in speech – at the same time) called ClamAV.

You can get it various ways. You can download it’s commercial version from AppStore – as paid release, you can install it using brew, download binary from some place where you have no idea what’s really inside, You can instal macOS Server (ClamAV comes bundled with it), etc.

However, you can also build it by yourself. Directly from sources. It’s a pain in a neck, I know, but you can be sure of what you are actually running. And, you will learn that zlib’s library author is a really brainy person. Go ahead, look for yourself in Wikipedia.

Anyway. Let’s start. Estimated time to complete (depending on your system configuration) – 1h-2h.

I suggest to create some place, where you can put all sources and binaries. I suggest following approach

mkdir -p $HOME/opt/src
mkdir -p $HOME/opt/usr/local

In each step, we will download source codes of given tool into

$HOME/opt/src

and then, use

./configure --prefix=$HOME/opt/usr/local/$TOOL_NAME

to install them inside $HOME/opt.

1. You need PCRE – Perl Compatible Regular Expressions

cd $HOME/opt/src
curl -O https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.gz
tar zxf pcre2-10.33.tar.gz
cd pcre2-10.33
./configure --prefix=$HOME//opt/usr/local/pcre2
make
make check
make install

2. You need LibreSSL
(special thanks go to: http://www.gctv.ne.jp/~yokota/clamav/). I was always using OpenSSL, but recently I had more and more issues with it while compiling stuff from sources.

cd $HOME/opt/src
curl -O https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.0.tar.gz
tar zxf libressl-3.0.0.tar.gz
cd libressl-3.0.0
export CXXFLAGS="-O3"
export CFLAGS="-O3"
./configure --prefix=$HOME/opt/usr/local/libressl
make
make check
make install

3. You need zlib

cd $HOME/opt/src
curl -O http://zlib.net/zlib-1.2.11.tar.xz
tar zxf zlib-1.2.11.tar.xz
cd zlib-1.2.11
./configure --prefix=$HOME/opt/usr/local/zlib
make
make install

4. Build the stuff

cd $HOME/opt/src
git clone git://github.com/vrtadmin/clamav-devel
cd clamav-devel
git checkout tags/clamav-0.101.4
# you can also get stable version from here:
# https://www.clamav.net/downloads
export CFLAGS="-O3 -march=nocona"
export CXXFLAGS="-O3 -march=nocona"
export CPPFLAGS="-I$HOME/opt/usr/local/pcre2/include \
  -I$HOME/opt/usr/local/libressl/include \
  -I$HOME/opt/usr/local/zlib/include"
./configure --prefix=$HOME/opt/usr/local/clamav --build=x86_64-apple-darwin`uname -r` \
  --with-pcre=$HOME/opt/usr/local/pcre2 \
  --with-openssl=$HOME/opt/usr/local/libressl \
  --with-zlib=$HOME/opt/usr/local/zlib \
  --disable-zlib-vcheck \
make
make install

5. Prepare minimal config file

mkdir $HOME/opt/usr/local/clamav/clamavdb
mkdir $HOME/opt/usr/local/clamav/log/
touch $HOME/opt/usr/local/clamav/etc/freshclam.conf

Add minimal content of freshclam.conf inside $HOME/opt/usr/local/clamav/etc/freshclam.conf. For details, make sure to read freshclam.conf documentation: freshclam.conf

DatabaseDirectory _PUT_YOUR_HOME_LOCATION_HERE_/opt/usr/local/clamav/clamavdb
UpdateLogFile _PUT_YOUR_HOME_LOCATION_HERE_/opt/usr/local/clamav/log/freshclam.log
DatabaseMirror database.clamav.net

6. Make sure to keep your database up to date

$HOME/opt/usr/local/clamav/bin/freshclam

6. Now, you can scan your drive for viruses

cd $HOME
$HOME/opt/usr/local/clamav/bin/clamscan -ir $HOME

# if you want to scan your whole drive you need to run the thing as root
# I also suggest to exclude /Volumes, unless you want to scan your TimeMachine
# and all discs attached
# -i - report only infected files
# -r - recursive
# --log=$FILE - store output inside $FILE
# --exclude=$DIR - don't scan directory $DIR
cd $HOME
sudo $HOME/opt/usr/local/clamav/bin/clamscan --log=`pwd`/scan.log --exclude=/Volumes --exclude=/tmp -ir /

_JAVA_OPTIONS will not always work for your Java code

It’s good to know, that _JAVA_OPTIONS will not always work in your Java code. Especially, when you elevate privileges using sudo.

Let’s say we have this simple code

public class Simple {
  public static void main(String [] arg) {
    System.out.println("Hello from Simple!");
  }
}

and we run it following way

> export _JAVA_OPTIONS="-Xms1G"
> java Simple
Picked up _JAVA_OPTIONS: -Xms1G
Hello from Simple!
> sudo java Simple
Password: 🔑
Hello from Simple!

As you can see, in case of second execution _JAVA_OPTIONS were not picked up. The reason for not picking it up follows

/* ./hotspot/share/runtime/arguments.cpp */ 

// Don't check this environment variable if user has special privileges
// (e.g. unix su command).
if (buffer == NULL || os::have_special_privileges()) {
  return JNI_OK;
}

The submit token is NOT YOUR LOGIN PASSWORD.

If you are trying to submit your solution using sbt, like this.

> sbt submit user@some.address.com SoMeToKeN
...
...
[error] Invalid input to `submit`. The required syntax for `submit` is:
[error] submit <email-address> <submit-token>
[error]
[error] The submit token is NOT YOUR LOGIN PASSWORD.
[error] It can be obtained from the assignment page:
[error] https://www.coursera.org/learn/scala-spark-big-data/programming/CfQX2
[error] or (for premium learners):
[error] https://www.coursera.org/learn/scala-spark-big-data/programming/QcWcs
[error]
[error]
...
...

you might find this one a solution for you. Start sbt, and run submit from there.

> sbt
> submit user@some.address.com SoMeToKeN
[info] Attempting to submit "wikipedia" assignment in "scala-spark-big-data" course
[info] Using:
[info] - email: user@some.address.com
[info] - submit token: SoMeToKeN
[info] Connecting to Coursera...
[info] Successfully connected to Coursera. (Status 201)
[info]
[info] Assignment submitted successfully!
[info]
[info] You can see how you scored by going to:
[info] https://www.coursera.org/learn/scala-spark-big-data/programming/CfQX2/
[info] or (for premium learners):
[info] https://www.coursera.org/learn/scala-spark-big-data/programming/QcWcs
[info]
[info] and clicking on "My Submission".

sign_and_send_pubkey: no mutual signature supported – macOS 10.14

Just add this one inside ~/.ssh/config.

Host *
  PubkeyAcceptedKeyTypes=+ssh-dss

And Now for Something Completely Different – Zbudzone furie

The dusk was repeating them in a persistent whisper all around us,
in a whisper that seemed to swell menacingly
like the first whisper of a rising wind.
‘The horror! The horror!’


And Now for Something Completely Different – Upadłe anioły

Jedyne co mogę powiedzieć na temat tej książki, to: a = g⋅sinα


Kindle Paperwhite and hard space issue

Recently I have encountered quite frustrating issue with Kindle Paperwhite (3rd) and hard spaces inside Mobi document. At the same time (while buying the book) I have download three, different, formats: epub, Mobi and RTF. All of these have hard spaces all over the place in document. However, there is a slight difference in the way these hard spaces are treated in Books and Kindle (both physical device and application).

In Kindle, there is an issue with selecting single words. If there are hard spaces surrounding the word, everything, together with adjacent words is selected. This prevents dictionary from kicking in. In this sample, I am trying to select word: “спины”.

As you can see, no matter what you do, there is no chance to select the word you are looking for. This is quite frustrating as you can’t lookup words in the dictionary which makes reading Kindle quite pointless (especially when you are reading in foreign language).

Now, the funny thing is that Books – you have it installed on iPad – can handle hard spaces way better. They treat hard space as a regular one, thus, allowing to select single word. In the very same book, opened using Books, I can easily select the word: “спины”.

Which makes it way better experience while reading books for which you have to have access to dictionary. Now, as I don’t give up quite easily and I wanted to use Kindle Paperwhite for that particular book, I tried to approach topic from different angle. It turned out the solution was very simple. All I had to do was taking RTF file (one that I have downloaded together with epub and Mobi), replace all hard spaces with regular ones, and send it to my Kindle’s e-mail. That’s it. Once file was downloaded (it’s not Mobi but who cares) everything worked as expected.

Now, I can lookup words inside Kindle’s dictionary without any issues.

Anyway, I think it would be cool to have this kind of support out of the box inside Kindle, so it’s possible to select the word that is surrounded by hard spaces. The same way, Books allows to select it. If you have the very same issue, try to replace spaces inside your doc and have fun :)


Samsung and scanning to PDF in macOS Mojave

… is broken. There is no way to use default Image Capture application with Samsung SCX-4500W printer. However, there is hope :)

You can download Samsung Easy Document Creator from here: link. Please note that Samsung line of printers was acquired by HP – this is why you have to download application from HP’s pages.

When you open this page, make sure to choose macOS 10.3 – there is no application for macOS Mojave.

Once application is installed, you can use it for scanning pages directly to PDF files – it will not crash the same way Image Capture does. Also, you will be able to open files inside Preview :)


How to get JAR location from JNI


And Now for Something Completely Different – Wojtek Justyna TreeOh!

Radio RAM nie zawodzi ;)

Tym razem, dzięki nim, dowiedziałem się o zespole Wojtek Justyna TreeOh!. Grają niesamowicie sympatyczny, spokojny, nieprzekombinowany Jazz, którego bardzo miło się słucha – szczególnie wtedy, gdy za oknem robi się ciemno. Nienatarczywy towarzysz wieczornej lektury książek, ale jako tło dla domówki też sie nada.

A tutaj link do ich strony na bandcamp: https://wojtekjustynatreeoh.bandcamp.com

Zdecydowanie warto


And Now for Something Completely Different – Altered Carbon

Zdecydowanie lepsza od interpretacji Netflixa


And Now for Something Completely Different – Company of One

Company of One is … everything


eternity – defined using macOS keyboard settings

To learn what eternity means, change your keyboard setting from this

to this


Running JAR file from R using rJava (without spawning new process)

Let’s say we have this, very simple, structure of the project

.
|-- Manifest.txt
`-- src
    `-- somepackage
        `-- StringTest.java

where StringTest.java is a very simple Java class

package somepackage;

public class StringTest {
  public String changeString(String str) {
    return "I have changed the string: " + str;
  }

  public static void main(String [] arg) {
    System.out.println(new StringTest().changeString("Hello"));
  }
}

while Manifest.txt contains

Manifest-Version: 1.0
Main-Class: somepackage.StringTest

We can easily create JAR (“executable”) from these files using jar application

# create JAR
> jar cfm test.jar Manifest.txt -C target somepackage/StringTest.class

# execute JAR
> java -jar test.jar
I have changed the string: Hello

Now, let’s try to run this code inside R. It’s quite straightforward.

# make sure R will be able to pick it up
> export CLASSPATH=./test.jar
> R

R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

...
...
...

> library(rJava)
> .jinit()
> obj <- .jnew("somepackage.StringTest")
> s <- .jcall(obj, returnSig="V", method="main", c("Hello", "Hello") )
I have changed the string: Hello
>

R, Java 11 and making sure you can load rJava

As usual, there are some issues with new Java releases (11 and 12) and R. If you want to run rJava package inside R you have to do few things.

First, make sure you are using Java 11 as default inside terminal session. Inside ~/.profile add this line

export JAVA_HOME=$(/usr/libexec/java_home -v 11)

Once it’s done, you have to make sure to install XCode – you can find it here: XCode. We will need that. XCode contains SDK that is used while R reconfigures itself – it will try to compile small, JNI based, code.

After XCode is installed, make sure to modify this file: /Library/Frameworks/R.framework/Versions/3.4/Resources/etc/Makeconf.

Try to locate the line that reads

CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

and replace it with line

CPPFLAGS = -isysroot  /Applications/XCode/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/
 -I/usr/local/include

Note! Make sure this is just one line inside Makeconf!

Now, you are ready to configure R. Simply call this one

> sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME}/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar

That’s it. You can now install and use rJava package.

Let’s say you have this simple code

.
`-- src
    `-- somepackage
        `-- StringTest.java

and the content of file is

package somepackage;

public class StringTest {
  public String changeString(String str) {
    return "I have changed the string: " + str;
  }

  public static void main(String [] arg) {
    System.out.println(new StringTest().changeString("Hello"));
  }
}

You can compile it following way.

> javac -d target src/somepackage/StringTest.java
> java -cp target somepackage.StringTest
I have changed the string: Hello
> export CLASSPATH=`pwd`/target

and then, use it inside R.

> R

R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
...
...
...

> library(rJava)
> .jinit()
> obj <- .jnew("somepackage.StringTest")
> s <- .jcall(obj, returnSig="Ljava/lang/String;", method="changeString", "Hello")
> print(s)
[1] "I have changed the string: Hello"
> s <- .jcall(obj, returnSig="V", method="main", c("Hello", "Hello") )
I have changed the string: Hello

macOS boots to black screen of emptiness

1. disable Night Shift

It looks like Mojave 10.14.5 has some issues with booting when display colours are adapted to night mode using Night Shift.

After starting up my macOS based machine in the evening (when Night Shift kicks in with all the fancy colour settings) I have noticed that machine boots into black screen. To get screen back, I had to unplug HDMI and put it back.

As I already had some issues with f.lux in the past, I decided to disable Night Shift and give it a try. Guess what, with Night Shift disabled it boots as expected.

If you have similar issue, try to disable Night Shift and restart your machine.

2. Reset the System Management Controller (SMC)

Unplug your stationary Mac computer, wait 15 seconds, plug power back and turn power on.

3. Reset the System Management Controller (SMC) using keyboard

Press Shift - Control - Option when your macOS is turned off. While keeping keys pressed press and hold Power for 15 seconds. Your Mac will turn on and off at some point.

After 15 seconds, release everything and turn your Mac on again.

source: SMC

4. Use USB-C + adapter

Man, this is driving me crazy. I still have to fight this issue. I guess, I will wait for 10.14.6. So far, the only permanent solution was to switch to USB-C instead of using HDMI.

5. Use USB-C + DVI adapter

OK – it looks like issue is still there when there are two, external, displays – connected via HDMI. The only solution to fix the issue was to switch to use HDMI with one display and HDIM -> DVI one the other one.


macOS Mojave and accessing TimeMachine’s
data from command line (iTerm2)

Whenever I restore (setup) new Mac, I do it manually. I simply install clean system, and transfer what I really need from TimeMachine’s backup – typically using CLI. In Mojave it’s a no-no.

If you use iTerm2, you will face following issue while accessing data inside TimeMachine’s storage.

> cd /Volumes/TimeMachine/Backups.backupdb/
> ls
ls: .: Operation not permitted

What you have to do, is adding iTerm2 to the list of trusted apps. Go to
System Preferences -> Security & Privacy -> Privacy
and make sure iTerm2 can access hard drive of TimeMachine.


←Older