Adrian Matei

Adrian Matei @ama

About: Making bookmarking easier for devs with www.codever.dev

Joined:
Apr 30, 2019

Adrian Matei
articles - 110 total

Calculate life span and age in years in javascript/typescript

Given birthDate and the day of death as strings the following method calculates the lifespan in...

Learn More 3 1Mar 31 '23

How to use test.each to avoid repetitive tests in jest

Jest is a popular JavaScript testing framework that provides an intuitive and powerful way to write...

Learn More 1 0Mar 10 '23

One easy way to set the name in jest repetitive tests (test.each)

One easy way to display a custom name for each test.each test in jest, is to place the text name in...

Learn More 1 0Mar 3 '23

How to compare mongoose model objects in jest while excluding _id

The schema model object in Mongoose provides an _id that is of type ObjectId. If you are not...

Learn More 1 0Mar 2 '23

How to verify an object is empty object with Jest (extended)

First install jest-extended with the npm install --save-dev jest-extended command and use the...

Learn More 3 0Feb 14 '23

Improve Your Dev Productivity with Bookmarks, Snippets and Notes Management

As a software developer, having quick access to relevant information and resources is essential to...

Learn More 1 0Feb 8 '23

How to set mongoose schema field from list of strings (enum)

In the following example we define template attribute to be of type String with values defined in the...

Learn More 6 0Jan 11 '23

How to set value of input field in angular template

To set the initial value of the input control, just use the value attribute: <input type="text"...

Learn More 10 0Jan 11 '23

How to compare date (no time) with current day in javascript

Get current date with new Date() and setHours to 0, 0, 0 and then you are ready to compare with the...

Learn More 2 0Jan 11 '23

How to use jest test.each function

Let's test with Jest the following isInfiniteDate function, which checks whether the given date is...

Learn More 6 0Dec 19 '22

Do nothing on Angular material dialog scrolling

If you are using Angular Material Dialogs for example and when it pops up the page seems to move a...

Learn More 6 0Dec 14 '22

How to configure and use environment specific values in Angular

Configuring application environments First define different environment files for the...

Learn More 7 1Dec 9 '22

Increase productivity by visually differentiating between environments

Going "green" As mentioned How I manage my dev bookmarks to save time and nerves I use...

Learn More 2 0Dec 8 '22

How to add class conditionally to css element in angular

Use the ngClass input attribute with the object notation, where the keys are CSS classes that get...

Learn More 5 0Dec 5 '22

How to expand dynamically angular material panel

Use the expanded attribute of the mat-expansion-panel element and set it to true when the condition...

Learn More 9 0Nov 28 '22

How to access filtered elements in angular pipe

To access the filtered results of the pipe just define it as a variable via the as...

Learn More 6 0Nov 28 '22

How to copy to clipboard with angular material

Use the click event to pass the text to the handling function, in this case...

Learn More 4 0Oct 14 '22

How to set default value to query param in jax-rs

Use the DefaultValue annotation parameter (accepts strings) where you set the default value alongside...

Learn More 3 0Aug 29 '22

How to unmarshall xml string to java object with JAXB

Given the following Superhero class: import javax.xml.bind.annotation.XmlAccessType; import...

Learn More 16 0Aug 29 '22

How to execute delete statements with jpa query

Use the executeUpdate method of the Query interface. It will return the number of deleted...

Learn More 3 0Aug 29 '22

How to get mockable current time in java enterprise

With Java version 8 it's very easy to get the current timestamp with LocalDateTime.now(). One problem...

Learn More 6 0Feb 18 '22

How to consume a text message from a JMS queue with a Message Driven Bean (MDB)

In the snippet you can see a message driven bean set up to consume asynchronously messages from a JMS...

Learn More 5 0Feb 17 '22

How to delete documents in mongo with mongoose

To delete one entry you can use findOneAndRemove command - it issues a mongodb findAndModify remove...

Learn More 10 0Feb 17 '22

Pagination with JPA queries

Use the firstResult(int startPosition) and setMaxResults(int maxResult) of the JPA Query...

Learn More 5 0Feb 16 '22

How to use named parameters in JPA queries

Define a named parameter (:status) in a named query: import...

Learn More 6 0Feb 15 '22

How to use named queries with JPA and JPQL

You can define several named queries on an entity by using the @NamedQueries and @NamedQuery...

Learn More 6 0Feb 15 '22

How To return CREATED HTTP Status Code in Jax-Rs

Use created(URI location) of the javax.ws.rs.core.Response class. Usually when you return the 201...

Learn More 6 0Feb 12 '22

How to return a response with OK HTTP Status Code with Jax-Rs

Use the ok() method of the javax.ws.rs.core.Reponse class to create a ReponseBuilder with a status of...

Learn More 7 0Feb 11 '22

How to define and use variables in sass

Use the $ sign to define the variable $variable_name: variable_value. Below we define anthracite-gray...

Learn More 6 0Feb 4 '22

How to delete a kubernetes deployment with kubectl

First select the deployment name in the current context you, if you don't know it with the following...

Learn More 6 0Feb 4 '22