git rebase

Situation Branch master has commits after older feature branch and now need continue feature branch, but without doing git merge master – better using rebase like below. $ git checkout feature $ git rebase master Real example Before * commit b2823b3076e16100979e52a8413fc7d6467d3f8e (HEAD -> master) | Date: Sun Feb 26 10:19:37 2023 +0100 | | commit Read more about git rebase[…]

Docker – inspect running container

List running containers $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec7ad9e8d7a5 spring-demo "java -jar /app.war" 3 minutes ago Up 3 minutes nifty_boyd$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec7ad9e8d7a5 spring-demo "java -jar /app.war" 3 minutes ago Up 3 minutes nifty_boyd Go inside running container and run command Read more about Docker – inspect running container[…]

SQL: UPDATE by SELECT

Need update t_reports table, column tanked_sum. t_reports – reports table – tanked_sum – sum of tanked from t_vehicles table t_vehicles – vehicles table (more than one vehicle is in one report) – tanked – refueled liters of fuel for one vehicle — select only (count in `tanked_sum_counted` column) SELECT tanked_sum_counted, * FROM t_reports r JOIN ( SELECT Read more about SQL: UPDATE by SELECT[…]

@Optional dependency in Angular

Usage of @Optional (optional dependency), for example when LoginComponent is used as dialog or standalone. import { Optional } from ‘@angular/core’;   constructor( @Optional() private dialogRef: MatDialogRef<LoginComponent>, ) { … } import { Optional } from ‘@angular/core’; constructor( @Optional() private dialogRef: MatDialogRef<LoginComponent>, ) { … }

Reactive Form: previous value

let form = this.fb.group({ ‘hotelLocation’:[null] });   form.get(’hotelLocation’).valueChanges.subscribe(v => {   // HERE !! let prevVal = this.form.value[’hotelLocation’]; });let form = this.fb.group({ ‘hotelLocation’:[null] }); form.get(‘hotelLocation’).valueChanges.subscribe(v => { // HERE !! let prevVal = this.form.value[‘hotelLocation’]; });

@DateTimeFormat usage example

@GetMapping("/find") public Page<ReportProjection> reports( @RequestParam(required = false, name = "status") ReportStatus status, @RequestParam(required = false, name = "search") String search, @DateTimeFormat(pattern="yyyy-MM-dd") @RequestParam(required = false, name = "from") Date from, @DateTimeFormat(pattern="yyyy-MM-dd") @RequestParam(required = false, name = "to") Date to, Pageable pageable) { return reportService.reports(status, search, from, to, pageable); }@GetMapping("/find") public Page<ReportProjection> reports( @RequestParam(required = false, name Read more about @DateTimeFormat usage example[…]

Return local json file from HttpClient

Steps add file.json to src/assets directory use this.http.get('assets/file.json'); in HttpClient import { Injectable } from ‘@angular/core’; import { HttpClient } from ‘@angular/common/http’; @Injectable({ providedIn: ‘root’ }) export class ApiService { constructor(private http: HttpClient) { } getLocalJson() { return this.http.get(‘assets/file.json’); } }