Skip to content

Instantly share code, notes, and snippets.

View akhikhl's full-sized avatar

Andrey Hihlovskiy akhikhl

  • Apple GmbH
  • Berlin, Germany
View GitHub Profile
@akhikhl
akhikhl / sierpinsky.turtle
Created February 10, 2014 16:44
Sierpinsky Triangle
learn triangle $x {
fw $x
tr 120
fw $x
tr 120
fw $x
tr 120
}
learn serpinsky $x, $level {
triangle $x
@akhikhl
akhikhl / gist:10540351
Created April 12, 2014 15:09
keybase.md
### 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 / XmlSlurper_vs_JDOM2.groovy
Created May 30, 2014 09:26
XmlSlurper vs JDOM2 performance
@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
@akhikhl
akhikhl / build.gradle
Last active August 29, 2015 14:02
Working gradle script for bintray and maven central upload
// 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 / stacktrace.txt
Created June 26, 2014 08:48
Gradle 2.0-rc-2 exception when reloading gradle project under Netbeans
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 / serialize.groovy
Created November 15, 2014 20:12
Serializable class in groovy script
// 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 / git-pull.gradle
Created June 7, 2013 05:22
Batch pull on all git-repositories found in the current folder
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.ajoberstar:gradle-git:0.5.0' }
}
import org.ajoberstar.gradle.git.tasks.*
def onEachGitFolder(File folder, Closure closure) {
File gitServiceFolder = new File(folder, ".git")
if(gitServiceFolder.exists() && gitServiceFolder.isDirectory())
@akhikhl
akhikhl / TestLogConfig.groovy
Last active December 19, 2015 15:29
"Manual" configuration of multiple logback encoders and appenders.
package testpackage
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.core.ConsoleAppender
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
@akhikhl
akhikhl / MyBirthday.java
Created July 12, 2013 08:47
My birthday!
class Main {
public void main(String[] args) {
Person p = new Person("Andrey", "Hihlovskiy", "12.07.1969");
boolean hasBirthDayToday = p.hasBirthDay(new Date());
if(hasBirthDayToday)
p.say("Friends", "Hey, guys, have a cake, it's my birthday!")
while(isWorkingHours()) {
p.work();
p.drink(DRINK.COFFEE, STRENGTH.EXTREME, 0.2);
@akhikhl
akhikhl / ParseRtf.groovy
Created July 14, 2013 07:48
A happier, groovier way to parse RTF: apache_tika + XmlSlurper
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)