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-rsyslog-with-relp.md
Last active February 5, 2022 21:28
Configure Rsyslog to use RELP for remote logging. #rsyslog #relp #logging
@drmalex07
drmalex07 / README-tree-dot-printer.md
Created November 20, 2018 21:42
Print a binary tree as DOT #cpp #binary-tree #DOT #dot #graphviz

Readme

Pipe to dot and then to display:

  ./a.out | dot -Tpng -Nshape=circle -Nfixedsize=true -Nfontname=serif -Nfontsize=10 -Nwidth=.5 | display
@drmalex07
drmalex07 / DbfToCsv.java
Created November 3, 2018 17:19
Convert a DBF file to CSV using Java. #dbf #csv #java
package com.example.scratch_java;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
@drmalex07
drmalex07 / singleton-example.cpp
Last active October 26, 2018 21:21
A singleton example in C++ #cpp #singleton
#include <iostream>
#include <vector>
#include <atomic>
#include <memory>
#include <stdexcept>
using namespace std;
namespace {
@drmalex07
drmalex07 / walk-dir.cpp
Created October 26, 2018 20:54
Walk a directory in C #opendir
#include <sys/types.h>
#include <dirent.h>
#include <cerrno>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
static const char* describe(const struct dirent * entry)
@drmalex07
drmalex07 / README-git-init-shared.md
Created October 3, 2018 11:22
Create a shared Git repository (for remote access) #git #git-init

Readme

Create repository folder with proper owner/group and permissions (group set-id so that subfolders are created under the same group). Say that we want group foo for this repository:

sudo mkdir hello-java.git
sudo chgrp foo hello-java.git
sudo chmod g+rwxs hello-java.git

Initialize repository:

@drmalex07
drmalex07 / binary-search.c
Created August 27, 2018 18:53
binary search example #binary-search #floor #ceiling
/**
* Search for key and return index inside a[0..n-1].
* If key does not exist, return -1.
*
* Precondition: The array a[0..n-1] is sorted
*/
int binary_search(int a[], int n, int key)
{
int start = 0, end = n;
@drmalex07
drmalex07 / log4j-with-smtp-appender.xml
Created July 21, 2018 20:12
Sample configuration with log4j with SMTP appender. #log4j #smtp
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="console">
<PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} %-5level %logger{36}.%M() @%L - %msg%n}"/>
</Console>
<!-- Note:
@drmalex07
drmalex07 / gen-bcrypt-password.py
Last active June 7, 2021 14:48
Generate BCrypt-ed password. #bcrypt
import bcrypt
encrypted_password = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt(rounds = 10, prefix=b"2a"))
@drmalex07
drmalex07 / pom-with-exec-h2.xml
Created June 17, 2018 18:38
An example maven-exec-plugin configuration for running H2 for development/testing purposes. #maven-exec-plugin #h2
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<!-- Start H2 server -->
<execution>
<id>h2-server</id>
<goals>
<goal>java</goal>