Skip to content

Instantly share code, notes, and snippets.

View novoj's full-sized avatar
💻
Hacking on evitaDB

Jan Novotný novoj

💻
Hacking on evitaDB
View GitHub Profile
@novoj
novoj / MonteCarlo.java
Created December 10, 2012 09:13
Monte Carlo test for testing different strategies for guessing game. You have three doors and only one is winning one. You make your choice, and then moderator opens some other door showing you that this doors don't win. He then offers you to change your guess. Will you have bigger chance to win when you change your mind or not?
import java.util.Random;
public class MonteCarlo {
private enum Choice {
WINNING, LOSING
}
private static int ITERATIONS = 1000000;
private static final Random randomGenerator = new Random();
private static GuessStrategy stayStrategy = new StayStrategy();
@novoj
novoj / ExperimentalPrePostAnnotationSecurityMetadataSource.java
Created March 18, 2012 21:12
Combining custom annotations for securing methods with Spring Security (http://blog.novoj.net)
package cz.novoj.spring.security.aop;
import cz.novoj.spring.security.annotation.RulesRelation;
import cz.novoj.spring.security.annotation.RulesRelation.BooleanOperation;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.method.AbstractMethodSecurityMetadataSource;
import org.springframework.security.access.prepost.*;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;