Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View MagnusSmith's full-sized avatar

Magnus Smith MagnusSmith

View GitHub Profile
@MagnusSmith
MagnusSmith / wordwrap.scala
Last active December 12, 2015 12:06
wordwrap in scala
import scala.annotation.tailrec
val sentence = "Four score and ten years ago our fathers brought forth upon this " +
"continent a new nation conceived in liberty and dedicated to the " +
"proposition that all men are created equal"
def wrap(source: String, len: Int):String = {
val wordChunks = sentence.split(" ").flatMap(x => x.grouped(len)).toList
@MagnusSmith
MagnusSmith / Application.java
Last active March 25, 2022 00:38
Java configuration for Spring with Axon Framework 2.09
package config;
import orders.commandhandling.Order;
import orders.commandhandling.OrderCommandHandler;
import org.axonframework.commandhandling.CommandBus;
import org.axonframework.commandhandling.SimpleCommandBus;
import org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor;
import org.axonframework.commandhandling.gateway.CommandGatewayFactoryBean;
import org.axonframework.eventhandling.EventBus;
import org.axonframework.eventhandling.SimpleEventBus;
@MagnusSmith
MagnusSmith / JpaRepository Example
Last active December 19, 2015 18:39
Starting with a simple entity UserAccount If you create an interface for a repository like below then Spring Data will create a proxy for you to inject into your service. It will automatically give you save, find, findAll, findOne, count methods for free (ie you don't have to do any implementation code). Since the UserAccount entity has a usern…
//JPA enitiy called UserAccount
@Entity
public class UserAccount {
@Id
private Long id;
private String username;
......
}
@MagnusSmith
MagnusSmith / ThirdParty.scala
Created January 22, 2013 13:23
My first attempt to use slick with play framework shows a slick table defined using a case class and a few helper methods to create, find, update and delete records
package models
import scala.slick.driver.H2Driver.simple._
import scala.slick.session.Session
/**
* Created with IntelliJ IDEA.
* User: Magnus.Smith
* Date: 21/01/13
* Time: 16:20