Skip to content

Instantly share code, notes, and snippets.

Avatar

Rufer Marc rufer7

View GitHub Profile
@rufer7
rufer7 / CurrentUserDataHelper.cs
Created Aug 27, 2015
An example for impersonate a service reference call
View CurrentUserDataHelper.cs
namespace how.To.Impersonate.Service.Reference.Call
{
public static class CurrentUserDataHelper
{
public static String GetCurrentUserId()
{
var administrationService = GetServiceReferenceInstance();
var identity = (WindowsIdentity)HttpContext.Current.User.Identity;
administrationService.Credentials = CredentialCache.DefaultCredentials;
using (var impersonationContext = identity.Impersonate())
@rufer7
rufer7 / SwisscomSmsSenderExample.java
Last active Aug 29, 2015
How to use swisscom-sms-api-client
View SwisscomSmsSenderExample.java
import be.rufer.swisscom.sms.api.client.SwisscomSmsSender;
import be.rufer.swisscom.sms.api.domain.CommunicationWrapper;
public class SwisscomSmsSenderExample
{
public static void main( String[] args )
{
// SENDER_NUMBER and RECEIVER_NUMBER1 in the following format: +41791234567
SwisscomSmsSender smsSender = new SwisscomSmsSender("API_KEY", "SENDER_NUMBER");
CommunicationWrapper response = smsSender.sendSms("MESSAGE", "RECEIVER_NUMBER1");
@rufer7
rufer7 / SampleGateway.java
Last active Aug 29, 2015
Gateway definition example
View SampleGateway.java
package be.rufer.amqp.integration.messaging.gateway;
import org.springframework.integration.Message;
public interface SampleGateway {
void sendSomething(@Payload Object object, @Header("header-key") headerValue);
}
@rufer7
rufer7 / sample-message-bus-config.xml
Last active Aug 29, 2015
Sample configuration for spring integration gateways to integrate with AMQP (Rabbitmq)
View sample-message-bus-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp
http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
@rufer7
rufer7 / SampleErrorHandler.java
Last active Aug 29, 2015
Example of an error handler, which rejects the message without requeuing it
View SampleErrorHandler.java
package be.rufer.amqp.integration.messaging.handler.error;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.util.ErrorHandler;
public class DefaultErrorHandler implements ErrorHandler {
@Override
public void handleError(Throwable throwable) {
throw new AmqpRejectAndDontRequeueException(throwable);
@rufer7
rufer7 / LogSamples.java
Last active Aug 29, 2015
Log4j logging examples
View LogSamples.java
import org.slf4j.Logger;
public class LogSamples {
private static final Logger LOG = LoggerFactory.getLogger(LogSamples.class);
public static void main(String args[]){
Object o = new Object;
// Sample 1
@rufer7
rufer7 / log4j.properties
Last active Aug 29, 2015
Log4j - rolling file appender sample
View log4j.properties
log4j.logger.org.web.rufer.sample=DEBUG,ROLLINGFILEAPPENDER
## Rolling file appender sample
log4j.appender.ROLLINGFILEAPPENDER=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILEAPPENDER.File=${catalina.base}/logs/sample.log
log4j.appender.ROLLINGFILEAPPENDER.MaxFileSize=25mb
log4j.appender.ROLLINGFILEAPPENDER.MaxBackupIndex=3
log4j.appender.ROLLINGFILEAPPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILEAPPENDER.layout.ConversionPattern=%d{ISO8601} %-5p %-85.85c - %m%n
View HornetsKeyMatcherExecutor.java
package be.rufer.swissunihockey;
import be.rufer.swissunihockey.matcher.KeyMatcher;
import be.rufer.swissunihockey.matcher.MatchingPrinter;
import be.rufer.swissunihockey.matcher.domain.MatchingResult;
import be.rufer.swissunihockey.matcher.domain.League;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.HashMap;
@rufer7
rufer7 / swissunihockey-key-matcher-result
Created Mar 26, 2015
Excerpt of the result of swissunihockey-key-matcher
View swissunihockey-key-matcher-result
H1L GF U21C Matches
6 3 3
6 2 3
6 5 3
6 4 3
...
@rufer7
rufer7 / SampleHeaderEnricher.java
Last active Aug 29, 2015
Custom header enricher, which returns the headers to add to messages
View SampleHeaderEnricher.java
package be.rufer.amqp.integration.messaging.enricher;
import org.springframework.integration.Message;
import java.util.HashMap;
import java.util.Map;
public class SampleHeaderEnricher {
public Map<String, Object> addCustomHeaders(Message<?> message) {