Skip to content

Instantly share code, notes, and snippets.

View hradec's full-sized avatar

Hradec hradec

View GitHub Profile
@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' | \
@hradec
hradec / nsimage_photogrammetrySample.swift
Last active December 22, 2023 09:26
NSImage extension with functions that convert it to Depth, Disparity, Color and Mask CVPixelBuffer to be used directly in a PhotogrammetrySample object.
// this code is based on the original extension found in this
// other gist: https://gist.github.com/DennisWeidmann/7c4b4bb72062bd1a40c714aa5d95a0d7
// thanks Dennis Weidmann!
extension NSImage {
// function used by all functions below. It shouldn't be used directly
func __toPixelBuffer(PixelFormatType: OSType) -> CVPixelBuffer? {
var bitsPerC = 8
var colorSpace = CGColorSpaceCreateDeviceRGB()
var bitmapInfo = CGImageAlphaInfo.noneSkipFirst.rawValue
@hradec
hradec / gcloud-port-forward.md
Created August 19, 2021 22:54 — forked from jibs/gcloud-port-forward.md
port forwarding with a google cloud instance

Google cloud's ssh command lets you pass standard ssh flags. To, for example, forward local port 8088 to port 8088 on a vm instance, all you need to do is:

gcloud compute  ssh --ssh-flag="-L 8088:localhost:8088"  --zone "us-central1-b" "example_instance_name"

Now browsing to localhost:8088 works as it would with standard ssh.

@hradec
hradec / gl_ffmpeg.cpp
Last active August 16, 2022 12:03 — forked from rcolinray/gl_ffmpeg.cpp
OpenGL-FFMpeg integration
/*
based on github gist from rcolinray: https://gist.github.com/rcolinray/7552384
you need to build with glfw2, not glfw3.
adjusted for newer ffmpeg ( version>55 - avcodec_alloc_frame now is
av_frame_alloc, and some other defines have AV_ prefix added to it )
build it using something like:
g++ ./gl_ffmpeg.cpp \
-lavcodec -lavutil \