Skip to content

Instantly share code, notes, and snippets.

View drmalex07's full-sized avatar

MichailAlexakis drmalex07

  • IMIS "Athena" Research Center
  • Athens, Greece
View GitHub Profile
@drmalex07
drmalex07 / README-systemd-service-executable-jar.md
Created October 30, 2019 11:37
A very simple systemd service for a Spring-Boot executable JAR. #systemd #spring-boot

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

[Unit]

Description=Foo Service
After=network.target 

[Service]
@drmalex07
drmalex07 / YarnHelpers_ExtractLog.java
Created October 21, 2019 10:12
Extract logs from YARN containers. #hadoop #yarn #tfile #logs #yarn-logs
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 October 18, 2019 07:17
An example of a programmatic submit of a Spark application. #spark #spark-submit #sparklauncher
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 December 30, 2021 14:25
An example submit to Apache Livy. #livy #spark

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 September 19, 2019 21:18
An example of using custom SSL context in Apache HttpClient. #https #ssl #apache-httpclient #keystore #certificate

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 September 8, 2019 19:53
An example with Lombok-generated classes. #lombok #java

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 November 22, 2023 16:58
List directory in WebDav #webdav

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 April 19, 2023 11:08
Setup apache as a load balancer with sticky sessions. #apache #balancer #stickysession

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>
@drmalex07
drmalex07 / constexpr-object-example.cpp
Last active May 30, 2019 15:45
A constexpr example in C++14 with custom object initialization. #c++ #constexpr
#include <iostream>
using namespace std;
constexpr int get_magic_number(int x)
{
return x + 1999;
}
template <int N>
@drmalex07
drmalex07 / Notes-Archive-CKAN-resources.md
Last active November 13, 2019 15:25
Archive resources from CKAN catalogue. #CKAN

Archive resources from CKAN catalogue

1. Replace resource file with symbolic link

A resource file can be archived without breaking the file hierarchy that CKAN builds under /var/lib/files/resources. The actual data for a resource 7896ea0c-504d-401c-818f-065430419695 will be stored as a regular file under a 3-level hierarchy at 789/6ea/0c-504d-401c-818f-065430419695.

For example:

tree resources
...