Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrey Hihlovskiy akhikhl

View GitHub Profile
@akhikhl
akhikhl / serialize.groovy
Created Nov 15, 2014
Serializable class in groovy script
View serialize.groovy
// The code below produces ClassNotFoundError. How to fix it?
import groovy.transform.ToString
@ToString
class P2ModuleSource implements Serializable {
private static final long serialVersionUID = 3526473395612776159L
List uris
P2ModuleSource(List uris) {
this.uris = uris
@akhikhl
akhikhl / stacktrace.txt
Created Jun 26, 2014
Gradle 2.0-rc-2 exception when reloading gradle project under Netbeans
View stacktrace.txt
Issue 1
--------
Requested project: /home/ahi/Projects/SampleProject
Stack trace:
org.gradle.tooling.BuildException: Could not run build action using Gradle installation '/home/ahi/.gvm/gradle/2.0-rc-2'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
@akhikhl
akhikhl / build.gradle
Last active Aug 29, 2015
Working gradle script for bintray and maven central upload
View build.gradle
// This is working gradle script for uploading artifacts of the given project
// to bintray/jcenter and to maven central (via bintray "sync to maven central" function).
// This script can be included from other scripts via `apply from: 'filename'` syntax.
apply plugin: 'signing'
apply plugin: 'maven-publish'
apply plugin: 'bintray'
import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact
@akhikhl
akhikhl / build.gradle
Created Jun 11, 2014
Simplest Gretty setup with Spring Boot
View build.gradle
buildscript {
ext {
springBootVersion = '1.1.0.RELEASE'
}
repositories {
mavenLocal()
jcenter()
}
@akhikhl
akhikhl / XmlSlurper_vs_JDOM2.groovy
Created May 30, 2014
XmlSlurper vs JDOM2 performance
View XmlSlurper_vs_JDOM2.groovy
@Grab('org.jdom:jdom2:2.0.5')
@Grab('xerces:xercesImpl:2.11.0')
@Grab('xml-apis:xml-apis:1.4.01')
@Grab('jaxen:jaxen:1.1.4')
@GrabExclude(group='jdom', module='jdom')
@GrabExclude(group='org.jdom', module='jdom')
import org.jdom2.Document
import org.jdom2.Element
import org.jdom2.JDOMException
View gist:10540351
### Keybase proof
I hereby claim:
* I am akhikhl on github.
* I am akhikhl (https://keybase.io/akhikhl) on keybase.
* I have a public key whose fingerprint is 3817 213B F592 2F04 4534 C0EC 125B 5BF8 F575 C5C0
To claim this, I am signing this object:
@akhikhl
akhikhl / sierpinsky.turtle
Created Feb 10, 2014
Sierpinsky Triangle
View sierpinsky.turtle
learn triangle $x {
fw $x
tr 120
fw $x
tr 120
fw $x
tr 120
}
learn serpinsky $x, $level {
triangle $x
@akhikhl
akhikhl / sort_map_by_values.java
Created Jan 4, 2014
Sorting map by values. Tested in Processing IDE (www.processing.org).
View sort_map_by_values.java
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();
}
}
@akhikhl
akhikhl / physical_ball_2d_graphics.groovy
Created Dec 31, 2013
2d graphics simulation of a ball in gravity field. Energy conservation law is respected.
View physical_ball_2d_graphics.groovy
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 {
@akhikhl
akhikhl / sort_map_by_values.groovy
Created Dec 27, 2013
Sorting hashmap float -> float by values
View sort_map_by_values.groovy
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>();