Skip to content

Instantly share code, notes, and snippets.

View Ozymandias42's full-sized avatar

Ozymandias42 Ozymandias42

  • Germany
View GitHub Profile
@Ozymandias42
Ozymandias42 / alpine-chroot.sh
Last active May 11, 2023 05:04
Chroot script for use with locked down Linux based NAS OSes
#!/bin/sh
basepath=$(dirname "${0}")
if [ "${basepath}" = "." ]
then
alpine="${PWD}/alpine"
else
alpine="${basepath}/alpine"
fi
@Ozymandias42
Ozymandias42 / replace-app-asar-with-open-app-asar.sh
Created December 17, 2022 12:29
Replaces app.asar with OpenSource app.asar in the Discord flatpak app
#!/usr/bin/env bash
#WEBCORD_APP_ASAR_DIR="/var/lib/flatpak/app/io.github.spacingbat3.webcord/x86_64/stable/active/files/bin/webcord/usr/lib/webcord/resources/"
WEBCORD_APP_ASAR_DIR="/var/lib/flatpak/app/com.discordapp.Discord/x86_64/stable/active/files/discord/resources/"
OPENSOURCE_APP_ASAR_URL="https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar"
function switch-for-open-asar-app(){
if [[ -e "$WEBCORD_APP_ASAR_DIR/app.asar-bak" ]] then
@Ozymandias42
Ozymandias42 / pulse-appmic-setup.sh
Last active July 20, 2021 22:19
Short Script that creates a streaming setup in pulseaudio.
#!/usr/bin/env bash
#Short script that creates a streaming setup in pulseaudio. It does the following:
#1. Create a null-sink as ApplicationSink to separate a single applications audio from the rest
#2. Create remap-source as Virtual Microphone; AppSource
#3. Loopback the the ApplicationSink's audio back to the systems default audio output
#4. Loopback AppSink into virtual microphone AppSource
# ┌────────────┐

Raspberry Pi OS:
Write Image to SDcard. Add empty file named 'ssh' to sdcard root.
Ref.: https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0

Alpine Linux:
Extract Image to local disk. Create apkovl.tar.gz overlay file that sets up networking and ssh.
Put file to the root of the sdcard.
In the same way it's possible to create a apkovl.tar.gz overlay file that runs setup-alpine with pre-made answerfile.
Ref.: https://wiki.alpinelinux.org/wiki/Raspberry_Pi_-_Headless_Installation
Ref.: https://docs.alpinelinux.org/user-handbook/0.1a/Installing/setup_alpine.html#_answer_files

#Single Liner
while [[ $(zypper pa --unneeded|tail -n+5|wc -l) -gt 0 ]]; do zypper pa --unneeded |tail -n+5|cut -d'|' -f3 | xargs sudo zypper rm; done
#Bash functions
zypper-cleanup() {
thingsToClean=$(zypper pa --unneeded|tail -n+5|awk -F'|' '{print $3}')
if [[ ${#thingsToClean[@]} -ne 0 ]]; then
echo ${thingsToClean[@]}|xargs sudo zypper rm -u
else
echo "Nothing to cleanup"
@Ozymandias42
Ozymandias42 / pulse-streaming-setup.sh
Last active May 14, 2021 20:22
Short bash script to setup a streaming setup with pulseaudio.
#!/usr/bin/env bash
#Short script that creates a streaming setup in pulseaudio. It does the following:
#1. Create a null-sink as ApplicationSink to separate a single applications audio from the rest
#3. Create another null-sink as Input-Combinator; CombineSink
#4. Create remap-source as Virtual Microphone; Vsource
#5. Loopback the the ApplicationSink's audio back to the systems default audio output
#6. Loopback ApplicationSink audio again, this time into the CombineSink
#7. Loopback actual microphone audio into the CombineSink as well
#8. Loopback combined application output and real-mic input from CombineSink into virtual microphone Vsource
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import re
import sys
if len(sys.argv) == 3:
URL=str(sys.argv[1])
cookie=dict(MoodleSession=str(sys.argv[2]))
else:
@Ozymandias42
Ozymandias42 / registry-find
Last active August 20, 2019 08:25
search function for windows registry in powershell
function Get-UninstallerFromRegistry {
param( [System.String] $query )
$paths=@(
"HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
)
$paths=$paths| Where-Object {(Test-Path $_) }
if ( $query -eq "" ) {