Skip to content

Instantly share code, notes, and snippets.

View hradec's full-sized avatar

Hradec hradec

View GitHub Profile
@hradec
hradec / tif-fp-image-display.py
Created November 12, 2024 00:14
tif-fp-image-display.py - display a floating point tif image without any color correction (mouse over shows pixel floating point value)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
from PIL import Image
import sys
import os
from PySide6.QtWidgets import QApplication
# Load the grayscale floating point TIFF image from command line
if len(sys.argv) != 2:
@hradec
hradec / python.cmd
Last active November 8, 2024 21:23
A windows batch file to quickly run python.sh in windows. It will download MSYS2 with all dependencies in the current folder, download python.sh and run it.
:: ================================================================================================
:: a wrapper script to run python.sh script in MSYS2 environment using bash
:: it will download and install MSYS2 in the current folder if it is not already installed
:: and then it will download python.sh script from the following URL and run it:
:: https://gist.github.com/hradec/32840097fe4cada3119468d8027155f9#file-python-sh
:: ================================================================================================
@echo off
:: folder where this script is located
set "_CMD_PATH=%~dp0"
@hradec
hradec / python.sh
Last active November 12, 2024 02:46
A simple way to setup a python virtual environment without having to install anything (no anaconda) - Linux and Windows
#!/bin/bash
# ================================================================================================================
# a simple script to create a virtual environment for python, install some basic packages and run a python script
# I known anaconda does the same, but I prefer to have a self-contained python environment in a folder without
# the need to install anything in the system.
# This script automatically downloads a self-contained python distribution in windows, so it can be used in any
# computer without any installation.
#
# In windows, use python.cmd to run this script. python.cmd will automatically download MSYS2 with bash and
# all dependencies to properly run this script.
@hradec
hradec / tar-progress.md
Created September 2, 2023 03:05 — forked from Kautenja/tar-progress.md
one-liners for using tar with gzip and pv for a progress bar

Compress

tar cf - <files> -P | pv -s $(du -sb <files> | awk '{print $1}') | gzip > <some .tar.gz file>

where:

  • `` is the root-mounted (i.e. starts with /) path to the files
@hradec
hradec / fixTheGreatSuspenderTabs.sh
Created July 20, 2023 01:46
A quick script to fix the broken tabs from TheGreatSuspender plugin that has been blocked by chrome.
!/bin/bash
# pull an export from FreshStart chrome plugin directly from the clipboard and fix the URLs
xclip -o | sed 's/,/,\n/g' | sed 's/chrome.extension.*uri.//g' | tr -d '\n' > /dev/shm/fixTheGreatSuspender
# just show the fixed version on the console
cat /dev/shm/fixTheGreatSuspender
# now copy it back to the clipboard, so we can import in FreshStart
xclip -selection c -i < /dev/shm/fixTheGreatSuspender
@hradec
hradec / wine-dowloader.sh
Created March 21, 2023 02:57
wine-dowloader.sh - a script that downloads wine from winehq Ubuntu 18.04 depot (can be used in most distros as standalone wine)
#!/bin/bash
CD=$(dirname $(readlink -f $0))
while getopts hlv: option ; do
case "${option}"
in
h) export HELP=1;;
l) export LIST=1;;
@hradec
hradec / downloadLatestZerotier.sh
Created November 24, 2022 19:25
zerotier download debian and uncompress
#!/bin/bash
v=$1
if [ "$v" == "" ] ; then
v=-1
fi
list=$(curl -L 'https://download.zerotier.com/RELEASES/' | gzip -d || curl -L 'https://download.zerotier.com/RELEASES/')
list=$(echo "$list" | awk -F'"' '{print $2}' | sort -V )
n=$(echo "$list" | wc -l | egrep -v '^$')
from arnold import *
import GafferArnold
import ctypes
import imath
import Gaffer
def convert_parameters( gaffer_shader, node ):
node_name = AiNodeGetName( node )
entry = AiNodeGetNodeEntry( node )
@hradec
hradec / redirect_to.sh
Last active September 28, 2022 02:17
iptables rules to redirect all ports to a different machine (192.168.0.3), but port 22
# ===============================================================================================================
# rules to redirect all ports to a different machine (192.168.0.3), but port 22
# ===============================================================================================================
redirect_to=192.168.0.3
iptables -A FORWARD -i eth0 -o eth0 -p tcp --syn --dport 1:21 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -i eth0 -o eth0 -p udp --dport 1:21 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -i eth0 -o eth0 -p tcp --syn --dport 23:65389 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -i eth0 -o eth0 -p udp --dport 23:65389 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -i eth0 -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --syn --dport 1:21 -j DNAT --to-destination $redirect_to
@hradec
hradec / ldif2synology.sh
Last active January 27, 2022 22:05
import an ldif file from openldap into a synology ldap server using ldapadd!!
#!/bin/bash
# run this in the machine running ldap server to export the db to ldif
# slapcat -n 0 -l config.ldif
# slapcat -n 1 -l data2.ldif'
# this mangles the ldif output so it can be import by synology openldap
cat data2.ldif | \
sed 's/dc=atomovfx,dc=lan/dc=ldap/g' | \
sed -e 's/Admin/admin/g' -e 's/Users/users/g' -e 's/ou=Group/cn=groups/g' -e 's/ou=/cn=/g' | \