Skip to content

Instantly share code, notes, and snippets.

View MafaldaLandeiro's full-sized avatar

Mafalda Landeiro MafaldaLandeiro

View GitHub Profile
@MafaldaLandeiro
MafaldaLandeiro / RandomMessageSpout.java
Created September 19, 2020 16:08
Random Message Spout
package org.ApacheStormTopologyJava.spout;
import org.ApacheStormTopologyJava.util.RandomMessageUtil;
import org.apache.storm.spout.SpoutOutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichSpout;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Values;
import org.apache.storm.utils.Utils;
@MafaldaLandeiro
MafaldaLandeiro / pom.xml
Created September 19, 2020 15:44
Pom file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ApacheStormTopologyJava</artifactId>
<version>1.0-SNAPSHOT</version>
package org.SpringRestfulServiceExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@MafaldaLandeiro
MafaldaLandeiro / CalculatorController.java
Last active May 30, 2016 22:20
Calculator controller
package org.SpringRestfulServiceExceptionHandler.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CalculatorController {
package org.SpringRestfulServiceExceptionHandler.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice(basePackages = { "org.SpringRestfulServiceExceptionHandler.controller" })
public class RestfulResponseExceptionHandler {
import java.util.ArrayList;
import java.util.List;
import strategyPattern.strategy.BubbleSort;
import strategyPattern.strategy.HeapSort;
public class App {
import java.util.List;
import strategyPattern.strategy.SortAlgorithm;
public class Context {
private SortAlgorithm sortAlgorithm;
package strategyPattern.strategy;
import java.util.List;
/**
* Implementation of heap sort
*
* http://www.sanfoundry.com/java-program-implement-heap-sort/
*
*/
package strategyPattern.strategy;
import java.util.List;
/**
* Implementation of bubble sort
*
* http://www.kriblog.com/j2se/util/various-bubble-sort-example-in-java-using-string-array-arraylist-linked-list-recursive.html
*
*/
@MafaldaLandeiro
MafaldaLandeiro / SortAlgorithm.java
Created May 1, 2016 21:05
Sort algorithm interface
package strategyPattern.strategy;
import java.util.List;
public interface SortAlgorithm {
public void sort(List<Integer> unsorted);
}