Skip to content

Instantly share code, notes, and snippets.

View bandrzejczak's full-sized avatar

Bartek Andrzejczak bandrzejczak

View GitHub Profile
/usr/lib/jvm/java-8-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53182,suspend=y,server=n -javaagent:/opt/idea-IU-139.222.5/plugins/Groovy/lib/agent/gragent.jar -Dfile.encoding=UTF-8 -classpath /opt/idea-IU-139.222.5/lib/idea_rt.jar:/opt/idea-IU-139.222.5/plugins/junit/lib/junit-rt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-8-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-8-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-8-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfxswt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/zip
@bandrzejczak
bandrzejczak / gist:33b3abd84b1bac6e3e6b
Created December 22, 2014 11:32
Degraph exception
java.lang.IncompatibleClassChangeError: class de.schauderhaft.degraph.analysis.asm.GraphBuildingClassVisitor has interface org.objectweb.asm.ClassVisitor as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
@bandrzejczak
bandrzejczak / VolatileMethodsSpec.java
Created January 8, 2015 21:14
Volatile method in Java
import org.junit.Test;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
public class VolatileMethodsSpec {
class Point {
private int x;
private int y;
public Point(int x, int y) {
setX(x);
setY(y);
}
public int getX() {
case class Point(var x: Int, var y: Int)
public Map<String, List<String>> makeWordMap(
List<String> sentences) {
Map<String, List<String>> result =
new HashMap<String, List<String>>();
for (String sentence: sentences) {
for (String word: words(sentence)) {
List<String> sentencesForWord = result.get(word);
if (sentencesForWord == null) {
def makeWordMap(sentences: List[String]):
Map[String, List[String]] = {
val initMap = Map.empty[String, List[String]]
sentences.foldLeft(initMap) { (map1, sentence) =>
words(sentence).foldLeft(map1) { (map2, word) =>
map2 +
(word -> (sentence :: map2.getOrElse(word, Nil)))
}
def plotSquares(n, plotter):
for x in range(0, n + 1):
plotter.plot(Point(x, x * x))
Integer getSongLength(
Artist artist,
String albumName,
String songName) {
Album album = artist.getAlbum(albumName);
if (album != null) {
Song song = album.getSong(songName);
if (song != null) {
return song.getLength();
Integer getSongLength(Artist artist, String albumName, String songName){
return artist
.getAlbum(albumName)
.map(a -> a.getSong(songName))
.map(Song::getTime)
.orElseThrow(() -> new NoSuchSongException(artist, albumName, songName));
}