Skip to content

Instantly share code, notes, and snippets.

View peci1's full-sized avatar

Martin Pecka peci1

  • Czech Technical University in Prague
  • Czech republic
View GitHub Profile
@peci1
peci1 / anonymize_pdf.sh
Last active January 4, 2021 18:07
Anonymize a PDF document with comments so that both document metadata and comment author data do not disclose who the author is.
qpdf --qdf --object-streams=disable $1 $1.tmp # uncompress /FlateDecode sections
perl -pe 's/(?<=\/T \()(.*?)(?=\))/ "x" x length($1) /e' $1.tmp > $1.tmp2 # remove /T commands containing author name in comments
qpdf --compress-streams=y $1.tmp2 $1.tmp3 # recompress streams
qpdf --empty --pages $1.tmp3 1-z -- $1.anonymous.pdf # remove document metadata (this also removes whole comments)
rm $1.tmp* # cleanup
@peci1
peci1 / scipy_odr_test.py
Created September 17, 2018 14:18
Test of scipy.odr regressor
from __future__ import print_function
import numpy as np
import scipy.linalg
from scipy.odr import *
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
import sys
import time
update_deb_from_github() {
repo=$1 # will use github.com/repos/${repo}/releases, so set to e.g. BoostIO/boostnote
pkg=$2 # name of the Deiban package e.g. apt can use, so e.g. boostnote
deb_type=$3 # a substring of the deb file on github releases which uniquely tells the requested deb from other deb files on the latest releases page
version_installed=$(LANG=C aptitude show boostnote | grep Version | grep -o '[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}')
download_link=$(curl -s https://api.github.com/repos/${repo}/releases/latest | jq -r ".assets[] | .browser_download_url" | grep "${deb_type}.*\.deb")
version_upstream=$(echo ${download_link} | grep -o '[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}' | head -n1)
if [[ "${version_installed}" != "${version_upstream}" ]]; then
wget -O "/tmp/${pkg}.deb" "${download_link}"
@peci1
peci1 / revert_packages_to_ppa_versions.sh
Created January 7, 2019 12:54
Revert all packages from non-PPA versions to their latest PPA version.
#!/usr/bin/env bash
# BSD 3-clause license, copyright Martin Pecka @ 2019
# This script outputs a command that will revert all packages from non-PPA versions to their latest PPA version.
# This may be handy i.e. for finding packages for which you installed a newer version from a .deb file, or after
# incompletely removing a PPA.
export LC_ALL=C
@peci1
peci1 / check_raid_status.sh
Last active January 13, 2019 23:49
A script for Turris Omnia that checks the status of a JMicron JMS56x RAID controller and sends a notification if something's wrong.
#!/bin/bash
# Based on the script from https://forum.odroid.com/viewtopic.php?t=29298
# Changes to that script are released under BSD license (c) Martin Pecka, 2019.
# raidmgr_static can be downloaded here: https://wiki.odroid.com/_media/accessory/add-on_boards/xu4_cloudshell2/raidmgr_static_cloudshell2.zip
RAID_MANAGER="/usr/bin/raidmgr_static"
STATUS="$(echo -e "SR C0\nEX\n" | $RAID_MANAGER)"
@peci1
peci1 / clean build output
Last active August 13, 2019 08:24
gazebo build problem
Subprocess > gazebo:make `cd /media/data/gazebo/build/gazebo; catkin build --get-env gazebo | catkin env -si /usr/bin/make --jobserver-fds=6,7 -j; cd -`
[gazebo:make] /usr/bin/cmake -H/media/data/gazebo/src/gazebo -B/media/data/gazebo/build/gazebo --check-build-system CMakeFiles/Makefile.cmake 0
[gazebo:make] /usr/bin/cmake -E cmake_progress_start /media/data/gazebo/build/gazebo/CMakeFiles /media/data/gazebo/build/gazebo/CMakeFiles/progress.marks
[gazebo:make] /usr/bin/make -f CMakeFiles/Makefile2 all
[gazebo:make] make[1]: Vstupuje se do adresáře „/media/data/gazebo/build/gazebo“
[gazebo:make] /usr/bin/make -f deps/opende/ou/CMakeFiles/gazebo_opende_ou.dir/build.make deps/opende/ou/CMakeFiles/gazebo_opende_ou.dir/depend
[gazebo:make] /us
@peci1
peci1 / FindFilesystem.cmake
Created January 13, 2020 20:18
CMake module for using the most modern of std::filesystem, std::experimental::filesystem and boost::filesystem.
# Distributed under the OSI-approved BSD 3-Clause License.
# Base on https://github.com/vector-of-bool/CMakeCM/blob/master/modules/FindFilesystem.cmake
#[=======================================================================[.rst:
FindFilesystem
##############
This module supports the C++17 standard library's filesystem utilities. Use the
:imp-target:`std::filesystem` imported target to enable support of it.
@peci1
peci1 / syslog-ng.conf
Created May 28, 2020 01:09
Syslog NG config for Turris Omnia which saves important parts of the logs to NAS. Date is also unified to a single timezone for all messages.
@version:3.19
options {
chain_hostnames(no);
flush_lines(0);
stats_freq(0);
flush_lines(0);
log_msg_size(65536);
};
@peci1
peci1 / Output:
Created July 1, 2020 13:54
Test of behavior when ROS subscribes to a message published using a different allocator
[ INFO]: pub1 a boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > >
[ INFO]: pub2 b boost::shared_ptr<sensor_msgs::PointCloud2_<boost::fast_pool_allocator<void, boost::default_user_allocator_new_delete, std::mutex, 32u, 0u> > >
[ INFO]: sub a boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const>
[ INFO]: Received message a is equal to p
[ INFO]: sub b boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const>
[ INFO]: Received message b is a new instance
[ WARN]: length PC2 with frame b
[ WARN]: write PC2 with frame b
[ WARN]: read PointCloud2 with frame b
@peci1
peci1 / ground_truth_publisher.cpp
Created September 26, 2020 14:21
Subt virtual publish ground truth
#include <ignition/transport.hh>
#include <ignition/msgs/pose_v.pb.h>
#include <ros/ros.h>
#include <nav_msgs/Odometry.h>
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/static_transform_broadcaster.h>
class GroundTruthPublisher
{