Skip to content

Instantly share code, notes, and snippets.

View banterCZ's full-sized avatar

Luboš Račanský banterCZ

View GitHub Profile
@banterCZ
banterCZ / pom.xml
Last active August 29, 2015 14:20
Dependency mediation - this determines what version of a dependency will be used when multiple versions of an artifact are encountered. http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cz.zvestov.mvn</groupId>
<artifactId>transitive-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
@banterCZ
banterCZ / build.gradle
Last active August 29, 2015 14:20
A version conflict results in a build failure. This strategy requires all version conflicts to be resolved explicitly in the build script. https://gradle.org/docs/current/userguide/dependency_management.html#sub:version_conflicts
apply plugin: 'java'
repositories {
mavenLocal()
}
configurations.all {
//TODO comment out to result in a build failure
//resolutionStrategy.failOnVersionConflict()
}
@banterCZ
banterCZ / Employee.java
Last active August 29, 2015 14:17
JPA association class
import javax.persistence.*;
import java.util.Map;
@Entity
public class Employee {
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
@Column(name = "EMP_ID")
private Integer id;
@banterCZ
banterCZ / pom-module.xml
Created March 23, 2015 12:37
maven multi-module build sample
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parent</artifactId>
<groupId>cz.zvestov.mvn-multimodule-sample</groupId>
<version>1.0.0-SNAPSHOT</version>
@banterCZ
banterCZ / Accumulator.clj
Created July 11, 2014 14:10
We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i. See the article Revenge of the Nerds http://www.paulgraham.com/icad.html This Clojure solution comes from http://rosettacode.org/wiki/Accumulator_factory#Clojure
(defn accum [n]
(let [acc (atom n)]
(fn [m] (swap! acc + m))))
@banterCZ
banterCZ / Accumulator.scala
Last active August 29, 2015 14:03
We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i. See the article Revenge of the Nerds http://www.paulgraham.com/icad.html This Scala solution comes from http://rosettacode.org/wiki/Accumulator_factory#Scala
def AccumulatorFactory[N](n: N)(implicit num: Numeric[N]) = {
import num._
var acc = n
(inc: N) => {
acc = acc + inc
acc
}
}
@banterCZ
banterCZ / Accumulator.groovy
Last active August 29, 2015 14:02
We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i. See the article Revenge of the Nerds http://www.paulgraham.com/icad.html
def foo(n) {
return {n += it}
}
def accumulator = foo(1)
assert accumulator(2) == 3
assert accumulator(3) == 6
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ErrorCollector
import org.openqa.selenium.By
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver
import static org.hamcrest.core.Is.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import static org.junit.runners.Parameterized.Parameters
import static org.junit.Assert.assertEquals
/**
* @author banterCZ
sudo apt-get install \
mc \
tree \
gimp \
xpaint \
subversion \
git \
mercurial \
vim-gnome \
synaptic \