четверг, 5 октября 2017 г.

Blog promotion

Hi everyone!

It is been a while since I wrote here. But in order to give some excuse I would like to present you the blog of a programmer:  http://www.yegor256.com/.

Why do I post it here? Well, I like that this man has his own opinion and he express it. A lot of computer topics are described - not only programming techniques, but management also. What is more - his opinion could be against with what everyone silently agree on. I like it. The more different angles of view we have at the topic the faster we can improve ourselves.

The same thing could be applied to the project. I do not like when everyone is silently agreed on something in a project. If all the team is agreed on it means that either no one doesn't care about the project or there is no atmosphere where each member can express their opinion safely.

Let's improve our projects.

среда, 30 августа 2017 г.

My top Android applications



I was disappointed that Microsoft doesn't produce windows phones any more and Nokia was sold. I have bought recently an Android phone Motorola Moto G4 plus and discovered Android and Play market.

Android seems to be very attractive and positive. I use version 7. I like fingerprint authentication very much. But... Why by default a lot of settings are turned on considering information sharing and statistics gathering? I need to go through  the settings of Android and apps and turn off spy features.

Play contains a lot of apps but a lot of them are a crap. I have also a concern why actually some applications asks for a permissions not related with a purpose of application? That is why it is better not to install the application but instead use web site.

But anyway I decided to create my own top of applications I use.

Productivity and entertainment:

  1. Skype
  2. Whatsapp
  3. Google Chrome
  4. Google Gmail
  5. Google Maps
  6. Google YouTube
  7. Google Photos
  8. Google Calendar
  9. Google Translate
  10. RAR
  11. micro Mathematics
  12. TuneIn Radio 
  13. Aviasales
  14. Gazeta.ru
  15. Moto File Manager
  16. Pocketbook
  17. FM Radio
Technical apps:
  1. Speedtest
  2. CPU-Z
What are your favorite apps on Android?

среда, 23 августа 2017 г.

понедельник, 17 июля 2017 г.

How to generate Sprint Boot project

Each time you need to create the Spring Boot project you start to search for your previous projects and copy paste the needed files. This is tiresome and error prone. Here is the solution: https://start.spring.io/. On this site one can just choose the necessary Spring Boot modules and generate the project with a click of a button. You then can just open up the generated project in IDE and start coding. :-)

суббота, 15 июля 2017 г.

Vsevolod Dyomkin. Lisp Hackers. Interviews with 100x More Productive Programmers.

Fantastic book. Can be found online at http://leanpub.com/lisphackers. It is a collection of interviews with 14 developers who use Lisp in real life.
After reading this book I have a new look into Lisp. I need to look at it more closely. :-)
It's disadvantages:
  1. lack of static typing
  2. difficult to work with in a big projects code bases (around 500 kloc)
Advantages:
  1. DSL support
  2. protocols
  3. ability to run partial programs
  4. Having fun
  5. extend your mind 
  6. can be used in projects where customer doesn't care about the tools but getting job done.
Productivity tips:
  1. Start from minimal running code and move forward in a long series of very small steps.
  2. Learn new languages  to meet new people, to think in a new way.

четверг, 1 июня 2017 г.

Java 8 WatchService. Windows Implementation note.

WatchService in java is service that allows to monitor the directory for changes. Here is the important notice from javadoc:
"For example a file manager may use a watch service to monitor a directory for changes so that it can update its display of the list of files when files are created or deleted. "

But what if you need to know  which file was actually renamed. What is the old name of a file and what is the new name?

On windows there is a native support from the OS to monitor such changes. Well, take a look how this possibilities were mapped in Java. For jdk8 see the link http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/windows/classes/sun/nio/fs/WindowsWatchService.java#l464. For lazy ones here is the method:
<code>
// Translate file change action into watch event
        private WatchEvent.Kind<?> translateActionToEvent(int action)
        {
            switch (action) {
                case FILE_ACTION_MODIFIED :
                    return StandardWatchEventKinds.ENTRY_MODIFY;

                case FILE_ACTION_ADDED :
                case FILE_ACTION_RENAMED_NEW_NAME :
                    return StandardWatchEventKinds.ENTRY_CREATE;

                case FILE_ACTION_REMOVED :
                case FILE_ACTION_RENAMED_OLD_NAME :
                    return StandardWatchEventKinds.ENTRY_DELETE;

                default :
                    return null;  // action not recognized
            }
        }
</code>

You see, renamed and new file events mapped to ENTRY_CREATE event. The only question comes to my mind is -- why? Why it was done like this?
I think they were trying to make a universal solution, but.. why they didn't make it extensible?

суббота, 13 мая 2017 г.

n queens puzzle

Hi! I was getting bored and started to think about algorithms.
Here is a solution to the 8 queen problem. Code is on github: https://github.com/chernykhalexander/puzzles/blob/master/src/test/java/ru/chernykh/queen/QueenTest.java.

Thanks!

среда, 10 мая 2017 г.

VirtualBox. Mount Windows shared folder in Linux guest

Small snippet how to mount a windows shared folder in linux guest in VirtualBox:
mount -t vboxsf share ~/host

where host is the mount point in linux guest and share is the name of the shared folder defined in VirtualBox.

суббота, 4 марта 2017 г.

Make screenshot with Java

It turns out that making screenshot of the monitor is very easy task.
It even works with dual monitor configurations.
Code is on github: https://github.com/chernykhalexander/screenshot.

вторник, 28 февраля 2017 г.

Java 8. Object.hashCode default implementation

Usually it is considered that default Object.hashCode and System.identityHashCode are calculated as value converted of object address to int. But this is not a strict rule. In fact in JVM8 there are possibilities to choose the implementation of Object.hashCode with option -XX:hashCode=0..5. The list of functions can be found at http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/runtime/synchronizer.cpp in method get_next_hash. Here is the list of possible values:

0 - unguarded global Park-Miller RNG;
1 - function on bits;
2 - constant 1;
3 - sequence number;
4 - object address;
5 - Marsaglia's xor-shift scheme with thread-specific state.

In JVM 8  by default is used Margalia's xor-shift option. See http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/share/vm/runtime/globals.hpp and line:
product(intx, hashCode, 5,"(Unstable) select hashCode generation algorithm").