Skip to content

Instantly share code, notes, and snippets.

View OmarElgabry's full-sized avatar
🧑‍🌾

Omar Elgabry OmarElgabry

🧑‍🌾
View GitHub Profile
@OmarElgabry
OmarElgabry / pom.xml
Last active February 19, 2019 07:13
Eureka Book Service
....
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
@OmarElgabry
OmarElgabry / SpringEurekaServerApplication.java
Last active June 10, 2018 06:00
Eureka Server Main Class
package com.eureka.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer // Enable eureka server
public class SpringEurekaServerApplication {
@OmarElgabry
OmarElgabry / application.properties
Last active June 10, 2018 17:34
Eureka Server Configurations
# Give a name to the eureka server
spring.application.name=eureka-server
# default port for eureka server
server.port=8761
# eureka by default will register itself as a client. So, we need to set it to false.
# What's a client server? See other microservices (image, gallery, auth, etc).
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
@OmarElgabry
OmarElgabry / pom.xml
Last active June 10, 2018 06:40
Spring Eureka Service
....
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
#include <stdio.h>
#include <queue>
using namespace std;
// It's like a BFS algorithm, where you have 9 roots for 9 trees (1, 2, ..., 9).
// For each tree, you scan it level by level,
// and you generate the two children of every number,
// add them to the queue, and remove the current number at q.front().
@OmarElgabry
OmarElgabry / list-orders.jsp
Created September 12, 2017 06:55
Spring: A Head Start 🔥— Building A Spring Web Application (Part 7)
<table>
<tr>
<th>Customer</th>
<th>Price</th>
<th>Date of Order</th>
<th>Actions</th>
</tr>
<c:forEach var="order" items="${orders}">
<tr>
@OmarElgabry
OmarElgabry / OrderController.java
Created September 12, 2017 06:54
Spring: A Head Start 🔥— Building A Spring Web Application (Part 7)
@GetMapping("/deleteOrder")
public String deleteOrder(@RequestParam("orderId") int orderId, Model model){
// delete the order using the service
orderService.deleteOrder(orderId);
return "redirect:/order/list";
}
@OmarElgabry
OmarElgabry / OrderServiceImpl.java
Created September 12, 2017 06:53
Spring: A Head Start 🔥— Building A Spring Web Application (Part 7)
@Override
@Transactional
public void deleteOrder(int orderId) {
orderDAO.deleteOrder(orderId);
}
@OmarElgabry
OmarElgabry / OrderDAOImpl.java
Created September 12, 2017 06:52
Spring: A Head Start 🔥— Building A Spring Web Application (Part 7)
@Override
public void deleteOrder(int orderId) {
// get the current hibernate session
Session session = factory.getCurrentSession();
// delete the order using the passed id (primary key)
Query theQuery = session.createQuery("delete from Order where id=:Id");
theQuery.setParameter("Id", orderId);
theQuery.executeUpdate();
@OmarElgabry
OmarElgabry / list-orders.jsp
Created September 12, 2017 06:51
Spring: A Head Start 🔥— Building A Spring Web Application (Part 7)
<table>
<tr>
<th>Customer</th>
<th>Price</th>
<th>Date of Order</th>
<th>Actions</th>
</tr>
<c:forEach var="order" items="${orders}">
<tr>