Skip to content

Instantly share code, notes, and snippets.

MichailAlexakis drmalex07

Block or report user

Report or block drmalex07

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@drmalex07
drmalex07 / AbstractSpreadsheetReader.java
Last active Nov 26, 2019
A basic spreadsheet reader in Java. #xlsx #xls #spreadsheet #excel
View AbstractSpreadsheetReader.java
package gr.auth.physics.magnetized.etl.util;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.poi.ss.usermodel.Cell;
@drmalex07
drmalex07 / README-openldap-add-memberof-overlay.md
Last active Nov 2, 2019
Add memberof overlay in OpenLDAP server. #ldap #openldap #memberof
View README-openldap-add-memberof-overlay.md

README - Add membeof overlay in OpenLDAP

Update configuration using ldapmodify and using the following LDIF:

dn: cn=module,cn=config
cn: module
objectClass: olcModuleList
olcModuleLoad: memberof
olcModulePath: /usr/lib/ldap
@drmalex07
drmalex07 / README-systemd-service-executable-jar.md
Created Oct 30, 2019
A very simple systemd service for a Spring-Boot executable JAR. #systemd #spring-boot
View README-systemd-service-executable-jar.md

An example service definition under /etc/systemd/system/foo.service:

[Unit]

Description=Foo Service
After=network.target 

[Service]
@drmalex07
drmalex07 / YarnHelpers_ExtractLog.java
Created Oct 21, 2019
Extract logs from YARN containers. #hadoop #yarn #tfile #logs #yarn-logs
View YarnHelpers_ExtractLog.java
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BoundedInputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
@drmalex07
drmalex07 / SubmitSparkApplication.java
Created Oct 18, 2019
An example of a programmatic submit of a Spark application. #spark #spark-submit #sparklauncher
View SubmitSparkApplication.java
import java.io.File;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.spark.launcher.SparkAppHandle;
import org.apache.spark.launcher.SparkLauncher;
/**
* An example of submitting a Spark application in a programmatic manner
*/
@drmalex07
drmalex07 / README-submit-to-livy.md
Last active Oct 18, 2019
An example submit to Apache Livy. #livy #spark
View README-submit-to-livy.md

README - Submit to Livy using REST API

See https://livy.apache.org/docs/latest/rest-api.html

Let app.json be the JSON payload that represents the application:

{
    "file": "hdfs:///user/user/apps/hello-spark-0.0.1.jar",
    "className": "acme.hello_spark.Grep",
    "args": ["input/1.txt", "[Mm]agic"],
@drmalex07
drmalex07 / README-ssl-context-for-apache-httpclient.md
Created Sep 19, 2019
An example of using custom SSL context in Apache HttpClient. #https #ssl #apache-httpclient #keystore #certificate
View README-ssl-context-for-apache-httpclient.md

README - SSL context for Apache HttpClient

Load keystore as usual:

KeyStore keystore = KeyStore.getInstance("PKCS12");
try (InputStream in = Files.newInputStream("keystore.p12")) {
  keystore.load(in, "secret".toCharArray());
}
@drmalex07
drmalex07 / README-lombok.md
Last active Sep 8, 2019
An example with Lombok-generated classes. #lombok #java
View README-lombok.md

README - Lombok

In the following examples, i also add field-level constraints for JSR-303 validation.

1. Typical usage

1.A. A java bean (getters/setters)

@lombok.Data
@drmalex07
drmalex07 / README-List-Directory-in-WebDAV.md
Last active Jul 19, 2019
List directory in WebDav #webdav
View README-List-Directory-in-WebDAV.md

Readme - List directory in WebDAV

1. An example request

To list properties of a directory we must use the PROPFIND method of WebDAV protocol and provide a request body with properties we are interested into. We must also provide the Depth header (otherwise the request is rejected as 403 Forbidden).

To retrieve basic properties as size and type, prepare a request body (say propfind-basic.xml) as:

@drmalex07
drmalex07 / README-apache-balancer-with-stickysession.md
Last active Jun 27, 2019
Setup apache as a load balancer with sticky sessions. #apache #balancer #stickysession
View README-apache-balancer-with-stickysession.md

Readme

We need to enable at least the following modules: headers, env, proxy, proxy_http, proxy_balancer. If we are proxying over AJP of course we should also enable proxy_ajp.

The following is a sample configuration for a site acting as a balancer to 2 instances of a backend application:

<IfModule mod_ssl.c>
    <VirtualHost 192.168.1.6:443>
You can’t perform that action at this time.