Skip to content

Instantly share code, notes, and snippets.

@lambdan
lambdan / bundle.py
Created August 27, 2022 20:07
nopaystation rap/pkg bundler
# if you know you know
import os, shutil
out_folder = "./bundled/"
pkg_folder = "./packages/"
rap_folder = "./exdata/"
rap_files = []
@lambdan
lambdan / killall_oculus.bat
Created May 28, 2022 19:21
Kill all oculus vr processes to fix Oculus Link
REM Killall oculus to get rid of the botnets... or if Oculus Link just is stubborn for some reason...
REM Killing everything Oculus related, and then opening the Oculus app again usually fixes it
REM Run as admin!
REM Multiples because theyre stubborn sometimes
taskkill /f /im OculusClient.exe
taskkill /f /im OVRRedir.exe
taskkill /f /im oculus-platform-runtime.exe
@lambdan
lambdan / caption.py
Last active February 19, 2022 11:56
Add custom captions, like subtitles, to images easily
# -*- coding: utf-8 -*-
# usage: caption.py image.jpg "The text"
# you can use a | to force a newline
# settings
strokew = 4 # outline width
stroke_color = "#101010" # outline color
font_color = "#f0f0f0" # ebeb0b=yellow, f0f0f0=white
@lambdan
lambdan / netatmo-dump.py
Last active February 12, 2022 11:10
Dump netatmo JSON to terminal
import netatmo, json, sys
if len(sys.argv) < 5:
# get clientid/secret from here https://dev.netatmo.com/apps/
print("usage: script.py clientid clientsecret username password")
sys.exit(1)
ws = netatmo.WeatherStation( {
'client_id': sys.argv[1],
'client_secret': sys.argv[2],
@lambdan
lambdan / check.py
Created January 25, 2022 15:52
convert videos with mp3 audio to aac
# remove .exe's to make it unix compatible
# needs mediainfo and ffmpeg
import os, subprocess
path = "Z:/Videos"
for f in os.listdir(path):
mi = subprocess.check_output(["mediainfo.exe", os.path.join(path,f)])
if "MPEG Audio" in str(mi):
print(f, "= mp3")
@lambdan
lambdan / install_ffmpeg.sh
Created July 1, 2021 16:18
Install latest ffmpeg and ffprobe to /bin/
#!/bin/bash
mkdir /tmp/ff
cd /tmp/ff
wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
tar -xf ffmpeg-git-amd64-static.tar.xz
rm ffmpeg-git-amd64-static.tar.xz
cd ff*
mv ffmpeg /bin/ffmpeg
mv ffprobe /bin/ffprobe
cd ~
@lambdan
lambdan / resolutionP.py
Created April 5, 2021 08:56
Function to get resolution (eg 1080p) from string (python3)
def resolutionP(string): # returns 720p from test.720p-foo and so on
string = string.lower()
if "0p" in string:
index = string.index("0p")
result = ""
# go backwards
while string[index].isnumeric():
result = result + string[index]
index -= 1
result = result[::-1] + "p" # reverse and add p
@lambdan
lambdan / foo_dr_renamer.py
Created April 3, 2021 09:03
Rename foo_dr.txt to DRX.txt
# usage: python3 foo_dr_renamer.py /path/to/music/folder/
# change ASK_FOR_CONFIRMATION to True if you want to decide manually
import os, sys, shutil
ASK_FOR_CONFIRMATION = False
if len(sys.argv) < 2:
print("no path given")
sys.exit(1)
@lambdan
lambdan / extract_highlights.py
Created December 29, 2020 17:03
extract highlights from video using list of timestamps
import os, subprocess, sys
# usage: extract_highlights.py <path-to-video> <path-to-timestamps>
# timestamps file format:
# hh:mm:ss bla bla bla
before_secs = 5 # secs to include before clip timestamp
after_secs = 25 # -"- after -" ... 5+25 = 30 sec clip
safe_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -0123456789."
@lambdan
lambdan / .zshrc
Last active November 29, 2020 22:36
zsh function to get absolute path to any file/folder using python3
# add this to to your .zshrc, then you can do `path file` to get the full path to that file, requires python
path() { python -c "import os;print(os.path.realpath(\""$1\""))" }