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
@timyates
timyates / arrowdoc.groovy
Created April 11, 2015 09:10
ascii-image and document-builder sitting in a tree
@Grab(group='com.craigburke.document', module='pdf', version='0.3.1')
@Grab(group='com.craigburke.document', module='word', version='0.3.1')
@Grab('com.bloidonia:ascii-image:1.1')
import com.bloidonia.asciiimage.AsciImageProcessor
import java.awt.image.BufferedImage
import java.awt.RenderingHints
import java.awt.Color
import javax.imageio.ImageIO
import com.craigburke.document.builder.PdfDocumentBuilder
@timyates
timyates / arrow.groovy
Last active February 9, 2022 00:07
Using AsciImage from Groovy
// Requires Groovy 2.4+ and Java 8
@Grab('com.bloidonia:ascii-image:1.1')
import com.bloidonia.asciiimage.AsciImageProcessor
import java.awt.image.BufferedImage
import java.awt.RenderingHints
import java.awt.Color
AsciImageProcessor.fromLines([
'. . . . . . .',
'. . 3 . . . .',
@melix
melix / Dockerfile
Last active June 2, 2020 01:37
Dockerfile for Groovy
################################################
# Dockerfile to run Groovy containers
# Based on Java 8 image
################################################
FROM java:8u40-jdk
MAINTAINER Cédric Champeau
# Install GVM
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:+'
}
}
apply plugin: 'org.akhikhl.gretty'
@timyates
timyates / YCombinatorFactorial.java
Last active August 29, 2015 14:00
Y Combinator based factorial in Java 8
package test;
import java.math.BigInteger;
import java.util.function.Function;
public class YCombinatorFactorial<T> {
private interface Improver<T> {
Function<T,T> apply( Improver<T> f ) ;
}
@timyates
timyates / forceOverrideTraits.groovy
Last active October 21, 2015 04:25
Messing with groovy traits
// Bad example of @ForceOverride... enjoy! (?)
import groovy.transform.*
class BasicIntQueue extends LinkedList<Integer> {
Integer get() {
this.poll()
}
void put( Integer x ) {
@melix
melix / README.adoc
Last active July 7, 2021 07:37
An automated solver for 2048

Automated solver for 2048

This is a script which runs a "bot" that tries to solve the incredibly addictive 2048 game. It makes use of Groovy and browser automation with Geb.

How to

  • First step, if you don’t have it, you need to install Groovy.

  • Second step is to install the Google Chrome WebDriver (just unzip the appropriate file to a local directory)

  • Next, edit the script to set the path to the Chrome Driver

  • then execute the script: groovy solver2048.groovy

@ysb33r
ysb33r / RelativePath.groovy
Last active November 4, 2022 14:18
The Groovy way to obtain a relative path given two paths.
def root= new File('/usr/share')
def full= new File('/usr/share/docs/rpm-4.4')
// Print the relative path of 'full' in relation to 'root'
// Notice that the full path is passed as a parameter to the root.
def relPath= new File( root.toURI().relativize( full.toURI() ).toString() )
@deanriverson
deanriverson / build.gradle
Last active May 12, 2018 12:55
Basic Gradle build file for a project using GroovyFX 0.2
apply plugin:'groovy'
project.ext.set('javafxHome', System.env['JAVAFX_HOME']
repositories { mavenCentral() }
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.8.6'
compile 'org.codehaus.groovyfx:groovyfx:0.4.0'
compile files("${javafxHome}/rt/lib/jfxrt.jar")