Quantcast
Channel: Java mon amour
Viewing all 1124 articles
Browse latest View live

AWS tutorial


Venkat Subramanian, Lazy evaluation in Streams

$
0
0




import java.util.Arrays;
import java.util.List;

public class Lazy {
public static void main(String[] args) {
List values = Arrays.asList(1, 2, 3, 5, 4, 6, 7, 8, 9);
System.out.println(values.stream().filter(Lazy::isGT3).filter(Lazy::isEven).map(Lazy::doubleIt).findFirst().orElse(0));

}

public static boolean isGT3(int number) {
System.out.println("isGT3 " + number);
return number > 3;
}


public static boolean isEven(int number) {
System.out.println("isEven " + number);
return number % 2 == 0;
}

public static int doubleIt(int number) {
System.out.println("doubleIt " + number);
return number * 2;
}


}





import java.util.stream.Stream;

public class SumEvenNumbers {
public static int compute(int start, int count) {
return Stream.iterate(start, e -> e + 1).filter(e -> e % 2 == 0).mapToInt(e -> e * 2).limit(count).sum();
}

public static void main(String[] args) {
System.out.println(compute(51, 101));
}

}


Knowledge transfer in IT projects

weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction

$
0
0
If you get "weblogic.transaction.internal.AppSetRollbackOnlyException: setRollbackOnly called on transaction " in your application, and have no clue what is going on, in Oracle Support you find this article:
"When setRollbackOnly() is Called in beforeCompletion() Synchronization Method , Thrown Exception Cannot be Obtained (Doc ID 1547327.1)"
you should apply a patch 16509700 AND specify -Dweblogic.transaction.allowOverrideSetRollbackReason=true , or upgrade to WLS 12.1.3

Java Flight Recorder JFR: enable recording of exceptions

$
0
0
how to specify custom settings for JFR

http://isuru-perera.blogspot.it/2016/03/specifying-custom-event-settings-file.html

The default settings are in C:\Program Files\Java\jre1.8.0_121\lib\jfr\default.jfc (in Windows... otherwise in JAVA_HOME/jre/lib/jfr/default.jfc in Linux.

so you can enable also the "Exceptions" event, just copy the default.jfc to /tmp/default.jfc, hack it


<event path="java/exception_throw">
<setting name="enabled" control="http://www.oracle.com/hotspot/jvm/enable-exceptions">false</setting>
<setting name="stackTrace">true</setting>
</event>


set it to true

and start the jfr with

jcmd JFR.start settings=/tmp/default.jfc

and you will smile and be happy

Angular 4 resources

$
0
0
https://cli.angular.io/reference.pdf Angular CLI reference

https://angular.io/guide/cheatsheet Angular cheatsheet

Install bootstrap: https://github.com/angular/angular-cli/wiki/stories-include-bootstrap

Bootstrap recipes https://getbootstrap.com/

Incredibly verbose course on Angular 4, with extremely confusing and complicated examples:
https://www.udemy.com/the-complete-guide-to-angular-2

Much clearer and essential course https://www.youtube.com/playlist?list=PLYxzS__5yYQmi8f94KAGx1ofwFIn-FLNt

Rangle.io training book https://www.gitbook.com/book/rangle-io/ngcourse2/details

Book review: Production-Ready Microservices, by Susan Fowler

$
0
0


This is a short book who covers the essential points about service availability in production, and how to prepare for a smooth operational setup.

It's a useful book but lacking "real life" stories and technical details, most of the stuff is quite common-sense.

I am looking forward to reading "Betsy Beyer, Chris Jones, Jennifer Petoff & Niall Richard Murphy: Site Reliability Engineering", who allegedly is much more "technical"

IntelliJ is really awesome

$
0
0
You can learn how to make the best of the IDE from this 1 hour video (if you can stand the speaker)



more tips available here:



but of course the official help https://www.jetbrains.com/help/idea/meet-intellij-idea.html contains all that info

and the product blog of course https://blog.jetbrains.com/idea/

Also, after you read this https://dzone.com/articles/why-idea-better-eclipse you definitely want to ditch Eclipse forever.

Very useful the https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf keymap reference (menu Help/Keymap...)


Kotlin essentials presentation

$
0
0


My first impression is that with Kotlin you can write more readable code than in Java. I am not sure how stable, refactorable and debuggable it is... surely it looks nice.

Sire Reliability Engineering at Google

$
0
0


I have immensely enjoyed reading this book, some sections are highly technical - frankly beyond my level - some other anecdotal and more narrative. Particularly interesting is how Google trains his Site Reliability Engineers, reading the Post-mortem reports and making crash simulations to brainstorm the trainees.

Spring boot Rest controller with Embedded Tomcat

Poll result on Global Warming

$
0
0


it seems that the audience is equally represented by catastrophists and "deniers/optimists"... I am afraid 10 years from now we will have MANY more catastrophists around. It's also true that IT people tend to be a bit disconnected from reality...

Intellij and Git

$
0
0
Basic introduction here, very nice:



Incidentally, at first I could not find the "New/Ignore file" menu, so I have manually created a New File .gitignore, and Idea magically prompted me to install the Gitignore plugin, which I did with great satisfaction.

I kept getting


2017-08-12 12:03:55,303 [2262815] INFO - #git4idea.commands.GitHandler - remote: Permission to pvmarmotta/pv01.git denied to vernetto.
2017-08-12 12:03:55,303 [2262815] INFO - #git4idea.commands.GitHandler - fatal: unable to access 'https://github.com/pvmarmotta/pv01.git/': The requested URL returned error: 403



until in .git/config I changed the URL to https://pvmarmotta:mypassword@github.com/pvmarmotta/pv01.git/

it's tragic that such basic things entail manual hacks... this is the state of IT in 2017... I hope driverless cars will be better engineered otherwise we are toast (we are in any case thanks to AGW)

More interesting stuff on Git:

the infamous "DETACHED HEAD" message: http://gitolite.com/detached-head.html

The "git concepts simplified"http://gitolite.com/gcs.html in gitolite by Sitaram Chamarty

charismatic Jessica Kerr "Git Happens" presentation



Great presentation site Think like a Git http://think-like-a-git.net/

Book: Humans need not apply

$
0
0


Excellent book about the impact that AI will have on our lives - at the same level as "the rise of the Robots". Read it!

Apache Camel training


OpenShift, Minishift, VirtualBox

$
0
0
Excellent VERY quick introduction to OpenShift:



I am following this nice introduction to OpenShift https://www.udemy.com/openshift-developers-workshop/ with github https://github.com/drizzleconsulting

Download and install VirtualBox https://www.virtualbox.org/wiki/Downloads

Install Docker https://docs.docker.com/docker-for-windows/

Download and unzip Minishift https://github.com/minishift/minishift/releases

If you get this error


.\minishift.exe start
-- Installing default add-ons ... OK
-- Checking if Hyper-V driver is configured ... FAIL
Hyper-V virtual switch is not set


it means that maybe Docker is not installed

When I try to install Docker, it tells me "HyperV is not available on Home editions, please use Docker Toolbox" - which uses Oracle VirtualBox instead of HyperV

Since I have Windows 10 Home and I don't want to waste 170 USD to buy Windows Enterprise, I am installing Docker Toolbox https://docs.docker.com/toolbox/overview/#whats-in-the-box

Docker training

$
0
0
Excellent training available at https://www.udemy.com/docker-tutorial-for-devops-run-docker-containers/

associated github repo https://github.com/jleetutorial/dockerapp

Awesome tool to plaz with Docker without having to install it locally http://training.play-with-docker.com/helloworld/

Docker install on Windows https://docs.docker.com/docker-for-windows/install/

Docker hub https://hub.docker.com/ and https://hub.docker.com/explore/

The Tomcat Docker Hub page https://hub.docker.com/r/_/tomcat/

Docker-friendly CI host https://circleci.com

Book: Peopleware

$
0
0


Where it's proven - with actual statistical facts, not only theories - that in IT - like elsewhere - PEOPLE and not TECHNOLOGIES are the key to success.... and that people are most productive when they are FREE to communicate and cooperate, and HAPPY and in a natural environment and without management pressure and coercion.

Quod Erat Demonstrandum.

Imperative vs Functional programming, a simple example

$
0
0
Today a colleague was asking me the difference between functional and traditional programming in Java... I made a simple example to show how a FUNCTION can be used as a parameter, and the importance of Streams.... of course, in this example the traditional programming is much simpler and readable! Often functional programs can be really hard to decipher!



import java.util.Arrays;

public class HelloWorld
{
static String[] theStrings = new String[] {"Pippo", "Pluto", "Paperino"};

public static void main(String[] args) {
theTraditionalWay();
theFunctionalWay();
}

static void theTraditionalWay() {
for (int i = 0; i < theStrings.length; i++) System.out.println(theStrings[i].toUpperCase());
}

static void theFunctionalWay() {
Arrays.stream(theStrings).map(String::toUpperCase).forEach(System.out::println);
}
}

You can run it here https://www.compilejava.net/

The price of changing job

$
0
0
I have recently changed company. I had the opportunity to stay as permanent, moving to another department with people I already knew, but I wanted to explore new worlds and also make some more money.

The change has been devastating, essentially for social reasons.

Humans are tribal animals, and to be happy they must build a web of trust and friendship around them.

Trust can be built only in action. You work with the guy, you know that he is responsible, helpful, skilled, he stops doing his work to come to your rescue. Only then you trust him and like him.

I don't trust someone for his smiles and handshakes and how are you. I trust someone because I know he will do his best to help me. The first thing I tell a new joiner is "whatever problem you have, please don't hesitate to contact me at any time". And if he has a problem that I can't solve, then I ask around until I find someone who can help. By no means a new joiner should be left alone with a problem.

IT industry is not a happy state of nature, where people spend maybe 5 hours a day chasing food, then the rest of the day socializing and having fun. This is a tough world, with tight deadlines, rough competition, people are always under pressure to get things done and acquire new skills. It's a permanent state of semi-war, unfortunately sometimes also internal to the same team. Sadly, some people will rejoice at your failure. Being able to build a team where everyone is really sympathetic to each other, is a real miracle that happens very rarely.

Don't expect a warm welcome. Don't expect to be helped. Most of the time you are absolutely on your own, in a new environment that you don't know. Getting to know the new environment (the 1000 "how to" that are different from company to company) is alone a huuuuge stress and drain on your energies, because you must constantly ask for help and expose you as a "weak" individual. Not everybody understand that it's absolutely normal that they have to invest some of their time to make you comfortable. Many people will consider you only a nuisance and a handicap. It's painful, very painful.



So, changing job is a jump in the dark. And don't believe to those who tell you "don't worry, everything will be fine". Sorry, this is not a Disney movie, this is Planet Earth, not all will be fine, there will be a lot of terrible stress, of shocks, of pain.

So, are you really really sure you want to change job? If you feel bored at work, or you feel that your skills are not improving, start your own project in the evening and weekends. Get certified on something. If you need extra money, you can join Toptal and get an extra part-time job.

But, think twice before you leave a company where you are trusted and you know the internal process. I did, and I am suffering A LOT.

Viewing all 1124 articles
Browse latest View live