Skip to content

Instantly share code, notes, and snippets.

István Sárándi isarandi

Block or report user

Report or block isarandi

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
isarandi /
Last active Jun 19, 2019
Procrustes transformation implemented in TensorFlow
def procrustes(X, Y, allow_scaling=False, allow_reflection=False):
"""Register the points in Y by rotation, translation, uniform scaling (optional) and reflection (optional)
to be closest to the corresponding points in X, in a least-squares sense.
This function operates on batches. For each item in the batch a separate
transform is computed independently of the others.
X: Tensor with shape [batch_size, n_points, point_dimensionality]
Y: Tensor with shape [batch_size, n_points, point_dimensionality]
isarandi /
Last active Mar 7, 2019
Parallel input pipeline as a TensorFlow Dataset
def parallel_map_as_tf_dataset(
fun, iterable, *, output_types=None, output_shapes=None, shuffle_before_each_epoch=False,
extra_args=None, n_workers=10, n_epochs=None):
"""Maps `fun` to each element of `iterable` and wraps the resulting sequence as
as a TF Dataset. Elements are processed by parallel workers using multiprocessing.
fun: A function that takes an element from `iterable` plus `extra_args` and returns a sequence of
numpy arrays.
iterable: An iterable holding the input objects, which can be any Python objects, not just numpy arrays.
isarandi /
Created Jun 18, 2018
Camera class with methods to transform coordinates, transform images, and change parameters intuitively (e.g. zoom, orbit around or turn towards point, center principal point)
import cv2
import numpy as np
class Camera:
def __init__(self, eye_point, rot_matrix_world_to_cam, intrinsic_matrix, distortion_coeffs):
"""Initializes camera.
eye_point: position of the camera in world coordinates
isarandi / dsm.conf
Created Jun 12, 2018
Parsing Tivoli Storage Manager logs for syslog-ng
View dsm.conf
log {
source { file("/var/log/dsmsched.log" follow-freq(10) flags(no-parse)); };
parser { python(class("TivoliParser")); };
python {
import re
import dateutil.parser
import socket
isarandi / fail2ban.conf
Last active Jun 11, 2018
syslog-ng parser for fail2ban's logfile (parsing for graylog)
View fail2ban.conf
source s_fail2ban {
file("/var/log/fail2ban.log" follow-freq(10) flags(no-parse));
parser fail2ban-parser {
options("regex", '(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) (?P<PROGRAM>.+?)\.(?P<type>.+?) +\[(?P<PID>\d+)\]: (?P<level>.+?) +(?P<MSG>.+)')
isarandi /
Created Dec 2, 2015
Sometimes I extract a zip or rar archive and don't care to delete one or the other, so now both the archive and its extracted contents take up disk space. This script hunts for such cases and offers to delete the extracted files. It could be modified to offer to delete the archive instead, too.
# encoding=utf8
import os, zipfile, rarfile, tarfile, shutil
# avoid encoding problems
import sys
def remove_file_or_tree(p):
You can’t perform that action at this time.