Skip to content

Instantly share code, notes, and snippets.

View jesty's full-sized avatar

Davide Cerbo jesty

View GitHub Profile
@jesty
jesty / MySpringNativeApp.java
Last active March 24, 2021 15:21
Spring Native configuration for an application using Apache Camel, ActiveMQ (JMS) and Elasticsearch
import javax.jms.Session;
import org.apache.activemq.openwire.OpenWireFormatFactory;
import org.apache.activemq.openwire.v12.MarshallerFactory;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.activemq.transport.TransportFactory;
import org.apache.activemq.transport.nio.NIOSSLTransportFactory;
import org.apache.activemq.transport.nio.NIOTransportFactory;
import org.apache.activemq.transport.tcp.TcpTransportFactory;
import org.apache.camel.Endpoint;
import org.apache.camel.component.activemq.ActiveMQComponent;
@jesty
jesty / example.jmx
Created August 30, 2019 15:56
JMeter test with JVM monitoring
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
@jesty
jesty / SpringKafkaStartStop.java
Created April 7, 2019 15:34
This class will be useful when you need to stop Kafka consuming when you are using Spring Cloud Stream with Kafka. I use this class to stop consuming during some management operation on my microservice.
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.binder.Binding;
import org.springframework.cloud.stream.binder.BindingCreatedEvent;
package com.agiledeveloper;
import java.util.*;
class Fibonacci {
public static int numberAtPosition(int position) {
int current = 1;
int next = 1;
if(position < 2) return 1;
@jesty
jesty / FibonacciS.scala
Last active May 15, 2018 08:39
Fibonacci in Scala
def seriesUntilPosition(n: Int) = (0 until n)
.map(x => (0,0))
.foldLeft((0,1))((acc, b) => (acc._2, acc._1 + acc._2))._2
def seriesUntil(n: Int) = (0 to n).map(fibo(_)) (
@jesty
jesty / Fibonacci.kt
Created May 14, 2018 15:35
Fibonacci in Kotlin
fun seriesUntilPosition(position: Int): List<Int> {
return (1..position)
.map { Pair(0, 1) }
.fold(listOf(Pair(0, 1))) { acc, first ->
val last = acc.last()
acc + (Pair(last.second, last.first + last.second))
}
.map { it.second }
}
@jesty
jesty / Maps.java
Created May 13, 2018 13:41
Map sample from functional Java to functional Kotlin
import java.util.List;
import java.util.Map;
import java.util.Set;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.*;
public class Maps {
public static Map<Integer, List<String>> listByScore(Map<String, Integer> scores) {
@jesty
jesty / Fibonacci.java
Last active May 14, 2018 15:34
Functional Fibonacci, from Java to Kotlin
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
class NextInSeries {
public final int current;
public final int next;
NextInSeries(int current, int next) {
this.current = current;
@jesty
jesty / Child.js
Last active April 4, 2018 23:04
Just for a Medium post
import React, { Component } from 'react';
import {MainContext} from './Context';
class Child extends Component {
happy = main => main.onChangeStatus("happy :D")
sad = main => main.onChangeStatus("sad :(")
render() {
return (
@jesty
jesty / Dockerfile
Last active April 27, 2017 07:52
Wildfly 10 Docker configuration example.
FROM centos:7
MAINTAINER Davide Cerbo
RUN yum update -y \
&& yum -y install unzip \
&& yum -y install java-1.8.0-openjdk-devel \
&& yum clean all
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0
ENV PATH "$PATH":/${JAVA_HOME}/bin:.:
ENV VERSION 10.1.0.Final
ENV INSTALL_DIR /opt