Skip to content

Instantly share code, notes, and snippets.

View hradec's full-sized avatar

Hradec hradec

View GitHub Profile
@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 \
@hradec
hradec / nas-bakup.py
Created July 15, 2021 17:18
A simple and handy script to automate backups using rsync. I use it on synology NAS to backup data every night for 6 hours max, limiting the max bandwidth.
#!/usr/bin/env python
import os, sys, datetime
import argparse
rsync='''rsync -avpPW %s --no-compress --inplace --delete --stats --exclude '#*' --exclude 'mirror.log' -e 'ssh -T -c [email protected] -o Compression=no -x -p %s' %s/ %s/ '''
# fbbackup01.myds.me
parser = argparse.ArgumentParser(description='Backup folders to backup nas')
parser.add_argument('source', help='a source path to copy files from.')
@hradec
hradec / gitclean.sh
Created March 28, 2021 00:10 — forked from Zibri/gitclean.sh
Bash script to remove all revisions from github or gist repository.
#!/bin/bash
#
# By Zibri (2019)
#
# Usage: gitclean username password giturl
#
gitclean ()
{
odir=$PWD;
if [ "$#" -ne 3 ]; then
@hradec
hradec / vr.py
Created October 10, 2020 20:27
A Python Script to automatically prioritize process for Oculus Link! (it also uses OculusDebugToolCli to setup ASW off for beatsaber)
import os, sys
import psutil
import time
vr=[
'vrserver.exe',
'vrcompositor.exe',
# 'steamvr.exe',
# 'vrmonitor',
# 'vrdash',
@hradec
hradec / cleanupUPNP.sh
Created July 30, 2020 20:37
A simple script to cleanup duplicated entries in a UPNP Server using upnpc!
#!/bin/bash
# to speed up the execution by not having to probe the network for the upnp server
# or if you have more than one upnp server in your network,
# use upnp_url var to specify the url of your upnp server.
# to find all the upnp servers urls, you can run:
# upnpc -l | grep 'InternetGatewayDevice' -B 1 | grep 'desc:'
#upnp_url="http://192.168.10.1:6352/rootDesc.xml"
@hradec
hradec / ue4-docker
Last active May 16, 2020 22:38
run ue4-docker without installing anything!
#!/bin/bash
if [ ! -e env/bin/ue4-docker ] ; then
python3 -m venv env
source env/bin/activate
pip3 install ue4-docker
deactivate
#!/usr/bin/python
import struct, socket, sys
# network block device server, substitute for nbd-server. Probably slower.
# But it works! And it's probably a lot easier to improve the
# performance of this Python version than of the C version. This
# Python version is 14% of the size and perhaps 20% of the features of
# the C version. Hmm, that's not so great after all...
# Working:
# - nbd protocol
# - read/write serving up files