Skip to content

Instantly share code, notes, and snippets.

View zedar's full-sized avatar

Robert Zakrzewski zedar

  • Twitter@zedar185
View GitHub Profile
@zedar
zedar / ApacheHadoopSpark_LZO.adoc
Last active April 24, 2024 14:33
Add LZO compression codecs to the Apache Hadoop and Spark

Add LZO compresssion codecs to the Apache Hadoop and Spark

LZO is a splittable compression format for files stored in Hadoop’s HDFS. It has valuable combination of speed and compression size. Thanks to hadoop-lzo the .lzo files could be splittable too.

  • Install lzo and lzop codes [OSX].

$ brew install lzo lzop
  • Find where the headers and libraries are installed

@zedar
zedar / ApacheHadoop_NativeLibs.adoc
Last active August 13, 2020 00:59
Add native libraries to Apache Hadoop installation

Apache Hadoop - add native libraries

If native libraries are not available the following message is displayed with every hadoop command: hadoop checknative

WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  • Clone hadoop source code


@zedar
zedar / build.gradle
Created May 15, 2015 06:50
Gradle template for custom ratpack module
// ---------------------------------------------------------------------------------------------------------------------
// module build and dependencies
// ---------------------------------------------------------------------------------------------------------------------
apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"
if (!JavaVersion.current().java6Compatible) {
throw new IllegalStateException("Must be built at least with Java 8")
@zedar
zedar / gist:801f6d28510515cb41d0
Created February 15, 2015 13:45
Intellij OSX and JVM version

After installing Intellij IDEA 14 in OSX you can get a message that JRE 1.6 is required to run it. If you have already installed JDK1.7 or JDK1.8 do following changes:

$ cd /Applications/IntelliJ\ IDEA\ 14\ CE.app/Contents/
$ vim Info.plist

Change

<key>JVMVersion</key>

1.6*

@zedar
zedar / GradleConflictingJarsInPlugins.md
Last active August 29, 2015 14:11
Gradle - conficting jars in plugins

Gradle - conflicting jar files (plugin) on classpath

Problem description

If you get an issue related to incorrect jar files on classpath while invoking gradle plugin, move the plugin's tasks into seperate build file. Use GradleBuild task type with reference to seperated build file.

Example

When developing small extension for ratpack manual I had to add gradle-js plugin with two tasks for combining javascript files into one file and then minifying it. Minification task thrown exception idicating that there are conflicting jar file versions for google's guava library:

java.lang.NoSuchMethodError: com.google.common.io.ByteStreams.limit

@zedar
zedar / GroovyHTTPBuilderChunkedResponse.md
Last active August 29, 2015 14:08
HTTPBuilder and chunked response

There is a bug in Groovy version up to 2.3.7. HTTPBuilder is not able to automatically parse chunked response to JSON format. If external server returns response with header:

Transfer-Encoding : chunked

Usually applied code:

def http = new HTTPBuilder(url)

def result = http.request(POST, JSON) { req ->

@zedar
zedar / StartingMounteBankStubsFromGradle.md
Last active March 19, 2018 11:19
Starting MounteBank stubs from inside gradle

MounteBank for API stubbing

While developing application with external API calls stubs with some logic are mandatory. MounteBank provides bright and simple solution for stubbing HTTP API.

It is possible to start MounteBank server directly from command line and initialize its content with folllowing curl command:

$ mb
$ curl -X POST -d@./src/test/groovy/online4m/apigateway/si/test/imposter.json http://localhost:2525/imposters
@zedar
zedar / RatpackBindObjectInstance.md
Last active November 29, 2018 01:05
Ratpack: bind object instance to Guice registry

Binding object instances as singletons

To bind object instance to be accessible accross handlers and custom classes define module and provider method. Add @Singleton annotation to have one instance for all injections.

import com.google.inject.AbstractModule
import com.google.inject.Scopes
import com.google.inject.Provides
import com.google.inject.Singleton

class CallerModule extends AbstractModule {

@zedar
zedar / RatpackTestsAndExternalProperties.md
Last active August 29, 2015 14:07
Ratpack tests and external .properties

Ratpack tests are based on Spock Framework.

To externalize properties from test cases, create new file in:

$ touch src/tests/resources/hipchat.properties

Put properties into the file:

auth_token=VALUE_OF_HIPCHAT_AUTH_TOKEN
@zedar
zedar / HTTPBuilderAndJsonOutput.md
Last active August 29, 2015 14:07
Incompatibility of HTTPBuider and groovy.json.JsonOutput

Groovy - StackOverflowError while incompatible versions of HTTPBuilder and JsonOutput

When working on microservice API Gateway that is Ratpack based I encountered StackOverflowError thrown by groovy.json.JsonOutput.toJson() method.

Versions of groovyx.net.http.HTTPBuilder prior to 0.6 used internaly json-io library. As of version 0.6 it changed to native Groovy's JsonSlurper to cosume JSON.

If you use JsonOutput.toJson(groovyObject) and this groovyObject was generated by the following code:

def http = new HTTPBuilder(url)