Skip to content

Instantly share code, notes, and snippets.

@Danny-Hoang
Danny-Hoang / nginx.conf
Created October 30, 2020 06:27 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
@Danny-Hoang
Danny-Hoang / docker_wordpress.md
Created June 19, 2021 03:57 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@Entity
public class Parent implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Child> children = new HashSet<>();
...
@Danny-Hoang
Danny-Hoang / jpa-query.java
Created June 28, 2021 11:02
JPA query samples
public interface DataArticleRepository extends CrudRepository<Article, UUID> {
Optional<Article> findBySlug(String slug);
Optional<Article> findByTitle(String title);
@Query("SELECT DISTINCT article_ FROM Article article_ " +
"LEFT JOIN article_.tags t " +
"LEFT JOIN article_.author p " +
"LEFT JOIN article_.favoredUsers f " +
@Danny-Hoang
Danny-Hoang / BookQueryService.java
Created June 28, 2021 11:25 — forked from guozi/BookQueryService.java
Spring Boot + Spring Data Jpa
public interface BookQueryService {
Page<Book> findBookNoCriteria(Integer page,Integer size);
Page<Book> findBookCriteria(Integer page,Integer size,BookQuery bookQuery);
}
package com.ypc.spring.data.elastic;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ElasticApplication {
public static void main(String[] args) {
SpringApplication.run(ElasticApplication.class, args);
@Danny-Hoang
Danny-Hoang / Customer.java
Created June 28, 2021 11:27 — forked from talk2debendra/Customer.java
Spring data Query By Example
package com.deb.qbe.model;
@Entity
@Table(name = "customers")
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@ToString
@Builder
public class Customers implements Serializable{
@Danny-Hoang
Danny-Hoang / CriteriaQueryTest.java
Created June 28, 2021 11:27 — forked from olivercaine/CriteriaQueryTest.java
JPA with Hibernate CriteriaQuery test
package com.in28minutes.jpa.hibernate.demo.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
@Danny-Hoang
Danny-Hoang / CustomRepository.java
Created June 28, 2021 11:28 — forked from namkyu/CustomRepository.java
spring data jpa #jpa
public interface MemberRepository extends JpaRepository<SpringMember, Integer> {
SpringMember findBySeqAndName(int seq, String name);
List<SpringMember> findTop3ByNameLike(String name);
SpringMember readBySeq(int seq);
SpringMember readByName(String name);
@Danny-Hoang
Danny-Hoang / SpringJPA11_2.java
Last active June 28, 2021 11:32 — forked from JavaNoobPig/SpringJPA11_2.java
jpa query 4 types
package com.pig.jpa.hibernate.demo.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.junit.Test;
import org.junit.runner.RunWith;