Open in app

Sign In

Write

Sign In

Elvis Ciotti
Elvis Ciotti

32 Followers

Home

About

May 15

Compare LocalDatetime ignoring nanoseconds

In case your test instantiates a date with LocalDateTime.now() , stores it into a JPA, retrieves it back, and compares, the simple assertion comparing dates might fail as the db might not support the date precision. In the example below, the assertion failed as the actual date didn’t have nanoseconds. expected: 2023-05-15T09:42:30.171983409 (java.time.LocalDateTime) but was: 2023-05-15T09:42:30.171983 (java.time.LocalDateTime)

Java

1 min read

Java

1 min read


Apr 12

Deploy Github code using Terraform and Github Actions: working example

In your repository, create the following files # .github/workflows/terraform.yml name: 'Terraform' on: push: branches: [ "main" ] permissions: contents: read jobs: terraform: name: 'Terraform deploy ...' runs-on: ubuntu-latest environment: production defaults: run…

Github

2 min read

Deploy Github code using Terraform and Github Actions: working example
Deploy Github code using Terraform and Github Actions: working example
Github

2 min read


Mar 28

Online platform that allows users to compare features of different products in a side-by-side comparison char

The website www.featurecompare.com is an online platform that allows users to compare features of different products in a side-by-side comparison chart. It covers a wide range of categories, including electronics, home appliances, sports and outdoor equipment, and more. To use the website, you can simply search for the products you…

Tools

1 min read

Tools

1 min read


Mar 27

Javascript: replace all the literal or regexpr occurrences in a string

Simple replace first occurrence “aaaaa”.replace(“a”, “b”) // baaaa Simple replace ALL occurrences “aaaaa”.replaceAll(“a”, “b”) // bbbbb Advanced replaceAll using Rgexpr Example with markdown, replacing titles with HTML tags #this is the title content # another title another content to transform into <h1>this is the title</h1> content <h1>another title</h1> another content This can be done with replaceAll taking all the content after a # symbol and spaces until the next line and outputting it inside h1 tags. Note that $1 means the content inside the first set of brackets.

JavaScript

1 min read

JavaScript

1 min read


Mar 27

Conditional adding object properties in Javascript in one line

One-liner code to add an element to an object without leaving the key without a value. In JavaScript, you can conditionally add object properties using an if statement, a ternary operator or even a single instruction using the spread operator. TL;DR; {a:1, ...(yourConditionalBoolean && {b:2}) } // outputs {a: 1}…

JavaScript

2 min read

JavaScript

2 min read


Mar 26

Java code in the command line with Shell. 5 minutes introduction

TL; DR Type jshell and type auto-completed java code in a prompt, immediately executed. Use $1 to access output from previous commands, type /save <file.jsh>to save the written code into a file and jshell <file.jsh>t to execute it. What JShell is JShell is a Java REPL (Read-Evaluate-Print Loop) tool that was introduced in JDK 9…

Java

3 min read

Java

3 min read


Jan 25

Redis Session SerializationException and automatically logging the user out on Spring boot 3 / Spring 6

In case you change the format of the security Authentication Details object being stored in the session and release your application and you forgot to change the session prefix/namespace, the user will be likely stuck at the login screen with an exception without being able to go anywhere. In Spring…

Spring

2 min read

Spring

2 min read


Jan 20

Migrate Spring boot data Redis session to v3.0

Migrating spring boot data redis from 2.7 to 3.0 seems to be only about renaming properties (see guide) from spring.redis. to spring.data.redis. , but there are other things to change if you are using redis for sessions. The official documentation spring boot data Redis 3.0 says that spring.session.store-type=redis can still…

Java

2 min read

Java

2 min read


Jan 12

Hibernate 6: how to customize JSON field serializer to support LocalDateTime. Spring Boot 3 config

The new Hibernate 6 supports JSON type natively, without using other libraries or custom attribute converters. Nevertheless, there are no specific options to configure how you want to serialize, e.g. you might want to serialize a LocalDateTime or just customize the Jackson options. Hibernate serializes using FormatMapper instances, and the…

Hibernate

1 min read

Hibernate

1 min read


Jan 10

Hibernate 6.1 “no viable alternative at input”

Spring boot migration to v.3.0 also migrates hibernate to v6.1. Some queries might fail as some old HQL syntax is not supported anymore. In my case, it was an old query containing entity.numericField is not 0 and another one entity.boleanField is true The mistakes were around logical comparators, so I fixed with entity.numericField <> 0 and entity.boleanField = true . Quoting the number ('0') and the boolean (‘true’) also didn’t seem to cause parse errors.

Hibernate

1 min read

Hibernate

1 min read

Elvis Ciotti

Elvis Ciotti

32 Followers

Software Contractor — Java / Spring / k8s / React @ London. https://www.linkedin.com/in/elvisciotti

Following
  • Ayodeji Awosika

    Ayodeji Awosika

  • umair haque

    umair haque

  • Freelancer Club

    Freelancer Club

  • Aphinya Dechalert

    Aphinya Dechalert

  • Mark Manson

    Mark Manson

See all (34)

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams