requested Java version ((null)) not available. Using Java at “” instead

If you are getting following errors while trying to install xlsx package in R (macOS)

> library(xlsx)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
> library(xlsx)
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
  call: .jinit()
  error: JNI_GetCreatedJavaVMs returned -1

Error: package or namespace load failed for ‘xlsx’

try following

> sudo R CMD javareconf -n
> R
> install.packages('rJava', type='source')
> install.packages('xlsx')
> library(xlsx)

Enforce LANG settings in R – macOS

defaults write org.R-project.R force.LANG en_US.UTF-8

What if you want to modify Makefile content while building your code

Well, it’s possible. Let’s say we have directory with source code: main.cpp

├── Makefile
└── main.cpp

Source code is supper simple.

int main() { return 0; }

What we want to do is to run Makefile and make sure that all occurrences of main will be changed to directory name (e.g. myCode).

All we have to do is to get location of Makefile, update it, store it inside other file and call that other file. In the meantime we can perform some source code manipulation as well.

makefilelocation = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
makefiletarget = $(makefilelocation).target

BASENAME := $(notdir $(CURDIR))

all: call
        $(warning "I will call myself")

call: copy
        $(MAKE) -f $(makefiletarget) exe

exe: main.cpp
        gcc -o main main.cpp

        @cp main.cpp $(BASENAME).cpp
        @sed -e "s/main/$(BASENAME)/g" $(makefilelocation) > $(makefiletarget)

        -rm $(BASENAME).cpp $(BASENAME) $(makefiletarget)

After execution of this Makefile we will have something like this

├── Makefile
├── main.cpp
├── myCode
└── myCode.cpp

Change file name to directory name

OK, I am not sure whether anybody really needs something like this. But, in case you want to change your executable name to the same name as your directory name, try this

BASENAME := $(notdir $(CURDIR))

all: copy exe

        @cp main.cpp $(BASENAME).cpp

exe: copy $(BASENAME).cpp
        gcc -o $(BASENAME).o $(BASENAME).cpp

/bin/sh: @echo: command not found

If you get this one, remember about missing new line after shell call that spans over multiple lines that are split with \. You will get this error in case you don’t add explicit new line and you want to silence the command using @ symbol at the same time.

LIST=a b c d

        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \
        @echo "Done!"

Below, you have new line after last \ – this one will work without any problems.

LIST=a b c d

        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \

        @echo "Done!"

Alternatively, you can make last echo to be part of the multiline command. Here, you will get the expected result as well.

LIST=a b c d

        @echo "Starting!"
        @echo "Loop over values"

        @for target in `echo ${LIST}`; do \
                echo "Value: $$target"; \
        done; \
        echo "Done!"

Whether to use this approach or not (I mean, to call shell from Makefile) is the topic for a completely different story.

More about commands modifiers: here

Running Open MPI on macOS

I am, generally, against all these automation stuff (brew, etc.) at macOS. I prefer to install everything from sources (as long as it is possible).

So, here are few steps to get Open MPI up and running at macOS. Please make sure to download source package from:

# put this file somewhere inside your $HOME
# and untar it
> tar xf openmpi-2.0.2.tar
> cd openmpi-2.0.2/

# Make sure you have XCode and command line tools
# installed - all of these if free of charge
> ./configure --prefix=$HOME/opt/usr/local
> make all
> make install

# After installation is done, you can 
# verify it
> $HOME/usr/local/bin/mpirun --version
mpirun (Open MPI) 2.0.2

Report bugs to

Now, it’s time for Hello world! code.

/* Put this text inside hello.c file */

int main(int argc, char** argv) {
    int rank;
    int world;

    MPI_Init(NULL, NULL);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &world);
    printf("Hello: rank %d, world: %d\n",rank, world);

And, eventually, we can compile and run it

$HOME/opt/usr/local/bin/mpicc -o hello ./hello.c
$HOME/opt/usr/local/bin/mpirun -np 2 ./hello
Hello: rank 0, world: 2
Hello: rank 1, world: 2

That’s all.

Get all hidden files inside $HOME

Simple one liner that helps to find all config locations inside your HOME directory

ls -a1 $HOME | grep '^\.'

In case you like more bass, the same way I do ;)

iTunes -> Windows -> Equaliser

# alternatively: Option + Command + E

apps keep asking for key chain access

1. Open Key Chain Access and unlock all key chains

2. use security utility to set timeout for keychain

security -v set-keychain-settings -t 72000 login.keychain

You can read more about security using man

man security

Scratch Coding Cards by Natalie Rusk

Summary: So far, the best Scratch Coding resource I have found :)

“Old school” way of learning (one that industrial era developed) is based on reading. To know something, you have to read something. Well, that’s not always the best idea. And let me remind you, that an old philosopher, long, long time ago in a land far, far away, said:

You know, Phaedrus, writing shares a strange feature with painting. The offsprings of painting stand there as if they are alive, but if anyone asks them anything, they remain most solemnly silent. The same is true of written words. You’d think they were speaking as if they had some understanding, but if you question anything that has been said because you want to learn more, it continues to signify just that very same thing forever

– Socrates

And that’s exactly what it is whet it comes to learning from books. You are always left with the content as it is, and you can hardly discuss anything with it.

Let’s be honest, reading is really boring nowadays. You have so many, various, sources of knowledge: youtube, online courses, tutorials, podcasts, screencasts, etc.

Even more, sometimes you don’t need them at all. All you need is just an inspiration. Idea of what can be done, and how can you achieve it. You don’t need all the steps, described one by one. You don’t need full recipe. General idea is more than enough. After you know what you are looking for, all you need to do is to experiment and try to achieve it.

This is exactly the way you can learn using Scratch Coding Cards. By far, this is the most engaging and most powerful tool to teach Scratch I was dealing with. I have some experience with teaching Scratch and I know that finding good way of engaging kids into Scratch is quite challenging. There are few things I done in past. Like, fighting very bad and powerful Knight – you can find him at youtube. Or, some ideas quickly sketched on a piece of paper: here (my beloved Moleskine notebooks ;) ). However, they require either following the instructions, strictly, when you watch video or they require someone extra comment from teacher – like in case of Scratch UML.

When it comes to Scratch Coding Cards, it’s all different. All you need to do, is to give one of the sets to kids, and they will solve it. That’s the beauty of this Box full of cards. Kids are simply shuffling cards, looking at them to check what can be done and which blocks are important, and few minutes later solution is there.

What you get inside the Box (which is firm and solid) are 75 cards.

Cards are grouped into activities (challenges you are supposed to code). Each challenge can be solved by following steps presented on cards. Together with my kids, we have found that strict following of the order is not required.


Each card describes some activity and show you how to achieve that. It’s supper simple. Note that my kids are non english speakers and they were still able to follow cards by simply looking and images. This was really cool!

And, one more comment. There was no cheating at all. Kids were given cards and I slowly shaded away :)

If you are looking for some ideas and new, fresh way of teaching Scratch, make sure to check this one. Really worth it.

Have fun!!

Printed: Scratch Coding Cards

ldd in macOS

otool -L libFile.dylib

Redirecting http traffic

Sometimes, simple solutions are the best

> iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8888
> iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 8888

# in case we want to list what we have

> iptables -t nat -nvL --line-numbers

# if we decide to remove the rule - ## stands for rule No.

> iptables -D PREROUTING ## -t nat
> iptables -D OUTPUT ## -t nat

Mr. Robot – some thoughts about bugs

Most coders think debugging software is about fixing a mistake, but that’s bullshit.
Debugging’s actually all about finding the bug.

Coding apprentice – TODOs

Coding apprentice:
– Hi there. Well, you know, there are lots of TODOs inside code.
What does it mean, really? Is it: This One Datelessly On-site?

If you have makefile that has weird name but you still want syntax highlighting

:set syntax=make

makefile – all you wanted to know about variable but were afraid to ask

Sometimes, all you need is a simple solution for checking whether variable you really (really!) need is already defined.

assert = $(if $2,$(if $1,,$(error $2)))

    $(call assert,$(VARIABLE),VARIABLE is not defined)

Stolen from: and found here The GNU Make Book

makefile – know your location

If you want to know where you really are during Make

location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(warning $(location))

Source: unknown Stack Overflow user

Scratch Programming Playground by Al Sweigart


Summary: Great introduction to Scratch

So, you probably wonder where to start your adventure with Scratch. Don’t look any further. You have just found what you were looking for.

Let me be straight here. This book is perfect read after finishing Super Scratch Programming Adventure! (published by No Starch Press). Supper Scratch Programming Adventure will provide you with very basics of Scratch, while here, you can elevate your knowledge and become more experienced and more sophisticated Scratch coder. You don’t have to be a nerd to start your adventure with games. In fact, author tries to convince you that your math related issues – I know some people have them – are really not that important. And I fully agree here.

Click image to enlarge

What I like about the book is the way it delivers the knowledge – through building games. Number of them. It encourages people to learn by practice and experiments. It will push you towards code development instead of making you remember the stuff. That’s something I really appreciate. That’s quite in the line with my approach to learning:

For the things we have to learn
before we can do them,
we learn by doing them.
– Aristotle

You are supposed to build games by actually developing them. What I find quite useful for the readers are steps taken while building each project:

at first you take a look at sketch of your game. You can always do yours, all you need is sheet of paper and pencil
then, you learn how to code each of the elements used in the game
finally, you are encouraged to alter initial concept by introducing some changes into play (e.g. turn one player game into two player game, or to introduce some cheat codes)

This approach gives you the feeling of controlling everything. You are not thrown into deep water, instead, you make small steps to achieve the goal specified in each chapter.

But don’t be fooled by simple language and quite likable creatures hanging all over the place. They will teach you some good programming practices. You will be able to apply what you have learned, later during your engineering carer :) One of these principles is called DRY (Don’t Repeat Yourself, DRY at Wikipedia).


Click image to enlarge

What’s also important is that you can get immediate access to content of the book, you can play sample projects (they are available via – Projects). This way, you can compare your work to what can be treaded as reference. Really useful. Especially for people who just start their experience with coding. And to make this review more appealing to people whose motto is – “seeing is believing” – take a look below. That’s what you will learn to code! Cool, isn’t it?


If you have used Scratch before, you will be able to find (inside the project) the good old Scratch code. It consists of blocks that make it super simple to code.


If you haven’t used Scratch before, don’t be afraid. It’s really, really simple. Just take a look here:

So, just to make a quick conclusion. If you like games, if you want to write games, if you want to learn how to code, grab this one and make sure to read it cover to cover and build all the projects you find there! And don’t cheat! Try to code everything by yourself. This way, you will get most of it.

NoStarch (print): Scratch Programming Playground
NoStarch (e-book): Scratch Programming Playground
Safari Books Online: Scratch Programming Playground

Two line prompt with colors and gadgets

To get this


use this

# bash


export PS1="${white}┌[${green}\u${blue}@${green}\h${white}]\n└[\w]${end} "
# tcsh

set     red="%{\033[1;31m%}"
set   green="%{\033[0;32m%}"
set  yellow="%{\033[1;33m%}"
set    blue="%{\033[1;34m%}"
set magenta="%{\033[1;35m%}"
set    cyan="%{\033[1;36m%}"
set   white="%{\033[0;37m%}"
set     end="%{\033[0m%}"

set prompt="${white}┌[${green}%n${blue}@%m${white}]\n└[%~]${end} "

mwm confing for people who like minimalism during remote work

Here comes my supper ascetic ~/.mwmrc I use on regular basis.

Menu RootMenu
  "Root Menu"          f.title
  "Terminal - urxvt"   f.exec "/afs/ &"
  "Terminal - Konsole" f.exec "/opt/trinity/bin/konsole &"
  "Shuffle Up"         f.circle_up
  "Shuffle Down"       f.circle_down
  "Refresh"            f.refresh
  no-label             f.separator
  "Restart..."         f.restart
  no-label             f.separator
  "Quit..."            f.quit_mwm

Buttons DefaultButtonBindings
  <Btn1Down>    icon  | frame  f.raise
  <Btn2Down>    icon    f.post_wmenu
  <Btn3Down>    root RootMenu
  Alt<Btn1Down> window| icon   f.move

Keys DefaultKeyBindings
  Alt<Key>Escape             root|icon|window        f.next_key
  Alt Shift<Key>Escape       root|icon|window        f.prev_key

and ~/.Xresources as well

Mwm*useIconBox: True
Mwm*keyboardFocusPolicy: explicit
Mwm*raiseKeyFocus: true