Skip to content

Instantly share code, notes, and snippets.

@msulima
msulima / gist:3187473
Created July 27, 2012 11:23
FulfilsPredicateAspect
package com.futureprocessing.fpcommunity.core.validation.groups;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
public aspect FulfilsPredicateAspect {
pointcut hasFulfisPredicateArguments() : execution(* *(.., @com.futureprocessing.fpcommunity.core.validation.groups.FulfilsPredicate (*) ,..));
pointcut isSpringComponent() : (@within(Service) || @within(Component)) && within(com.futureprocessing.fpcommunity..*);
before() : hasFulfisPredicateArguments() && isSpringComponent() {
@msulima
msulima / gist:3187475
Created July 27, 2012 11:23
FulfilsPredicate
package com.futureprocessing.fpcommunity.core.validation.groups;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.google.common.base.Predicate;
@Target(value = ElementType.PARAMETER)
@Retention(value = RetentionPolicy.RUNTIME)
@msulima
msulima / gist:3187477
Created July 27, 2012 11:24
EventResignServiceImpl
package com.futureprocessing.fpcommunity.core.services.events;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.stereotype.Service;
import org.springframework.validation.Validator;
import com.futureprocessing.fpcommunity.core.datetime.IDateTime;
import com.futureprocessing.fpcommunity.core.domain.Event;
import com.futureprocessing.fpcommunity.core.domain.User;
import com.futureprocessing.fpcommunity.core.exceptions.EventEndedException;
@msulima
msulima / gist:3187481
Created July 27, 2012 11:26
EventResignController
package com.futureprocessing.fpcommunity.controllers.event;
import java.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@msulima
msulima / gist:3748556
Created September 19, 2012 08:59
IntelliJ run DevMode JVM arguments
-Xms512m
-Xmx512m
-classpath
"C:\Java\MavenRepo\com\parkeon\gto\transfolio\product\transfolio-address-interface\2.10.0-SNAPSHOT\transfolio-address-interface-2.10.0-SNAPSHOT.jar;C:\Java\MavenRepo\com\parkeon\gto\core\gto-core\2.10.0-SNAPSHOT\gto-core-2.10.0-SNAPSHOT.jar;C:\Java\MavenRepo\org\springframework\spring-beans\3.1.0.M2\spring-beans-3.1.0.M2.jar;C:\Java\MavenRepo\org\springframework\spring-core\3.1.0.M2\spring-core-3.1.0.M2.jar;C:\Java\MavenRepo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\Java\MavenRepo\org\springframework\spring-context\3.1.0.M2\spring-context-3.1.0.M2.jar;C:\Java\MavenRepo\org\springframework\spring-expression\3.1.0.M2\spring-expression-3.1.0.M2.jar;C:\Java\MavenRepo\org\springframework\spring-asm\3.1.0.M2\spring-asm-3.1.0.M2.jar;C:\Java\MavenRepo\org\springframework\spring-aop\3.1.0.M2\spring-aop-3.1.0.M2.jar;C:\Java\MavenRepo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Java\MavenRepo\org\aspectj\aspectjweaver\1.5.4\aspectjweaver-1.5.4.jar;C:\Java\Mave
package pl.baza.gui.controllers.tasks;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.springframework.beans.factory.InitializingBean;
import concurrent.duration._
import concurrent.{Await, Future, Promise}
import org.scalatest.FunSuite
import scala.concurrent.ExecutionContext.Implicits.global
class Snippets extends FunSuite {
test("Promise can be fulfilled") {
val numberPromise = Promise[Int]()
val addedFuture = addThree(numberPromise.future)
import java.util.concurrent.Semaphore
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import org.scalatest.FunSuite
class CallbacksTest extends FunSuite {
test("Callback are complicated") {
var result: Int = 0; val semaphore = new Semaphore(1, true)
generateNumber(generatedNumber => addThree(generatedNumber,
FROM CardTransactionEntity AS ct WHERE (EXISTS(FROM TravelProductOnCardEntity AS prod WHERE ct.travelProductOnCard = prod AND prod.smartCard.smartCardId = :smartCardId) OR EXISTS(FROM ProfileOnCardEntity AS prof WHERE ct.profileOnCard = prof AND prof.smartCard.smartCardId = :smartCardId)) ORDER BY ct.transactionDate DESC
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global
import org.scalatest.FunSuite
class ErrorsTest extends FunSuite {
test("Future can recover from error") {
val numberFuture: Future[Int] = generateNumber()
val addedFuture: Future[Int] = numberFuture.map(addThree).recover({
case exception: IllegalStateException => -1