And Now for Something Completely Different – Modern Java in Action


If you have stuck with pre 1.8 Java but you want to get back in time, it’s definitely worth it!


And Now for Something Completely Different – Serotonina


Po taniości :(


VNC – The first attempt to start Xvnc failed

At some point I was struggling with the strange issue. It came out of nowhere. VNC simply stopped working. Eventually, it turned out that reason was completely awkward. Missing directory on LD_LIBRARY_PATH. Yes, I know how it sounds, but it’s true. You can try it by yourself

> setenv LD_LIBRARY_PATH /some_fake_location
> vncserver -geometry 800x600

WARNING: The first attempt to start Xvnc failed, possibly because the font
catalog is not properly configured.  Attempting to determine an appropriate
font path for this system and restart Xvnc using that font path ...
Could not start Xvnc.


Xvnc TigerVNC 1.3.1 - built Nov 16 2016 13:38:44
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11702000, The X.Org Foundation


Wed May  8 23:59:59 2019
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on all interface(s), port 5902
 vncext:      Listening for HTTP connections on all interface(s), port 5802
 vncext:      created VNC server for screen 0
(EE)
(EE) Backtrace:
(EE) 0: /usr/bin/Xvnc (xorg_backtrace+0x55) [0x5bb935]
(EE) 1: /usr/bin/Xvnc (0x400000+0x1bf7a9) [0x5bf7a9]
(EE) 2: /usr/lib64/libpthread.so.0 (0x2b8c5b8ad000+0xf370) [0x2b8c5b8bc370]
(EE) 3: /lib64/ld-linux-x86-64.so.2 (0x2b8c59945000+0x5f79) [0x2b8c5994af79]
(EE) 4: /lib64/ld-linux-x86-64.so.2 (0x2b8c59945000+0x86db) [0x2b8c5994d6db]
...
...
(EE) Segmentation fault at address 0x2b8c59b65de0
(EE)
Fatal server error:
(EE) Caught signal 11 (Segmentation fault). Server aborting
(EE)

Stopping node.js – an elegant way

If you want to stop node.js you have basically two ways:

– brute force (⌃ – C),
– gentle way, via socket inside your application.

I will show you how to do that using simple code (https://nodejs.org/en/about/).

/* app.js */
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Brute force

This is the simplest way, just kill your app inside console using Ctrl-C (macOS: ^-C). All we have to do is to start node (node app.js) and terminate it.

Gentle way

Here, we are using socket to listen for messages from client. We have to modify server a little bit, we have to add socket.

/* app.js */
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

const io = require('socket.io')(server);
io.on('connection', (socketServer) => {
  socketServer.on('stop', () => {
    process.exit(0);
  });
});

Make sure to install socket packages as well

> npm install socket.io
> npm install socket.io-client

Once we have server part, we can focus on client

/* app.stop.js */
const io = require('socket.io-client');
const socketClient = io.connect('http://127.0.0.1:3000/');

socketClient.on('connect', () => {
  socketClient.emit('stop');
  setTimeout(() => {
    process.exit(0);
  }, 1000);
});


What kind of programmer are you…
take this simple C based ‘loop’ test

You still remember good old days with your Atari/Commodore machine. You like to annotate the code and you miss line numbers so much

void main() {

loop:
  printf("Hello\n");
  goto loop;

}

You like it ‘low level’ style. In high school you were the master of assembler. There is nothing wrong about working with bare metal, close to the chip.

#include <setjmp.h>

jmp_buf ljenv;

void main() {

    setjmp(ljenv);
    printf("Hello\n");
    longjmp(ljenv, 0);

}

There is also nothing wrong with procedural languages. Do you recall ‘the father’ of clean procedural code – mister Pascal?

#define true 1

void main() {

  while( true ) {
    printf("Hello\n");
  }

}

You are the Z-generation coder. Scala is the language to rule them all. Recursion, recursion everywhere.

void loop() {
  printf("Hello\n");
  loop();
}

void main() {

  loop();

}

Invalid CSS after “body”: expected 1 selector or at-rule, was “{ “

This error drove me crazy for a while.

Find one difference :)

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css'

body { 
  padding: 0; 
}
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

body { 
  padding: 0; 
}

find without .git and .svn

> find . -not -iwholename '*.svn*' -type f -name "*"
> find . -not -iwholename '*.git*' -type f -name "*"

Apple keyboard symbols – how to type them

– U+2318
– U+2325
– U+21E7
– U+2303
– U+232B

If you don’t know how to type Unicode characters in mac OS, take a look here: Unicode frames in macOS.


Capture whole HTML page into PNG

1. Start Chrome
2. Open the page
3. Open DevTools (⌥⌘I)
4. Open the Command Menu (⇧⌘P)
5. Choose Capture full size screenshot


Python 3 Programming Specialization – Coursera


If you want to learn Python 3, I definitely suggest this specialization: Python 3 Programming Specialization. It consists of five courses, each focusing on different aspects of programming. It will guide you through the basics of Python 3 programming and will let you learn lost of various aspects of Python 3 based development: Python basics (primitive types, variables, loops), dealing with arrays and dictionaries, writing functions. You will learn mapping and filtering of data. During the course you will have to work with REST and JSON APIs – these are the basis for the web projects. There are sections devoted to file operations, CSV files, parsing JSON data, accessing web content from Python code – summarizing, it covers lots and lots of stuff related to Python.

Even though I work with Python on daily basis, I have decided to go through all these courses to refresh few things, to learn concepts I have never used, and to systemize my knowledge.

You can find my notes here: and . These notes will give you the felling of how many topics are covered during the course. It’s really well prepared material, I must say.

When it comes to the delivery, I think it’s a top notch lecture. Teachers go through all the concepts explaining them in details. Material is divided into short, encapsulated sections. It helps to learn if you can’t devote too much time at one go. Apart from the lectures there are exercises, practice materials, and projects that you are obliged to finish before passing each course.

There is one thing, that might be a little bit of a struggle for complete newcomers to Python 3. If you have no experience at all, I think that material complexity elevates a little bit at the very end. It might be challenging for people who are not familiar with coding. However, spending a little bit of time here and there should be enough to finish the course.

When it comes to summarizing Python 3 Programming Specialization in once sentence – definitely worth the time and money.

There are many options to write Python 3 code. You can use regular text editor (e.g. Sublime Text, TextMate or even Vim). However, I strongly suggest PyCharm (Community Edition is more than enough).


List all shared libraries loaded by the process

> cat /proc/PROC_ID/maps | sed 's/\s\s*/ /g' | cut -f6 -d' ' | grep '\.so' | sort -u

or

> lsof -p PROC_ID | grep "\.so" | sed 's/\s\s*/ /g' | cut -f9 -d' ' | sort -u

Unicode frames in macOS

If you want to type in Unicode character on macOS, it’s very simple. Just add new layout

System Preferences -> Keyboard -> Input Sources.

Now, you can type the hex number of Unicode character while keeping option (⌥) key pressed. For example, to get ╒═╕ type: ⌥+2552, ⌥+2550, ⌥+2555.


It was fun, but no, thanks …


This is the end, Beautiful friend :(

My Open Source based license for IntelliJ IDEA Ultimate came to and end. It’s time to say goodbye :(


And Now for Something Completely Different – e-Deklaracje 2019 macOS

Jeżeli walczysz z e-Deklaracjami na macOS, jest duża szansa że widziałeś komunikat jak poniżej: “Failed to load an application resource (internal error).”

Na szczęście, jest rozwiązanie tej patowej sytuacji. Winę za całość ponosi integracja e-Deklaracji i Adobe Acrobat Reader DC. Nie wiem jak u innych, ale u mnie e-Deklaracje nie współpracują z najnowszą wersją Adobe Acrobat Readera.

Rozwiązanie jest trywialne.

1. Usuń Adobe Acrobat Reader DC (a jeszcze lepiej, zrób kopię zapasową)
2. Wejdź na stronę: get.adobe.com
3. Upewnij się, że wybrałeś poniższą wersję (11.0.10)

4. uruchom e-Deklaracje

voilà! :)

P.S.

Jest jeszcze jeden mały “myk”. Przy wysyłaniu deklaracji aplikacja prosi o podanie danych z zeznania 2017 – oczywiście trzeba podać wartości z roku 2018.


Scanning remote machines in macOS

If you have issues while testing your remote services, it’s very convenient to use Network Utility in macOS.

You can start it either using Spotlight Search (⌘-space)

or you can call it directly from CLI

> /System/Library\
/CoreServices/Applications/\
Network\ Utility.app/Contents/\
MacOS/Network\ Utility

All you have to do is to scan your target machine using Prot Scan

If you want to start port listener on Linux machine, it’s good to remember you can use nc for that purpose

> nc -l 80

Quotes like this make my day ;)

So the svd and the principle components, and principle components analysis is essentially the same thing. And so if you hear, you know, you’re in a cocktail party and you hear two people talking about the svd and pca you can rest assured that they’re basically doing the same thing.

source: Exploratory Data Analysis

One is a shift pattern and the second is this kind of alternating pattern, so that’s the truth. But of course, we rarely know the truth, so we need to learn the truth from the data.

source: Exploratory Data Analysis


And Now for Something Completely Different – Reputacje



How do I work with development build on macOS – NetBeans 11.0

Whenever you download NetBeans 11.0 (development version) from the official page here: Download, you end up with a zip file that contains working copy of NetBeans. It looks like this

netbeans
|-- CREDITS.html
|-- DEPENDENCIES
|-- DISCLAIMER
|-- LICENSE
|-- NOTICE
|-- README.html
|-- apisupport
|-- bin
|-- enterprise
|-- ergonomics
|-- etc
|-- extide
|-- groovy
|-- harness
|-- ide
|-- java
|-- javafx
|-- licenses
|-- nb
|-- netbeans.css
|-- php
|-- platform
|-- profiler
|-- webcommon
`-- websvccommon

If you want to run it, you can make a symlink to netbeans/bin/netbeans, you can open the directory and double-click the executable file, you can put in on PATH. You have numerous options. However, macOS users (like me) are used to run everything from /Applications folder. This is why I have prepared very simple setup for my testing environment.

I have this small empty structure inside /Applications

NetBeans.app
|-- Contents
|   |-- Info.plist
|   |-- MacOS
|   `-- netbeans.content
`-- Icon\r

Info.plist is just an empty shell that is supposed to make macOS happy with application structure.

> cat Info.plist
<plist><dict></dict></plist>

More interesting part of this “wrapper” lays here MacOS/NetBeans. As you can see, I simply run whatever comes bundled inside development version of NetBeans.

> cat MacOS/NetBeans
#!/usr/bin/env bash

ABSPATH=$(cd "$(dirname "$0")"; pwd)

${ABSPATH}/../netbeans.content/bin/netbeans

All I have to do, each time new version of NetBeans is ready, is drag and drop content of zip file inside /Applications/NetBeans.app/Contents/netbeans.content. Since now, I can run NetBeans directly from /Applications folder.

If you don’t want to waste your time reinventing the wheel, you can always download “empty shell” here: Download

After you open it, just drag and drop NetBeans inside /Application. Then, make sure to right click it and choose: Show Package Contents. Navigate to Contents -> netbeans.contents. Drop here the whole content of netbeans directory after unpacking development version of NetBeans.


macOS and VMware Tools for Ubuntu
– sharing files between host and guest system

You can share your macOS directories between your host system and guest system while running VMFusion.

In my case, the easiest way to do it was as follows.

Download VMware Tools

You can download it here: VMware tools

Unpack the archive

After unpacking the archive you will find structure like this

VMware-Tools-core-10
|-- floppies
|   |-- pvscsi-Windows2008.flp
|   |-- pvscsi-Windows8.flp
|   `-- pvscsi-WindowsVista.flp
`-- vmtools
    |-- buildNumber.txt
    |-- isoimages_manifest.txt
    |-- isoimages_manifest.txt.sig
    |-- linux.iso
    |-- linux.iso.sha
    |-- linux.iso.sig
    |-- linux_avr_manifest.txt
    |-- linux_avr_manifest.txt.sig
    |-- version.txt
    |-- windows.iso
    |-- windows.iso.sha
    |-- windows.iso.sig
    |-- windows_avr_manifest.txt
    `-- windows_avr_manifest.txt.sig

Mount the iso file

Open VMware Fussion and make sure to mount linux.iso to your Ubuntu based VM.

Once you have selected ISO image, make sure to perform Connect CD/DVD

You should be able to see your newly mounted VMware Tools CD

Install tools

Open terminal application and run sudo su -. This way, you will become root. Now, you can create directory inside ~root and install tools.

> sudo su -
> mkdir install_vmware_tools
> cd install_vmware_tools
> find /media -name "VMwareTools*" -exec cp {} . \;
> find . -name "VMwareTools*" -exec tar -zxf {} \;
> cd vmware-tools-distrib
> ./vmware-install.pl

Proceed with installation until it is finished. Once it’s done, restart your VM machine.

Share the directory

Inside VM preferences, make sure to share directory between host and guest systems.

Inside /mnt/ you will be able to see the files you have shared between systems.


←Older