Skip to content

Instantly share code, notes, and snippets.

View thlinhit's full-sized avatar
😵
I may be slow to respond.

Truong H. Linh thlinhit

😵
I may be slow to respond.
View GitHub Profile
@btroncone
btroncone / subscription-cleanup.md
Last active April 19, 2022 22:29
Cleaning up subscriptions in Angular

Which do you prefer?

Adding to common sub, calling subscription.unsubscribe() in ngOnDestroy:

export class MyComponent {
  private _subscription: Subscription;
  
  ngOnInit() {
    this._subscription = myObservable
@ufuk
ufuk / JpaEntityQueryBuilder.java
Last active January 8, 2023 17:38
Easy to use query builder for JPA Criteria API
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.criteria.internal.path.PluralAttributePath;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.repository.support.PageableExecutionUtils;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;