Skip to content

Instantly share code, notes, and snippets.

View davengeo's full-sized avatar
🏠
Working from home

David Navarro davengeo

🏠
Working from home
View GitHub Profile
@davengeo
davengeo / JmsListener.java
Last active October 12, 2015 09:19
much better now as hot observable
/*
* Copyright (c) 2015.
* [email protected]
*/
package org.daven.rx.listeners;
import org.daven.rx.domain.EventContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@davengeo
davengeo / LoggingAspect.java
Last active October 18, 2015 17:30
Aspect for profile methods
/*
* Copyright (c) 2015.
* [email protected]
*/
package com.daven.aspects;
import com.google.common.base.Stopwatch;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@davengeo
davengeo / EventController.java
Last active October 18, 2015 17:53
RestController that emits as Observable
/*
* Copyright (c) 2015.
* [email protected]
*/
package org.daven.demo.rxcache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
@davengeo
davengeo / CacheStream.java
Last active October 19, 2015 21:07
Observable Stream created from Infinispan Cache
/*
* Copyright (c) 2015.
* [email protected]
*/
package org.daven.demo.rxcache;
import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.notifications.Listener;
@davengeo
davengeo / RxInOutAspect.java
Created October 24, 2015 10:40
Aspect that propagates the argument of the advised methods as Observable, it might also propagate the result or the time elapsed
/*
* Copyright (c) 2015.
* [email protected]
*/
package org.daven.demo.rxcache;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@davengeo
davengeo / TestRxStreamble.java
Last active October 27, 2015 13:54
Testing artefact for TDD with Rx Observables
/*
* Copyright (c) 2015.
* David Navarro
* [email protected]
*/
public class TestRxStreamble implements Streamable<EventContainer> {
private static Logger LOG = LoggerFactory.getLogger(TestRxStreamble.class);
@davengeo
davengeo / FileTransferScpImpl.java
Last active November 12, 2015 18:07
SFTP transmission of content using apache VFS2 and OpenSSH private key
@Component
public class FileTransferScpImpl {
private final String userName;
private final String hostName;
private final FileSystemOptions opts;
private final StandardFileSystemManager manager;
private final String privateKeyPath;
@davengeo
davengeo / TrivialIT.java
Created February 11, 2016 12:17
useful IT test to list the beans
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
Application.class,
TrivialIT.PostConfiguration.class
})
@WebAppConfiguration
@IntegrationTest("server.port=0")
@ActiveProfiles({"default", "test"})
@ConfigurationProperties("application.yml")
public class TrivialIT {
@davengeo
davengeo / ChainOfMessageProcessors.java
Created April 25, 2016 16:37
My first default method in java 8
public interface ChainOfMessageProcessors extends MessagePostProcessor {
void setNext(ChainOfMessageProcessors next);
ChainOfMessageProcessors next();
default Message toNext(Message message) throws JMSException {
if (next()!=null) {
return next().postProcessMessage(message);
}
@davengeo
davengeo / serviced-client.js
Last active September 15, 2016 19:34
getIpvalue in javascript
function getPublicAddress() {
let interfaces = os.networkInterfaces();
return _.chain(interfaces)
.filter(function(o) {
return o[0].family == 'IPv4' && !_.startsWith(o[0].address, '192.168');
})
.flatten()
.value();
}