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-launch-java-with-enabled-remote-jmx.md
Last active July 21, 2023 07:25
Start a java process with enabled remote JMX connections. #java #jmx #jconsole

README

At server

In this example we launch an H2 server, but it doesnt matter; same for any Java process.

Create a password file at ~/.jmxremote.password using $JRE_HOME/lib/management/jmxremote.password as a template.

JMX_PORT=1616
@drmalex07
drmalex07 / README-java-heap-usage.md
Last active May 10, 2020 20:01
Get Java heap usage. #java #heap #memory

README - Get Java heap usage

First, find PID of the Java process (e.g by using jps -lvm).

Use jstat to get measurements on the usage/capacity of the several memory pools of the heap (see also man jstat). The results are reported in kbytes.

Get heap capacity, usually referred to as commited size (i.e memory allocated from the OS), by summing up S0C, S1C, EC, OC columns:

jstat -gc ${pid} | gawk '{if (NR > 1) {printf("%.0fk\n", ($1 + $2 + $5 + $7))}}'
@drmalex07
drmalex07 / func-returning-record.sql
Last active April 13, 2020 11:04
An example on plpgsql functions returning a (single) record. #postgres #plpgsql
--
-- An example of a function returning a (single) record of (integer, integer, text)
--
CREATE OR REPLACE FUNCTION examine_change_of_status(
IN status text, IN prev_status text,
-- output parameters (correspond to fields of returned record)
OUT a_count integer, OUT b_count integer, OUT answer text)
AS $body$
BEGIN
@drmalex07
drmalex07 / README-setup-docker-registry.md
Last active February 9, 2021 15:00
Setup docker registry. #docker #docker-registry

README - Setup Docker registry

Let's assume that the FQDN name of the server will be registry.localdomain, and the service will be exposed as https://registry.localdomain:8443/.

1. Prerequisites

Create an environment file .env for the docker-compose project. An example content:

COMPOSE_PROJECT_NAME=registry_localdomain
@drmalex07
drmalex07 / setup-docker-on-ubuntu.yml
Created February 21, 2020 11:47
An ansible playbook for setting-up Docker under Ubuntu. #docker #ansible
# Run with: ansible-playbook -b
---
- hosts: all
pre_tasks:
- command: lsb_release -is
register: lsb_release_distributor_result
@drmalex07
drmalex07 / README-docker-nfs-volume.md
Last active February 11, 2020 12:46
An example creating a Docker volume on NFS. #docker #nfs #docker-volumes

Readme - Create a Docker volume on NFS

In this example, we directly instruct Docker to maintain a volume backed by NFS storage. Another way, of course, is to mount the NFS folder at the system level (afterwards, any container can bind-mount it).

By adding a Docker volume backed by NFS, Docker engine will take care of mounting/unmounting based on how containers are using this volume.

See also this comment:

@drmalex07
drmalex07 / README-bootable-usb-with-grub2.md
Last active February 9, 2020 09:15
Create bootable USB with Grub2. #grub #grub2 #boot #usb

README - Create bootable USB with GRUB2

Let /dev/sdb be the USB device. Create 1 VFAT partition at /dev/sdb1 and mount at /mnt/usb0.

Install GRUB on the device:

grub-install --boot-directory=/mnt/usb0/boot /dev/sdb

Now, all files needed by GRUB (e.g modules for filesystems) are under /mnt/usb0/boot/grub.

@drmalex07
drmalex07 / AbstractSpreadsheetReader.java
Last active February 28, 2021 12:31
A basic spreadsheet reader in Java. #xlsx #xls #spreadsheet #excel
package com.example.hello_spreadsheet;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@drmalex07
drmalex07 / README-openldap-add-memberof-overlay.md
Last active November 2, 2019 19:47
Add memberof overlay in OpenLDAP server. #ldap #openldap #memberof

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 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]