Scroll two divs simultaneously

On example of diff2html result let sides = this.diffResult.nativeElement.querySelectorAll(’.d2h-file-side-diff’); sides.forEach((sideDiv,idx) => { sideDiv.addEventListener(’scroll’, (event) => { let scrollLeft = event.target.scrollLeft; sides[idx==0?1:0].scrollLeft = scrollLeft; }); });let sides = this.diffResult.nativeElement.querySelectorAll(‘.d2h-file-side-diff’); sides.forEach((sideDiv,idx) => { sideDiv.addEventListener(‘scroll’, (event) => { let scrollLeft = event.target.scrollLeft; sides[idx==0?1:0].scrollLeft = scrollLeft; }); });

Active Directory/LDAP authentication with Spring Boot

package net.marioosh.ldapdemo;   import java.util.Arrays; import java.util.Collection;   import org.springframework.context.annotation.Configuration; import org.springframework.ldap.core.DirContextOperations; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;   @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter {   @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .fullyAuthenticated() .and().formLogin(); }   @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { Read more about Active Directory/LDAP authentication with Spring Boot[…]

*ngTemplateOutlet

<ng-template #toolbar> lorem ipsum… </ng-template>   <!– put my template here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container>   <!– and here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container>   <!– and here, too 😉 –> <ng-container *ngTemplateOutlet="toolbar"></ng-container><ng-template #toolbar> lorem ipsum… </ng-template> <!– put my template here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here, too 😉 –> <ng-container Read more about *ngTemplateOutlet[…]

array to map with reduce()

let months = [ {month: 1, data1: "test1", data2: "test2"}, {month: 2, data1: "test1", data2: "test2"}, {month: 3, data1: "test1", data2: "test2"} ];   let monthsAsMap = months.reduce((map, obj) => { map[obj.month] = obj; return map; }, {});   console.log(monthsAsMap); console.log(monthsAsMap[’2’]);let months = [ {month: 1, data1: "test1", data2: "test2"}, {month: 2, data1: "test1", data2: Read more about array to map with reduce()[…]

@PreAuthorize with use Spring Expression Language (SpEL) and service method call

public interface EventRepository extends JpaRepository<Event, Long> {   @PreAuthorize("@securityService.canSave(#event,principal)") Event save(@Param("event") Event event);   @PreAuthorize("@securityService.canSave2(#event)") Event save2(@Param("event") Event event); }   @Service("securityService") public class SecurityService {   public boolean canSave(Event event, UserDetails principal) { // some logic here }   public boolean canSave2(Event event) {   // get principal from Security Context Object principal = Read more about @PreAuthorize with use Spring Expression Language (SpEL) and service method call[…]

AsyncPipe example

@Component({ … }) export class TestingComponent implements OnInit { units: any; constructor(private restService:RestService) { } ngOnInit() { this.units = this.restService.getUnits(); } }@Component({ … }) export class TestingComponent implements OnInit { units: any; constructor(private restService:RestService) { } ngOnInit() { this.units = this.restService.getUnits(); } } Template <ng-template #loading>Loading…</ng-template> <div *ngIf="units|async as units; else loading"> <span *ngFor="let unit Read more about AsyncPipe example[…]

JSON -> List

import org.springframework.core.io.Resource; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper;   …   @Value("classpath:/strings.json") private Resource jsonFile;   @Autowired private ObjectMapper mapper;   …   List<String> listOfStrings = Arrays.asList( mapper.readValue(jsonFile.getInputStream(), String[].class) );import org.springframework.core.io.Resource; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; … @Value("classpath:/strings.json") private Resource jsonFile; @Autowired private ObjectMapper mapper; … List<String> listOfStrings = Arrays.asList( mapper.readValue(jsonFile.getInputStream(), String[].class) );