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 / .htaccess
Created May 22, 2014 21:02
Silly (but powerful) .htaccess handling of script-generated web thumbnails
#############################
# START: THUMBNAIL HANDLING #
#############################
# Since handling thumbnails in Nette is painfully slow (loading the whole framework
# just to find out that the thumbnail has already existed), there is a workaround
# that finds all the generated thumbnails using mod_rewrite and only redirects to the
# script if generating a thumbnail is really needed.
# Even for generating thumbs the standard Nette usage is slow, so there is another workaround.
@peci1
peci1 / dynamic_reconfigure_tools.py
Created November 5, 2015 01:55
ROS dynamic_reconfigure enum with variable value set.
def change_enum_items(type, parameter_name, new_items, default=None):
"""
Take an enum-typed parameter in the given autogenerated cfg type and reset its possible values to new_items.
You can then start a dynamic_reconfigure server which advertises the changed enum domain.
To achieve this, you need to call this function before creating the server.
:param type type: One of the autogenerated config types (package.cfg.*Config).
:param basestring parameter_name: Name of the enum parameter to change.
:param new_items: The items that will form the new domain of the enum.
// Author: Martin Pecka ( martin.pecka@cvut.cz )
// License: BSD
#ifndef DEM_GENERATION_SLOW_TOPIC_DIAG_UPDATE_H
#define DEM_GENERATION_SLOW_TOPIC_DIAG_UPDATE_H
#define private public
#include <diagnostic_updater/update_functions.h>
#undef private
@peci1
peci1 / Abbreviate Journal Names in Bibtex Database.py
Last active January 28, 2021 07:22 — forked from FilipDominec/Abbreviate Journal Names in Bibtex Database.py
Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys, os
import re
try: bibtexdb = open(sys.argv[1]).read()
except: print "Error: specify the file to be processed!"
if not os.path.isfile('journalList.txt'):
@peci1
peci1 / compile_darktable_on_windows.sh
Last active June 19, 2021 11:34
A script for compiling Darktable on Windows using the Windows Subsystem for Linux ("bash for Windows") introduced in Win 10.
#########################################
# DO NOT REPORT ANY BUGS FROM DARKTABLE INSTALLED THIS WAY.
#
# This is an unofficial compilation & installation guide.
# Darktable developers explicitly say that they don't support Windows ANY way and won't fix ANY bugs on Windows.
# Please, respect their decision and do not bother them with Windows bugreports.
#
# If you find a bug, please verify it on a regular Linux/Mac system or inside a virtual machine.
#
# There is a chance an official Windows build will appear. Just subscribe to https://github.com/darktable-org/darktable/pull/1327 to be informed.
@peci1
peci1 / transparent-tor.diff
Created November 2, 2017 02:14
A trial to get transparent .onion translation on Omnia
diff -Nru @161/etc/config/resolver @/etc/config/resolver
--- @161/etc/config/resolver 2017-10-01 21:01:14.375423242 +0200
+++ @/etc/config/resolver 2017-11-02 01:13:47.862130135 +0100
@@ -21,6 +21,7 @@
option log_stderr '1'
option log_stdout '1'
option forks '1'
+ option include_config '/etc/kresd/config.conf'
config resolver 'unbound'
@peci1
peci1 / torrc
Last active March 31, 2022 14:47
My torrc on Turris Omnia
SOCKSPort 9050
SOCKSPolicy accept 127.0.0.1/32
SOCKSPolicy accept 192.168.18.0/24
SOCKSPolicy accept6 FC00::/7
SOCKSPolicy reject *
Log notice syslog
RunAsDaemon 1
DataDirectory /srv/tor
AvoidDiskWrites 1
ORPort 9001
@peci1
peci1 / print_bytes_in_all_encodings.py
Created December 25, 2017 23:05
Print the characters corresponding to the given byte sequence in all encodings known to the python interpreter.
#!/usr/bin/env python3
import encodings
import pkgutil
bytes_to_decode = b"\xc4\x9b"
codecs = []
for importer, modname, ispkg in pkgutil.iter_modules(encodings.__path__):
try:
@peci1
peci1 / nas
Created May 31, 2018 00:01
OpenWRT: automount NTFS drive by UUID and before mountd comes into action and mounts it under /tmp/run/mountd
#!/bin/sh /etc/rc.common
# This is a procd initscript, so put it in /etc/init.d/
START=79 # Important: this number must be lower than the START number in /etc/init.d/mountd !!!
USE_PROCD=1
PROGNAME="/usr/bin/ntfs-3g"
# Fill these values as desired
@peci1
peci1 / pb_model_executor.py
Created June 1, 2018 20:25
Tensorflow executor of models from TF 1.4+ on TF 1.3- (python 3)
import tensorflow as tf
import numpy as np
class PbModelExecutor:
def __init__(self, model_path, input_shape, input_name='input', output_name='output:0'):
self.session = tf.Session()
self.input = tf.placeholder(tf.float32, shape=input_shape)