Skip to content

Instantly share code, notes, and snippets.

View tytydraco's full-sized avatar
🦆
Quack!

Tyler Nijmeh tytydraco

🦆
Quack!
View GitHub Profile
@tytydraco
tytydraco / process
Created October 8, 2022 17:25
Convert audio to OPUS format from a WEBM or other container.
#!/usr/bin/env bash
# Ignore SIGINT.
trap '' SIGINT
# Given a file name, get the audio codec.
get_codec_name() {
ffprobe "$1" \
-v quiet \
-show_streams \
@tytydraco
tytydraco / degrade_audio
Created October 6, 2022 04:43
A bash script to degrade audio from a container.
#!/usr/bin/env bash
trap 'echo Ignoring' INT
filename="$(basename -- "$1")"
ext="${filename##*.}"
filenameNoExt="${filename%.*}"
dir="$(dirname "$1")"
new="$dir/degraded_$filenameNoExt.$ext"
@tytydraco
tytydraco / extract_audio
Last active October 6, 2022 04:42
A bash script to extract audio from a container.
#!/usr/bin/env bash
trap 'echo Ignoring' INT
get_codec_name() {
ffprobe "$1" \
-v quiet \
-show_streams \
-select_streams a \
-show_entries stream=codec_name \
@tytydraco
tytydraco / convert_audio.sh
Last active December 30, 2022 05:31
Very simple script to convert audio files to a new format
#!/usr/bin/env bash
shopt -s globstar
FROM="opus"
TO="mp3"
OUT_DIR="Converted"
for file in **/*."$FROM"
do
@tytydraco
tytydraco / database_helper.dart
Created May 17, 2022 00:32
A helper class to handle basic SQLite operations in Flutter.
import 'dart:async';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
/// A very simple class that we recognize as SQLite-compatible
abstract class DatabaseModel {
Map<String, Object?> toMap();
}
@tytydraco
tytydraco / lc983.py
Created May 6, 2022 19:52
LC 983. Minimum Cost For Tickets
class Solution:
def mincostTickets(self, days: List[int], costs: List[int]) -> int:
# S[i] = min total cost to travel for up to i days
# S[i] =
# min(S[i-1] + costs[0], S[i-7] + costs[1], S[i-30] + costs[2]) if i is in days
# S[i-1] otherwise
# answer is S[-1]
# so either it is cheaper to check the price 7 days ago with the cost of a 7 day
# pass, or our pass is still in service, so the price does not change
@tytydraco
tytydraco / Bedrock Privacy Policy
Created July 29, 2021 14:06
The official privacy policy for Bedrock.
By using Bedrock, you are aggreeing to these terms.
Bedrock requests your 1) Google Account email, 2) Google public profile information, and 3) permission to modify Bedrock's own app data in Google Drive. No information is sent anywhere except for Google's own official APIs and the Bedrock app itself.
Bedrock requests read and write access to your "minecraftWorlds" folder on your device's internal storage. Bedrock uploads and downloads files and folders from this directory (and this directory only) to Google Drive exclusively.
@tytydraco
tytydraco / chrome_keys.sh
Created June 26, 2021 05:51
Quick chrome audio control: "[" -15%; "]" +15%
#!/usr/bin/env bash
xinput test-xi2 --root 3 | \
gawk '/RawKeyRelease/ {getline; getline; print $2; fflush()}' | \
while read -r key
do
[[ "$key" -ne 34 && "$key" -ne 35 ]] && continue
VOL="+15%"
[[ "$key" -eq 34 ]] && VOL="-15%"
@tytydraco
tytydraco / hash.sh
Last active June 18, 2021 19:57
Open an ADB shell session on an Android system via netcat
#!/system/bin/sh
LOCAL=false
PORT=65432
usage() {
echo "Usage: $0 [-h] [-l] [-k] [-p PORT]
-h Show this screen
-l Only allow localhost connections
-k Kill any open netcat sessions
@tytydraco
tytydraco / cleaner.sh
Last active June 4, 2021 23:52
Clear data and cache of disabled pacakges
#!/usr/bin/env bash
disabled_pks="$(pm list packages -d | sed 's/package://')"
for pkg in $disabled_pks
do
echo "----- $pkg -----"
pm uninstall "$pkg" &> /dev/null
echo "- UNINSTALLED UPDATES"
pm disable-user "$pkg" &> /dev/null
echo "- DISABLED AGAIN"