This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2013 (c) Andrey Hihlovskiy | |
* License: MIT (http://opensource.org/licenses/MIT) | |
*/ | |
@Grab('org.jdom:jdom2:2.0.5') | |
@Grab('jaxen:jaxen:1.1.4') | |
@GrabExclude('jdom:jdom') | |
import org.jdom2.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '1.1.0.RELEASE' | |
} | |
repositories { | |
mavenLocal() | |
jcenter() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add this to the parent "build.gradle" to enable xyz-sources.jar and xyz-javadoc.jar generation | |
* for every java and groovy subproject of the given parent project. | |
* The script tolerates non-java subprojects. | |
*/ | |
subprojects { | |
afterEvaluate { | |
if(tasks.findByName("classes")) { | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.Color; | |
import java.awt.event.*; | |
import java.awt.geom.*; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import java.awt.Rectangle; | |
public class Ball extends JComponent { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('javax.servlet:javax.servlet-api:3.0.1') | |
@Grab(group='org.eclipse.jetty', module='jetty-webapp', version='8.1.8.v20121106') | |
@Grab(group='org.eclipse.jetty', module='jetty-server', version='8.1.8.v20121106', transitive=false) | |
@Grab(group='org.eclipse.jetty', module='jetty-servlet', version='8.1.8.v20121106', transitive=false) | |
@GrabExclude('org.eclipse.jetty.orbit:javax.servlet') | |
import org.eclipse.jetty.server.Server | |
import org.eclipse.jetty.servlet.* | |
import groovy.servlet.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.Map; | |
import java.util.LinkedHashMap; | |
import java.util.List; | |
class FloatEntryComparator implements Comparator<Map.Entry> { | |
public int compare(Map.Entry e1, Map.Entry e2) { | |
return ((Float)e2.getValue()).intValue() - ((Float)e1.getValue()).intValue(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
rand = new Random(); | |
float random(float minX, float maxX) { | |
rand.nextFloat() * (maxX - minX) + minX | |
} | |
// Note the HashMap's "key" is a String and "value" is an Integer | |
HashMap<Float,Float> hm = new HashMap<Float,Float>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.xml.transform.TransformerFactory | |
import javax.xml.transform.stream.StreamResult | |
import javax.xml.transform.stream.StreamSource | |
def input = '''<?xml version="1.0"?> | |
<p>This is <b>bold text</b>, <i>italic text</i> and normal text</p> | |
''' | |
def xslt = '''<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" indent="yes" encoding="UTF-8"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isGreaterThan(a, b) { a > b } | |
def isGreaterThan(b) { | |
return { a -> isGreaterThan(a, b) } | |
} | |
def isLessThan(a, b) { a < b } | |
def isLessThan(b) { | |
return { a -> isLessThan(a, b) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.akhikhl.test | |
import org.apache.tika.metadata.Metadata | |
import org.apache.tika.parser.rtf.RTFParser | |
class ParseRtf { | |
def parse(String rtfText) { | |
// not validating, not ns-aware | |
XmlSlurper slurper = new XmlSlurper(false, false) |
NewerOlder